Get the App
SLTechnology News&Howtos  ›  Servers  › 

Centos7 grub damage repair

Shulou Source: shulou.com Published: 2022-06-02 20:04:22 09月22日 Update

The tester came to me and told me that the test environment could not be remotely operated, but I could ping. After logging in to the virtual machine, I found that the system had been faked dead and could not be operated, so I had no choice but to reset the virtual machine. After the reset, the virtual machine could not enter the system prompt:

Error: can't find command':'

Grub >

1. Manual boot

# failed to repair grub by manual boot! #

Grub > ls

Grub > ls (hd0,msdos1) / grub2 # # separate partition

Grub > insmod xfs

Grub > set root= (hd0,msdos1) (- > this is the boot partition you found in the previous step)

Grub > linux16 / vmlinuz-xxxxx root=/dev/sda1 # I see sda1 when boot partition through rescue mode

Grub > initrd16 / initramfs-.xxxxx.img

Grub > boot

#! Failure! #

2. Repair through rescue mode

(1) the virtual machine loads the centos7 CD-ROM drive, and the BIOS setting is started through dvd.

(2) Select Trobleshooting

(3) Select Rescue a CentOS Linux system

(4) Select 1) Continue

(5) enter the sh interface

Sh-4.2# chroot / mnt/sysimage # change to the root directory

Sh-4.2# cp-r / boot/ / tmp/ # backup boot partition files

Sh-4.2# rm-fr / boot/* # Delete all files under the boot partition

Sh-4.2# mount / dev/cdrom / media # Mount the CD-ROM drive

Sh-4.2# rpm-ivh / mnt/Packages/kernel-3.10.0-514.e17.x86_64.rpm-- force # reinstall the kernel, preferably with the previous version of the kernel

Sh-4.2# grub2-install / dev/sda1 # install grub directory

Sh-4.2# grub2-mkconfig-o / boot/grub2/grub.cfg # repair grub2 configuration file

Sh-4.2# exit

Sh-4.2# reboot

Choose: boot from the hard disk, the system can find the grub normally, find the kernel to boot normally, and the repair is complete.

Tags: Select kernel file system optical drive manual mode directory virtual machine rescue test personnel method backup best machine version environment interface hard disk Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology NVidia MariaDB vpn Huawei