我们查询系统磁盘信息,发现硬盘设备 sda 没有包含任何分区。
bash-4.1# fdik – l Disk /dev/sda: 43.0 GB, 42991616000 bytes 255 heads, 63 sectors/track, 5226 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00032735 Device Boot Start End Blocks Id System Disk /dev/sdb: 2147 MB, 2147483648 bytes 255 heads, 63 sectors/track, 261 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xcdd48395 Device Boot Start End Blocks Id System /dev/sdb1 1 261 2096451 83 Linux |
我们来恢复它的硬盘分区表,创建一个目录并且挂载之前备份的 USB 设备,我们看到它的设备名是 /dev/sdb。
bash-4.1# mount /dev/sdb1 /usb bash-4.1# ls /usb lost+found sda.mbr |
通过原来备份的 sda.mbr 文件来恢复硬盘设备 sda 的硬盘分区表 :
bash-4.1# dd if=/usb/sda.mbr of=/dev/sda bs=1 count=64 skip=446 seek=446 64+0 records in 64+0 records out 64 bytes (64 B) copied, 0.038358 s, 4.6 kB/s |
再次查询系统磁盘信息:
bash-4.1# fdisk -l Disk /dev/sda: 43.0 GB, 42991616000 bytes 255 heads, 63 sectors/track, 5226 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00032735 Device Boot Start End Blocks Id System /dev/sda1 * 1 17 131072 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 17 147 1048576 82 Linux swap / Solaris Partition 2 does not end on cylinder boundary. /dev/sda3 147 5227 40803328 83 Linux Disk /dev/sdb: 2147 MB, 2147483648 bytes 255 heads, 63 sectors/track, 261 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xcdd48395 Device Boot Start End Blocks Id System /dev/sdb1 1 261 2096451 83 Linux |
硬盘设备 sda 的分区表已经恢复,重启后系统便可正常引导。
系统 GRUB 损坏
类似得我们可以来写零 Bootloader 来实现 GRUB 被破坏的结果:
[root@FCoE grub]# dd if=/dev/zero of=/dev/sda bs=446 count=1 1+0 records in 1+0 records out 446 bytes (446 B) copied, 0.0017583 s, 254 kB/s |
重启后系统会因找不到 GRUB 而卡在“Booting from Hard Disk …”
挂载系统安装光盘然后选择进入 Rescue 模式,然后恢复 GRUB:
bash-4.1# chroot /mnt/sysimage sh-4.1# grub grub > root hd(0,0) grub > setup (hd0) grub > quit |
图 5. 恢复 GRUB
重启主机后,系统可正常引导。
系统内核文件丢失
系统丢失内核 kernel 文件,再次启动后会提示找不到文件。
图 6. 内核丢失
挂载系统安装盘进入援救模式,检查 /boot 目录下发现没有 kernel 文件。
bash-4.1# chroot /mnt/sysimage bash-4.1# ls /boot ls config-2.6.32-71.el6.x86_64 lost+found efi symvers-2.6.32-71.el6.x86_64.gz grub System.map-2.6.32-71.el6.x86_64 initramfs-2.6.32-71.el6.x86_64.img |
从挂载的系统安装盘强制重新安装内核:
sh-4.1# mount – o loop /dev/sr0 /media sh-4.1# cd /media/Server/Packages sh-4.1# rpm -ivh --force kernel-2.6.32-71.el6.x86_64.rpm warning: kernel-2.6.32-71.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, \ key ID fd431d51: NOKEY Preparing... ########################################### [100%] 1:kernel ########################################### [100%] |
在 /boot 目录下已经生成新的 kernel 文件 vmlinuz-2.6.32-71.el6.x86_64
sh-4.1## ls /boot config-2.6.32-71.el6.x86_64 lost+found efi symvers-2.6.32-71.el6.x86_64.gz grub System.map-2.6.32-71.el6.x86_64 initramfs-2.6.32-71.el6.x86_64.img vmlinuz-2.6.32-71.el6.x86_64 |
重启主机后,系统可正常引导。

