Ubuntu 修复grub2

更多信息,请访问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这种文件系统的,所以就有了

      error:unknownfilesystem
        这种情况下自然不能启动,那么grub2就会启动grub rescue模式,就是修复模式。那么我们要做的就是把grub重新指向ubuntu的所在分区即可解决问题。


下面是具体步骤:


①查看分区
因为每个人的分区不一样,所以我们要查看分区,用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

回车,出现:

prefix=(hd0,msdos10)/boot/grub
root=hd0,msdos10
从上面可以看出来现在我的ubuntu系统是从(hd0,msdos10)里启动的。

那么怎么知道ubuntu在哪个分区呢?进入第二步


②寻找ubuntu所在分区
这一步我们要一个一个的试,
还是用ls指令
先试下在不在(hd0,msdos10)里边
grubrescue>ls (hd0,msdos10)
回车会发现,不是,还是unknown file system(NTFS无法识别带来到结果)
接着来
。。。。。。。。。
当我试到

(hd0,msdos8)的时候,可以看到

badfilename
难道我的分区内容挂了?其实没有,只是grub2未能识别其中到内容而已。


③修改启动分区
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

好啦,重启,一切搞定!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值