One experience to solve grub boot error

  

My computer has two hard drives, one solid state drive (sda) installed win7, another ordinary hard disk (sdb) installed ubuntu and centos two systems, system boot The boot is ubuntu grub2 installed on sdb, it is responsible for selecting different operating systems to start, OK, the background is finished, and then we start to talk about our problems.

Added a new partition to sdb last night, as follows:

 1 Disk /dev/sdb: 500.1 GB, 500107862016 bytes 2 255 heads, 63 sectors/track, 60801 cylinders, total 976773168 Sectors 3 Units = sectors of 1 * 512 = 512 bytes 4 Sector size (logical/physical): 512 bytes /4096 bytes 5 I/O size (minimum/optimal): 4096 bytes /4096 bytes 6 Disk identifier: 0xa887a887 7 8 Device Boot Start End Blocks Id System 9 /dev/sdb1 2048 125829119 62913536 83 Linux10 /dev/sdb2 125829246 970502711 422336733 f W95 Ext'd (LBA)11 Partition 2 does not start on physical sector boundary.12 /dev/sdb5 125829248 221983352 48077052 + 7 HPFS/NTFS/exFAT13 /dev/sdb6 221983424 228274807 3145692 b W95 FAT3214 /dev/sdb7 228274872 518603944 145164536+ 7 HPFS/NTFS/exFAT15 /dev/sdb8 518604008 782021941 131708967 7 HPFS/NTFS/exFAT16 /dev/sdb9 782024704 918054911 68015104 83 Linux17 /dev/sdb10 918056960 934834175 8388608 83 Linux18 /dev/sdb11 934836224 951613439 8388608 83 Linux19 /dev/sdb12 951615488 960004095 4194304 82 Linux swap /Solaris20 /dev/sdb13 960004159 970502711 5249276+ 83 Linux21 Partition 13 does not start on physical sector boundary. 

The 13-line sdb6 is my newly added partition. Since this partition is added in the middle of the disk, it will cause all the partition numbers to change. (For example, the root directory of centos was originally installed in sdb8, it has now become Sdb9), my ubuntu root directory is installed in sdb1, because its partition number has not changed, so the ubuntu system can start normally, and the centos system can not start!


I can't start the error, I just thought about the boot problem, so I called the update-grub command under ubuntu to update grub2. Start the entry, the result of the update is this:

Generating grub configuration file ...Found background image: ubuntu_kylin_grub_bg.tgaFound linux image: /boot/vmlinuz-3.13.0-46-genericFound initrd image: /boot /initrd.img-3.13.0-46-genericFound linux image: /boot/vmlinuz-3.13.0-32-genericFound initrd image: /boot/initrd.img-3.13.0-32-genericFound memtest86+ image: /boot/Memtest86+.elfFound memtest86+ image: /boot/memtest86+.binFound Windows 7 (loader) on /dev/sda1Found CentOS release 6.6 (Final) on /dev/sdb9done 

As you can see from the above, all three operating systems are found. It should be able to start normally now. I restarted and tried it. Centos started or failed. . . .


Later I was thinking, my centos system's home directory and var directory are separate partitions, is it automatically mounted when it starts, so I went again Modify the /etc/fstab file of centos. I used the partition number to identify the partition (such as /dev/sdb9). Here I changed it to use UUID to identify the partition. Here also learned a little trick, the original UUID number of the partition is stored in the /dev/disk/by-uuid/directory, all saved is a soft link, ll you can see which hard disk it points to, as follows :


After I changed the fstab, I restarted the system and found that it still didn't work. I am very depressed, I have been thinking about where the problem lies. Later, I looked at the grub2 configuration file (grub.cfg) and finally found the problem above the startup command, as shown below:

 1 menuentry 'CentOS release 6.6 (Final) (on /dev/Sdb9)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-d24c3228-5ffc-4937-8411-a69681c3b54e' { 2 insmod part_msdos 3 insmod ext2 4 set root='hd1, Msdos9' 5 if [ x$feature_platform_search_hint = xy ]; then 6 search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos9 --hint-efi=hd1,msdos9 -- Hint-baremetal=ahci1,msdos9 d24c3228-5ffc-4937-8411-a69681c3b54e 7 else 8 search --no-floppy --fs-uuid --set=root d24c3228-5ffc-4937-8411-a69681c3b54e fi 9 linux /boot/m uz ro root root root root root Initrd /boot/initramfs-2.6.3 2-504.12.2.el6.i686.img11 } 

This is the part of the grub.cfg file about centos startup. In the ninth line of the linux command, it selects the kernel to mount the root file with a read-only command. In the system, the selected partition is sdb8, and at this time sdb8 has become the ntfs partition of windows, so when my system starts, it will prompt a bunch of unrecognized file system types (ntfs), as long as Changed to sdb9 here, my system will start normally!

^ o ^


After the startup, I haven’t been happy for a long time. I found that running the update-grub command under ubuntu, the grub.cfg file is overwritten. It is. . No way, you have to continue to analyze!

After analysis, it was found that the boot entry for centos was generated by the /etc/grub.d/30_os-prober configuration file, and in this file, the linux-boot-prober command eventually generated grub. The partition name followed by the root command in line 9 of the .cfg file! The linux-boot-prober command is to find a configuration file similar to "menu.lst" in a given partition name. As a result, I finally found out that the problem is still in the configuration file of the centos system, as shown below: Br>

1 title CentOS (2.6.32-504.12.2.el6.i686)2 root (hd0,9)3 kernel /boot/vmlinuz-2.6.32-504.12.2.el6.i686 ro root=/Dev/sdb8 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=128M KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet vga=7914 initrd /boot/initramfs-2.6.32-504.12.2.el6.i686 .img

I originally changed the partition selected by the root command of line 2, but did not change the partition selected by the root command in the third line, so my system could not be started. .


OK, change the configuration file of centos, the problem is finally solved! ^ . ^

Copyright © Windows knowledge All Rights Reserved