[问题]ubuntu boot丢失

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
miaoyi
帖子: 1
注册时间: 2008-05-15 9:42

[问题]ubuntu boot丢失

#1

帖子 miaoyi » 2008-05-15 9:48

:?:我本来是 Windows XP与Ubuntu Linux系统双启动,但后来UBUNTU 的boot丢失了,系统无法引导进入UBUNTU了,这是XP下的启动信息[boot loader]
timeout=3
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect /usepmtimer /bootlogo
C:\GHLDR=一键GHOST v11.0 Build 070707
求高手解决 :?:
头像
yaoms
帖子: 4952
注册时间: 2007-10-19 14:51
来自: 深圳

#2

帖子 yaoms » 2008-05-15 9:55

不知道你的ubuntu情况,boot丢失是什么意思?
Nothing 有事请发邮件到 yms541 AT gmail.com
alias 爱慕颇雷尔='mplayer'
goodayoo
帖子: 87
注册时间: 2007-10-23 11:19

#3

帖子 goodayoo » 2008-05-15 10:05

删除Linux与恢复grub,这是我等新手常遇到的两个问题,感觉Linux不好,想退出,就要删除Linux,覆盖Grub;而装了Windows与Linux双系统的用户,又会在重装Windows时把Grub覆盖掉,需要恢复Grub。这是后路,我们在做事之前需要先考虑好的。



删除Linux,覆盖Grub,还原成XP自带的启动引导,这个很简单,只要你有Windows XP盘(非Ghost),用它启动,至选择安装位置的地方退出重启就可以。或者用它启动故障修复台,运行fixboot或者fixmbr都可以。



而恢复Grub,其实也很简单的:用Live CD(对于Ubuntu来说就是Desktop CD或者DVD)启动,打开终端(Applications──>Accessory──>Terminal),执行以下代码:

代码:

sudo grub

find /boot/grub/stage1

root (hdX,Y)

setup (hdX)

quit





注意:其中的X、Y是执行find /boot/grub/stage1命令后系统提示的。,比如:

代码:

grub> find /boot/grub/menu.lst

(hd0,7)



注意:这里的grub>是执行sudo grub命令后进入grub环境得到的提示符,不用输入。这时,X就是0,Y就是7。



下面详细解释一下这几条命令:





sudo grub 以root用户身份启动grub,否则会出错,错误见后文

find /boot/grub/stage1 寻找/boot所在分区,其实换用find /boot/grub/menu.lst也一样。

root (hdX,Y) 设置硬盘hdX的根文件系统(root Device),实际就是设置/boot所在的分区

setup (hdX) 自动安装GRUB到硬盘hdX。

quit 退出GRUB

root、setup命令后都有空格,如果没有会出错误。

如果不以root用户身份会出现什么样的错误呢?

引用:

ubuntu@ubuntu:~$grub



[ Minimal BASH-like line editing is supported. For

the first word, TAB lists possible command

completions. Anywhere else TAB lists the possible

completions of a device/filename. ]



grub> find /boot/grub/stage1



Error 15: File not found



grub> find /boot/grub/menu.lst



Error 15: File not found



grub> root(hd0,7)



Error 27: Unrecognized command



grub> root (hd0,7)



Error 21: Selected disk does not exist

grub> setup (hd0)



Error 12: Invalid device requested





一个成功例子:

引用:

ubuntu@ubuntu:~$ sudo grub

[ Minimal BASH-like line editing is supported. For

the first word, TAB lists possible command

completions. Anywhere else TAB lists the possible

completions of a device/filename. ]



grub> find /boot/grub/menu.lst

(hd0,7)



grub> root (hd0,7)



grub> setup (hd0)

Checking if "/boot/grub/stage1" exists... yes

Checking if "/boot/grub/stage2" exists... yes

Checking if "/boot/grub/e2fs_stage1_5" exists... yes

Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded.

succeeded

Running "install /boot/grub/stage1 (hd0) (hd0)1+15 p (hd0,7)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded

Done.

grub>quit







这是最简单的方法,也有其它几个寻找/boot分区的方法,但稍麻烦点:

在终端使用ls /dev/sd*和ls /hd*命令来查找系统的外部设置,用sudo mkdir命令来建立挂载目录,用sudo mount命令挂载,再用ls命令查看是否/boot所在的分区。



也可以用sudo fdisk -l来找到启动分区(这里不涉及将/boot单独分区的情况,因为那种我没有实验过,不太清楚),如:

引用:

ubuntu@ubuntu:~$ sudo fdisk -l



Disk /dev/sda: 160.0 GB, 160041885696 bytes

255 heads, 63 sectors/track, 19457 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes



Device Boot Start End Blocks Id System

/dev/sda1 * 1 2295 18434556 7 HPFS/NTFS

/dev/sda2 2296 19456 137845732+ f W95 Ext'd (LBA)

/dev/sda5 2296 4845 20482843+ 7 HPFS/NTFS

/dev/sda6 4846 8669 30716248+ 7 HPFS/NTFS

/dev/sda7 8670 16557 63360328+ 7 HPFS/NTFS

/dev/sda8 * 16558 17361 6458098+ 83 Linux

/dev/sda9 17362 19393 16322008+ 83 Linux

/dev/sda10 19394 19456 506016 82 Linux swap / Solaris





就知道启动分区是/dev/sda8



有人可能会有疑问,在Linux系统中是用sda8来表示这个启动分区,而GRUB中则是用(hd0,7)表示,这是因为在新版的Ubuntu中系统将串口硬盘和并口硬盘都识别为sd,a表示第一硬盘,8表示第4个逻辑分区(1──4被分配给主分区,扩展分区里的逻辑分区从5开始计算)。而Grub中则是用统一用hd代表硬盘,硬盘号与分区号都是从0开始计算的。

这部分是凭记忆写的,可能不准确,请参考wiki。



PS:

看到有的帖子说Alterate CD可以在boot后输入linux rescue来启动救援盘,后面的操作则一样。我因手头没有Alterate CD无法验证。DVD虽说集成了Alterate CD与Desktop CD,但无法在以字符界面安装时启动救援盘。



感谢雕雕补充:

雕啸长空 写道:



补充一点,上面讲的是在/boot下面的东西都还完好的,但如果RP不行,/boot都玩完了,可以试一下下面的:

生成/etc/mtab

代码:

sudo grep -v rootfs /proc/mounts >sudo tee /etc/mtab



安装grub到mbr

代码:

grub-install --no-floppy /dev/hda



然后就自己搞定menu.lst了.



ps:将雕的命令按http://forum.ubuntu.org.cn/viewtopic.php?t=67897修改了一下。

顺便鄙视一下Linux/Windows双料菜鸟。

再鄙视一下自己,其实这都是网上流传的已有的,只是这次恰好在实验Vista时用上了实证了一下。
头像
windwiny
帖子: 2254
注册时间: 2007-03-13 17:26

#4

帖子 windwiny » 2008-05-15 11:12

那个一键恢复的 GHLDR 应该就能用

选那个进,c 进命令行,输入

代码: 全选

root  (hd  按TAB,自动补全,后面跟一个根分区号
kernel /boot/vmli<TAB>  root=/dev/sda<TAB>  ro
initrd /boot/initrd<TAB>
boot
只要明白这几行的意思 ,用 TAB 补全就可以进系统了 ,按TAB会列出可选项
回复