MBR sector failure
A brief diagram of the hard disk storage Logic
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/8A/8A/wKioL1gz4QqzNH_UAAD-IwXpm8E160.png "/>
The first sector of the MBR in the first track of the first disk.
From: http://www.cnblogs.com/wuguanglei/p/4244639.html
Back up MBR data
Note! MBR data needs to be backed up on other hard disks and backed up in multiple locations!
Check the partition information. We have two hard disks.
# df -hFilesystem Size Used Avail Use% Mounted on/dev/sda2 19G 5.5G 13G 32% /devtmpfs 485M 0 485M 0% /devtmpfs 490M 12K 490M 1% /dev/shmtmpfs 490M 6.8M 484M 2% /runtmpfs 490M 0 490M 0% /sys/fs/cgroup/dev/sda1 93M 65M 22M 75% /boottmpfs 98M 0 98M 0% /run/user/0/dev/sdb1 991M 2.6M 922M 1% /data
Now, the MBR information is written to the second hard disk. The/data directory is mounted to the second hard disk.
# dd if=/dev/sda of=/data/mbr.bin bs=512 count=1
Simulate MBR corruption
# dd if=/dev/zero of=/dev/sda bs=512 count=1
After the system is restarted, the Linux system cannot be started.
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/8A/8A/wKioL1gz4QvjdWQdAAAxETB8OxI789.png "/>
Repair MBR damage
1. Linux system CD or USB flash drive is required
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/8A/8D/wKiom1gz4QyS_ca4AAA4thq0-S0313.png "/>
Select troubleshooting mode and rescue mode
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/8A/8A/wKioL1gz4Q3wcmNMAAB3FxUr_nE334.png "/>
The disk will be mounted to/mnt/sysimage /.
Continue mounts partitions in RW mode.
Read Only mounts partitions in RO mode.
Skip the Skip and manually attach the disk.
Continue. In fact, the original system partition cannot be mounted because the partition table is no longer in use.
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/8A/8D/wKiom1gz4Q-TrJwOAACENN_2EwY160.png "/>
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/8A/8D/wKiom1gz4Q-A1fPYAAAzc5v3YyE277.png "/>
2. Mount the second hard disk that saves MBR data
#fdisk -l
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/8A/8A/wKioL1gz4RCSZA8SAAAuvTA3xHw440.png "/>
#mkdir /data#mount /dev/sdb1 /data
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/8A/8D/wKiom1gz4RHiGXvmAAAI92kTegU744.png "/>
3. Use Backup MBR data to Repair System Disk Partitions
#dd if=/data/mbr.bin of=/dev/sda bs=512 conut=1
Summary of comparison with centos6
Compared with centos 6, centos7 and centos6 are consistent in the repair process of MBR damage.
The extended primary boot program is corrupted.
If the MBR partition information is not damaged and the main Bootstrap program is damaged
Mount the original system to/mnt/sysimage.
# Chroot/mnt/sysimage # grub2-install/dev/SDA or # grub2-install root-directory =/mnt/sysimage/dev/SDA
Glibc upgrade causes the system to fail to start
Enter the rescue mode again, replace it with the database file before upgrade, and restart.
/Etc/fstab file loss
The "/etc/fstab" configuration file determines how each partition is loaded after the Linux system is started, such as the root partition "/" and "/Boot" partitions. If these partitions cannot be mounted, the system will mount the root partition with Ro. After the "/etc/fstab" file is lost, the file system cannot be written after it is started.
In rescue mode, recover the/etc/fstab file.
Forget the root user password
Reset the password of the root account in single-user mode
single
GRUB boot fault simulation grub fault
Grub is the default boot program used by most Linux systems. You can choose to enter different operating systems (if any) through the boot menu ). When "/boot/grub2/grub. when the CFG 'configuration file is lost, the key configuration is incorrect, or the boot program in the MBR record is damaged, the "Grub>" prompt may appear after the Linux host starts, further system startup cannot be completed.
# mv /boot/grub2/grub.cfg /boot/grub2/grub.cfg.bak
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/8A/8A/wKioL1gz4RHjdX5dAAAWbcI8zto463.png "/>
Fix grub faults
1. Specify the file system, which can be XFS or ext2. The default file system centos7 is XFS.
grub>insmod xfsorgrub> insmod ext2
2. Set root: specify the location of the/boot partition containing boot files such as the kernel
grub> set root=‘hd0,msdos1‘
# Hd0 indicates the first hard disk msdos1 indicates the first partition
3. linux16: specify the location of the kernel file. When the kernel is loaded, the permission is read-only "Ro" and the root partition device file location is specified through "root =.
If you do not know the kernel file name, you need to check it in the centos System Version/boot/grub2/grub. cfg.
grub>linux16 /vmlinuz-3.10.0-123.el7.x86_64 ro root=/dev/sda1rhgbquiet
# Here, root indicates the directory where the root partition is located.
Note:
ro #read onlyrhgb # redhat graphical bootquiet #disable all log messages
4. specify the location of the temporary system image file used to start the kernel
grub>initrd16 /initramfs-3.10.0-123.el7.x86_64.img
After the repair is completed, you can enter the system and recreate the configuration file.
Use the CD rescue mode for restoration
chroot /mnt/sysimage grub2-install /dev/sda
Summary of comparison with centos6
Grub> root (hd0, 0) grub> kernel/vmlinux-2.6.18-8.e15 Ro root =/dev/volgroup00/logvo100 rhgb quiet grub> inited/initrd-2.6.18-8.e15.img grub> boot
>: Title: The name of the operating system displayed in the Startup menu.
>: Root: specify the location of the/boot partition containing the boot file such as the kernel.
>: Kernel: Specifies the location where the Kernel File is located. When the kernel is loaded, the permission is read-only "Ro" and the root partition device file location is specified through "root =.
>: Initrd: Specifies the location of the temporary system image file used to start the kernel.
Centos7 and centos6 are started in the grup boot system. Some commands have changed. Please pay attention to them!
[Boiled water]-fault-centos7 startup fault-knowledge point