更多信息,请访问glygo
Ubuntu 修复grub2
蛋疼手贱,在windows下把winX86分区改为主分区,结果开机就挂了,gruberror了,grubrescure啊,无奈,先在win7PE环境下用diskgenius重建了mbr,暂时可以进win7系统了,进入之后用easyBCD增加ubuntu启动项(grub2),结果还是错误。度娘万能,赶紧看看怎么解决。百度很多,再尝试,结果发现都不见效,猛然醒悟,那些都是针对grub的,赶紧再找了下grub2相关到,总算解决了问题。研究了半天,才解决这个问题。先说说是怎么回事。
安装ubuntu时,启动是用grub2进行启动。我的系统折腾多了,盘分得相当混乱了。
Disk/dev/sda: 91201 cylinders, 255 heads, 63 sectors/track
Warning:extended partition does not start at a cylinder boundary.
DOSand Linux will interpret the contents differently.
Units= cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
DeviceBoot Start End #cyls #blocks Id System
/dev/sda1 * 0+ 154- 155- 1242108+ 7 HPFS/NTFS/exFAT
/dev/sda2 0 - 0 0 0 Empty
/dev/sda3 154+ 91201- 91047- 731329536 f W95 Ext'd (LBA)
end:(c,h,s) expected (1023,254,63) found (65,84,19)
/dev/sda4 0 - 0 0 0 Empty
/dev/sda5 154+ 5219- 5065- 40684544 7 HPFS/NTFS/exFAT
end:(c,h,s) expected (1023,254,63) found (99,224,61)
/dev/sda6 5220+ 16767- 11548- 92755968 7 HPFS/NTFS/exFAT
start:(c,h,s) expected (1023,254,63) found (1023,34,63)
end:(c,h,s) expected (1023,254,63) found (1023,183,56)
/dev/sda7 16767+ 19200- 2433- 19537920 83 Linux
start:(c,h,s) expected (1023,254,63) found (1023,216,26)
end:(c,h,s) expected (1023,254,63) found (1023,52,52)
/dev/sda8 19200+ 20425- 1225- 9838592 83 Linux
start:(c,h,s) expected (1023,254,63) found (1023,85,22)
end:(c,h,s) expected (1023,254,63) found (1023,46,37)
/dev/sda9 20425+ 20911- 487- 3905536 82 Linux swap / Solaris
start:(c,h,s) expected (1023,254,63) found (1023,79,7)
end:(c,h,s) expected (1023,254,63) found (1023,134,23)
/dev/sda10 20911+ 25652- 4742- 38083584 83 Linux
start:(c,h,s) expected (1023,254,63) found (1023,166,56)
end:(c,h,s) expected (1023,254,63) found (1023,214,34)
/dev/sda11 25653+ 32027- 6375- 51201024 7 HPFS/NTFS/exFAT
start:(c,h,s) expected (1023,254,63) found (1023,187,7)
end:(c,h,s) expected (1023,254,63) found (1023,246,27)
/dev/sda12 32028+ 87282- 55254- 443827196+ 7 HPFS/NTFS/exFAT
start:(c,h,s) expected (1023,254,63) found (1023,23,60)
end:(c,h,s) expected (1023,254,63) found (1023,6,13)
/dev/sda13 87282+ 91201- 3919- 31478784 b W95 FAT32
start:(c,h,s) expected (1023,254,63) found (1023,38,53)
end:(c,h,s) expected (1023,254,63) found (1023,20,19)
我们知道,每次系统启动时都是先进入grub,也就是先在ubuntu的启动目录里选择进入哪个系统,如果按分区来讲,grub2在(hd0,msdos10)也就是我的ubuntu所在的分区。那么启动时root应该设在(hd0,msdos10),在更改了分区设置之后,我的分区号码发生了改变,msdos10已经不再指向ubuntu的所在分区,而ubuntu是不能识别NTFS这种文件系统的,所以就有了
这种情况下自然不能启动,那么grub2就会启动grub rescue模式,就是修复模式。那么我们要做的就是把grub重新指向ubuntu的所在分区即可解决问题。error:unknownfilesystem
下面是具体步骤:
①查看分区
因为每个人的分区不一样,所以我们要查看分区,用ls指令
grub rescue>ls
回车后,
(hd0)(hd0,msdos13) (hd0,msdos12) (hd0,msdos11) (hd0,msdos10)(hd0,msdos5)....(hd0,msdos1) grub rescue>
注:我用的是grub2,对于grub用户,分区前没有msdos字样
上面是我的分区,每个人的不一样。grub rescue >set
回车,出现:
从上面可以看出来现在我的ubuntu系统是从(hd0,msdos10)里启动的。prefix=(hd0,msdos10)/boot/grub root=hd0,msdos10
那么怎么知道ubuntu在哪个分区呢?进入第二步
②寻找ubuntu所在分区
这一步我们要一个一个的试,
还是用ls指令
先试下在不在(hd0,msdos10)里边
回车会发现,不是,还是unknown file system(NTFS无法识别带来到结果)grubrescue>ls (hd0,msdos10)
接着来
。。。。。。。。。
当我试到
(hd0,msdos8)的时候,可以看到
难道我的分区内容挂了?其实没有,只是grub2未能识别其中到内容而已。badfilename
③修改启动分区
grubrescue>root=(hd0,msdos8) grubrescue>prefix=/boot/grub //grub路径设置 grubrescue>set root=(hd0,msdos8) grubrescue>set prefix=(hd0,msdos8)/boot/grub grubrescue>insmod normal //启动normal启动 grubrescue>normal
出现了熟悉到启动选项画面,太激动了!
⑥进入ubuntu修复grub
大功就要高成了
进入Ubuntu后,修复grub
在终端里运行
sudo update-grub
重建grub到第一硬盘mbr
sudo grub-install /dev/sda
好啦,重启,一切搞定!