现在的位置: 首页 > 综合 > 正文

【转】如何修复Linux引导

2014年05月13日 ⁄ 综合 ⁄ 共 2950字 ⁄ 字号 评论关闭

有人可能装过Linux双系统,但是在XP老是要重装的年代,郁闷的是Linux不能被引导的问题经常出现了。原因嘛,XP在安装的时候是不会给我们提供系统引导程序安装的,Linux带有系统引导程序,如GRUB等等。它一般装在第一个硬盘(hd0)、第一个分区(hd,0)的第一个区上,所以要是我们把XP装在第一个分区上,那重装XP,GRUB就被破坏了,再也不能引导系统了。

要是遇上这样的情况就得重装GRUB了。别着急,Linux不会那么容易就要重装的。那么下面介绍GRUB的安装方法:

第一种方法:

用Live CD(Desktop, 图形界面),进入到安装界面,不用安装系统,直接打开一个终端(Ctrl+Alt+F1或F2、F3……输入命令:

#su

#grub:

grub>root (hdX,Y) X是Linux在第几个硬盘上,Y是/boot在第几个分区,都是从零开始数。

grub>setup(hdX) 一般为0。

grub>quit

#reboot

这样就完成了。

第二种方法:

用alternative CD(文本模式)

放入光盘重启电脑,进入第一个界面时设置引导参数

boot:rescue

系统文件装载完之后,进入命令行模式

#grub-install/dev/sda

1.用Live CD启动

2.打开一个终端,运行$sudo grub命令(这里可能需要等一会儿),你会看到’grub>’这样的提示符

3.在提示符’grub>’后输入find /grub/stage1,你会得到一个运行结果,比如我的机子上结果是(hd0,5) (这个命令其实就是找出/boot所在分区)

4.运行grub>root (hd0,5)(这个位置要填上你机子上的运行结果)

5.运行grub>setup (hd0)出现几行提示文字,最后是“… succeeded” 修复成功!

6.运行quit

7.重启计算机,取出live CD

手动引导Linux

grub>root (sd0,7)

grub>kernel (sd0,7)/boot/vmlinuz-2.6.16 ro root=/dev/sda8 –typelinux=ext3

grub>initrd (sd0,8)/boot/initrd.img-2.6.16

grub>boot

蓝藻注:要修改/boot/grub/grub.conf的内容,修改为root(sd0,7),不然每次开机都要修改

//以上是我的机器里参数,各位可以根据自己的情况改一下。

第三方法:

1.安装一键GHOST硬盘版8.3.

2.用explore2fs在windows下将Linux boot分区中的grub.conf文件导出。我导出的文件内容如下

QUOTE:

# grub.conf generated by anaconda

#

# Note that you do not have to rerun grub after making changes to this file

# NOTICE: You have a /boot partition. This means that

# all kernel and initrd paths are relative to /boot/, eg.

# root (hd0,8)

# kernel /vmlinuz-version ro root=/dev/sda3

# initrd /initrd-version.img

#boot=/dev/sda

default=1

timeout=1

gfxmenu (hd0,8)/message

title Everest (2.6.23.1-5)

root (hd0,8)

kernel /vmlinuz-2.6.23.1-5 ro root=LABEL=/ vga=788 splash=silent resume=/dev/sda4

initrd /initrd-2.6.23.1-5.img

title Windows XP SP2 Professional

rootnoverify (hd0,0)

chainloader +1

3.修改安装一键GHOST硬盘版后C盘中的一个文件C:bootghosmenu.lst

修改前内容如下

QUOTE:

# 禁止修改或删除本文件,否则”一键GHOST”将无法使用

# Don’t edit or delete this file, otherwise “1KEY GHOST” is not used.

# *** 制作

# MADE BY ***

timeout 0

default 0

#foreground E0E0E0

#background 505050

#gfxmenu /boot/ghos/grub_chs.msg

#fontfile /boot/ghos/fonts

#splashimage /boot/ghos/black.xpm

password –md5 $CiueUGxatxEg3ubyHriXN0

title 1KEY GHOST v8.3

# MODE1

clear

#password

map –mem /boot/ghos/ghost83.img (fd0)

map –hook

chainloader (fd0)+1

rootnoverify (fd0)

# MODE2

#kernel /boot/ghos/memdisk

#initrd /boot/ghos/ghost83.img

#plus

#plus-end

修改后内容为:

QUOTE:

# 禁止修改或删除本文件,否则”一键GHOST”将无法使用

# Don’t edit or delete this file, otherwise “1KEY GHOST” is not used.

# *** 制作

# MADE BY ***

timeout 5

default 0

#foreground E0E0E0

#background 505050

#gfxmenu /boot/ghos/grub_chs.msg

#fontfile /boot/ghos/fonts

#splashimage /boot/ghos/black.xpm

password –md5 $CiueUGxatxEg3ubyHriXN0

title Everest (2.6.23.1-5)

root (hd0,8)

kernel /vmlinuz-2.6.23.1-5 ro root=LABEL=/ vga=788 splash=silent resume=/dev/sda4

initrd /initrd-2.6.23.1-5.img

title 1KEY GHOST v8.3

# MODE1

clear

#password

map –mem /boot/ghos/ghost83.img (fd0)

map –hook

chainloader (fd0)+1

rootnoverify (fd0)

# MODE2

#kernel /boot/ghos/memdisk

#initrd /boot/ghos/ghost83.img

#plus

#plus-end

4.保存重启,选择

C:GHLDR=一键GHOST v8.3 Build 060716

抱歉!评论已关闭.