RHEL7 system repair rm-rf/boot/etc/fstab
Guide |
RHEL7/Centos7 has been released for so long. We all know that one feature of this system is that systemctl replaces the init system daemon process, and the system is becoming more and more modular. Many Commands have also changed in the new version of the system, and grub has changed to grub2, which is completely incomprehensible. There are also many online tutorials comparing the new version with the old version. I have been trying to fix the 7 version of the system. Today, I have killed the system by hand. |
Brute force killer system --- "rm-rf/boot/etc/fstab"
/Boot/stores the system kernel and boot file, in the "grub2/grub. cfg stores the mbr boot Record information of the system. The rm-rf/boot system must have crashed, next we will create a more absolute--"rm-rf/etc/fstab" to kill the partition table.
Restart the system and find that the system has crashed:
Repair, go to the system CD
At present, our repair cannot be carried out by using the tool that comes with our linux system, because our system has been suspended and there is no system available, next, you need to perform the following operations: import the disc, start from the disc, and choose-Repair Option.
Note: You can select the CD, network, and other boot devices such as USB flash drives and hard disks in the Quick Start item. In the enterprise environment, we need to start the pxe network. If the pxe network does not deploy the server, you need to insert the disc, boot disk of the USB flash drive, and mount the hard disk to another linux System for repair.
Go to the disc repair mode to repair
On the boot disk in RHEL7, move the cursor up and down to select the third item "Troubleshooting" rescue mode and press enter to enter;
The boot disk in RHEL7 has three options:
1. "Install Red Hat Enterprise Linux 7.0" ---- Install RHEL7.0 OS 2. "Test this media & install Red Hat Eenterprise Linux 7.0" Test whether the boot disk is complete and install RHEL7.03. "Troubleshooting" ---- rescue mode in Error Mode
Enter the disc repair mode and repair wizard
Follow the Wizard to repair the system's fstab, that is, let the system find the disk partition.
In the rescue mode of the CD, a pseudo system similar to windows pe is available. In this pseudo system, we use the "df" command to view the system partition and find that there is no mounted partition. We use the "fdisk" command tool to view the partition information of our hard disk, and then write "/etc/fstab" to find the system partition.
There is no command prompt in the pseudo system. At this time, the "pwd" command will play a role. We will create a mount point in the current location, then mount the disk partition to the mount point, and then run the "ls" command to view the content below the partition to identify the specific location of the partition:
After the partition content is identified, we find "/" write "/etc/fstab ". Let the system identify system files
All right, write the fstab file and find the partition. restart the system, start the disk, and fix it again.
Repair/boot/kernel files
Restart and start from the CD. Go to "pseudo system" to fix the problem.
Idea: 1. according to the wizard prompt, we have found the system partition and mounted the hard disk to the/mnt/sysimage/directory, next, we need to switch the environment to our hard disk system, that is,/mnt/sysimage2. in the previous step, we found that we mistakenly wrote home as boot. As for how to find this error, you need to enter the directory for ls viewing and use the pwd command to imagine the current location. 3. we checked in the/boot/ls below and found that our file is empty. Imagine that the boot contains important information such as our kernel, RAMDISk file, and boot, these things are related to our kernel. What should we do without a kernel? -- Manually install the kernel -- how to install it? -- Rpm package installation -- installation source? -- CD or ftp -- CD mounting -- mounting in a pseudo System -- creating a mount point -- installation...
"cd ..mkdir 1mount /dev/sr0 1cd 1/Packages/rpm -ivh kernel—3.10XXX --root=/mnt/sysimage/ --enforce"
To install the kernel in a pseudo system, "-- root =/mnt/sysimage -- enforce" forcibly installs the kernel in the hard drive system as root.
During the long wait, all kernel-related files have been installed.
Next we will fix the grub file of mbr:
"Grub2-install/dev/sda" add boot on the first hard disk to fix grub2 Related Files
"Grub2-mkconfig/boot/grub2/grub. conf" regenerate boot item to file
OK. Our "grub2.conf" is successfully repaired.
The disk partition is repaired successfully, the kernel file is repaired successfully, and the boot file is repaired successfully. The system has all the partitions. OK to test.
Restart Test
Restart and we can see that the linux Startup item is included in our boot item.
Refresh the tag and wait for it again. During this process, the tag may be restarted multiple times.
The test is successful, and rhel7 has been in violation for a long time:
System Repair Summary
1. When the/boot/file and fstab file are lost in the system, you need to go to the RHEL system disc to go to the rescue repair mode for repair or repair in other linux systems.
2. in rescue and repair mode, follow the Wizard to check whether the partition can be found. Then read the Kernel File and finally the boot file.
3. kernel installation runs through "rpm-ivh" in a pseudo system. "-- root =/mnt/sysimage -- enforce" forcibly installs the kernel on the hard disk system as root.
4. Fixed grub file "grub2-install/dev/sda" add boot "grub2-mkconfig/boot/grub2/grub. conf" rebuild boot item to file
5. In the rescue and repair mode, Common commands are "pwd" and "ls". Be sure to pay attention to your current location.
6. By default, the system mounts the hard disk to "/mnt/sysimage". You cannot habitually mount the disc to "/mnt". Otherwise, you will delete all files on the hard disk.
7. General Plan: Rescue mode-partition file-kernel-related file-pilot grub2 File