[求助]将GRUB安装到移动硬盘的方法

启动讨论 grub/grub2/syslinux/grub4dos/Lilo
starwing
帖子: 100
注册时间: 2008-09-19 1:03

[求助]将GRUB安装到移动硬盘的方法

#1

帖子 starwing » 2009-09-13 15:15

我准备把目前电脑的系统装到移动硬盘里面去。用ubuntu-cloner复制的。现在就是引导问题了。

我的硬盘有两个,分别是/dev/sda, /dev/sdb, 移动硬盘是/dev/sdc,sdc的分区如下:
starwing@starwing-desktop:~$ fdisk -l /dev/sdc

Disk /dev/sdc: 160.0 GB, 160041885696 bytes
64 heads, 32 sectors/track, 152627 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Disk identifier: 0xbf317fa9

Device Boot Start End Blocks Id System
/dev/sdc1 * 1 15381 15750128 83 Linux
/dev/sdc2 15382 152627 140539904 f W95 Ext'd (LBA)
/dev/sdc5 15382 28670 13607920 83 Linux
/dev/sdc6 28671 30719 2096451 82 Linux swap / Solaris
/dev/sdc7 30719 81918 52428096 7 HPFS/NTFS
/dev/sdc8 81918 152626 72404923+ 7 HPFS/NTFS
menu.lst的启动用的是:
title Ubuntu 9.04, kernel 2.6.28-15-generic
uuid b6d241ad-f183-4200-8795-c23cb2e280e5
kernel /boot/vmlinuz-2.6.28-15-generic root=UUID=b6d241ad-f183-4200-8795-c23cb2e280e5 ro quiet splash
initrd /boot/initrd.img-2.6.28-15-generic
quiet
uuid是对的,/boot下各文件都存在。

device.map里面是这样的(我有点担心这个有问题):
(fd0) /dev/fd0
(hd0) /dev/sda
(hd1) /dev/sdb
(hd2) /dev/sdc


安装的时候,把grub安装到mbr了,启动能进grub,但是没有菜单,就像是直接在命令行允许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按tab,显示:
Error 21 : Selected disk does not exist

输入root 按tab,显示:
hd1 hd2

这就很奇怪了,因为在宿主系统上面(/dev/sdb),输入root按tab显示的是
hd0 hd1 hd2

先不管这些,输入
uuid ...
kernel .... root=UUID=.... ro quiet splash
initrd ...
这些(menu.lst里面的)说找不到文件(错误1还是错误2,忘了),确定uuid是对的,把uuid改成root (hd1,0)能进initrd,但是会进raminitrd提示符,反正就是无法进系统。

现在的疑问是两个:1. 为什么进去什么提示都没有,而且还找不到menu.lst的样子? 2. 如何能启动系统?
starwing
帖子: 100
注册时间: 2008-09-19 1:03

Re: [求助]将GRUB安装到移动硬盘的方法

#2

帖子 starwing » 2009-09-13 15:33

更新:在那个grub的下面,输入find<tab>,返回的是:
Error 1: "Filename must be either an absolute filename or blocklist"

输入find /<tab>,返回的是:
Error 21 : Selected disk does not exist

输入root (<tab>,这次是对了,返回的是:
hd0 hd1 hd2
根据分区信息,hd1是/dev/sda,hd2是/dev/sdb,那么显然hd0就是/dev/sdc了。但是,hd0的分区无法显示,输入
root (hd0,<tab>,显示的是:
Error 21 : Selected disk does not exist

这是怎么回事?难道grub不认移动硬盘?可是如果不认的话,又是怎么进grub的呢?疑惑中。
头像
wangdu2002
帖子: 13284
注册时间: 2008-12-13 19:39
来自: 物华天宝人杰地灵

Re: [求助]将GRUB安装到移动硬盘的方法

#3

帖子 wangdu2002 » 2009-09-13 15:38

根据分区信息,hd1是/dev/sda,hd2是/dev/sdb,那么显然hd0就是/dev/sdc了
确认如此?
(fd0) /dev/fd0
(hd0) /dev/sda
(hd1) /dev/sdb
(hd2) /dev/sdc
hd0 hd1 hd2
那底你的硬盘是啥样啊?
行到水穷处,坐看云起时。
海内生明月,天涯共此夕。
--------------------吾本独!
头像
leeaman
帖子: 30702
注册时间: 2007-02-02 18:14
系统: debian sid

Re: [求助]将GRUB安装到移动硬盘的方法

#4

帖子 leeaman » 2009-09-13 15:40

装grub到移动硬盘,sda sdb什么也不动,移动硬盘建立menu.lst包括sda sdb装的系统的引导
醉了星星,醉月亮●●●●●The Long Way To Go(*^_^*)
头像
wangdu2002
帖子: 13284
注册时间: 2008-12-13 19:39
来自: 物华天宝人杰地灵

Re: [求助]将GRUB安装到移动硬盘的方法

#5

帖子 wangdu2002 » 2009-09-13 15:40

只接移动硬盘,就可以把grub装在移动硬盘上了。还是你的menu.lst没写对。直接用uuid来识别分区吧。 :em06

响应一叶号召,回贴不忘拉票。 :em02
viewtopic.php?f=1&t=226128#各位兄弟姐妹,赶快去给Ubuntu中文投票。投票日期截止到9月20,每天都可以投 :em11
行到水穷处,坐看云起时。
海内生明月,天涯共此夕。
--------------------吾本独!
starwing
帖子: 100
注册时间: 2008-09-19 1:03

Re: [求助]将GRUB安装到移动硬盘的方法

#6

帖子 starwing » 2009-09-13 17:32

谢谢大家关注!!

回wangdu2002:
1. 我不确定,因为我根本进不了系统,只能看见grub提示符。但是根据分区数目,hd1和hd2肯定是/dev/sda和/dev/sdb无疑。

2. 那个fd0.。。。的是移动硬盘上面的device.map,我没动。同样的文件在宿主计算机里面的内容如下:
(hd0) /dev/sda
(hd1) /dev/sdb

但是重启用移动硬盘引导,进入grub提示符输入root(<tab>,出现的的确是
hd0 hd1 hd2

我也不知道为什么。


关键问题就是用uuid那个grub不认哇,我手动在提示符下面输入uuid,居然显示文件不存在(哪个错误我忘了)。


我重启再试试看。现在打算这么试验:1. 用笔写下/dev/sdb1(硬盘Ubuntu)和/dev/sdc1(移动硬盘Ubuntu)的uuid。2. 挨个试验。看看结果如何,如果硬盘能启动而移动硬盘不行那就不明白是怎么回事了,如果都不能启动,难道是uuid的运算方式不一样?怎么在grub下面查看uuid?

对了,选票已投 :em11
头像
wangdu2002
帖子: 13284
注册时间: 2008-12-13 19:39
来自: 物华天宝人杰地灵

Re: [求助]将GRUB安装到移动硬盘的方法

#7

帖子 wangdu2002 » 2009-09-13 17:39

移动硬盘上有没有menu.lst?可以先从内置硬盘引导进系统后,在连按移动硬盘查看uuid,并把内置系统的menu.lst修改后,复制到在移动硬盘上。
个人觉得用grub4dos可能更方便些。
viewtopic.php?f=139&t=150541#grub4dos简介和使用方法
http://download.gna.org/grub4dos/#下载gru ... 版本0.4.4正式版

viewtopic.php?f=139&t=225669&p=1448778# ... 的哥伦布2代基础教程
行到水穷处,坐看云起时。
海内生明月,天涯共此夕。
--------------------吾本独!
starwing
帖子: 100
注册时间: 2008-09-19 1:03

Re: [求助]将GRUB安装到移动硬盘的方法

#8

帖子 starwing » 2009-09-13 17:54

我想试试grub嘛,因为毕竟是系统克隆……

menu.lst肯定有。顶楼已经给出了分区情况,我再详细说说。/dev/sdc1的标签是Root,分配给/,/dev/sdc5是Home,分配给/home,剩下的两个是NTFS的数据盘。menu.lst在/dev/sdc1的/boot/grub/menu.lst。里面的东西是齐全的:
starwing@starwing-desktop:~$ cd /media/Root/boot/
starwing@starwing-desktop:/media/Root/boot$ ll *
-rw-r--r-- 1 root root 516K 2009-07-25 10:12 abi-2.6.28-14-generic
-rw-r--r-- 1 root root 516K 2009-09-09 20:56 abi-2.6.28-15-generic
-rw-r--r-- 1 root root 302K 2009-05-20 12:43 coffee.bmp
-rw-r--r-- 1 root root 95K 2009-07-25 10:12 config-2.6.28-14-generic
-rw-r--r-- 1 root root 95K 2009-09-09 20:56 config-2.6.28-15-generic
lrwxrwxrwx 1 root root 15 2009-06-27 04:24 debian.bmp -> /boot/sarge.bmp
-rw-r--r-- 1 root root 151K 2009-05-20 12:43 debianlilo.bmp
-rw-r--r-- 1 root root 7.4M 2009-08-07 14:05 initrd.img-2.6.28-14-generic
-rw-r--r-- 1 root root 7.4M 2009-09-12 17:15 initrd.img-2.6.28-15-generic
-rw-r--r-- 1 root root 126K 2009-03-28 01:15 memtest86+.bin
-rwxrwxrwx 1 root root 24K 2009-06-27 04:24 sarge.bmp
-rw-r--r-- 1 root root 24K 2009-05-20 12:43 sid.bmp
-rw-r--r-- 1 root root 1.4M 2009-07-25 10:12 System.map-2.6.28-14-generic
-rw-r--r-- 1 root root 1.4M 2009-09-09 20:56 System.map-2.6.28-15-generic
-rw-r--r-- 1 root root 1.1K 2009-07-25 10:13 vmcoreinfo-2.6.28-14-generic
-rw-r--r-- 1 root root 1.1K 2009-09-09 20:58 vmcoreinfo-2.6.28-15-generic
-rw-r--r-- 1 root root 3.4M 2009-07-25 10:12 vmlinuz-2.6.28-14-generic
-rw-r--r-- 1 root root 3.4M 2009-09-09 20:56 vmlinuz-2.6.28-15-generic

grub:
总用量 212K
-rw-r--r-- 1 root root 197 2009-09-13 14:19 default
-rw-r--r-- 1 root root 60 2009-09-12 17:15 device.map
-rw-r--r-- 1 root root 8.1K 2009-09-13 14:19 e2fs_stage1_5
-rw-r--r-- 1 root root 7.7K 2009-09-13 14:19 fat_stage1_5
-rw-r--r-- 1 root root 16 2009-09-13 14:19 installed-version
-rw-r--r-- 1 root root 8.6K 2009-09-13 14:19 jfs_stage1_5
-rw-r--r-- 1 root root 5.1K 2009-09-13 15:32 menu.lst
-rw-r--r-- 1 root root 7.2K 2009-09-13 14:19 minix_stage1_5
-rw-r--r-- 1 root root 9.6K 2009-09-13 14:19 reiserfs_stage1_5
-rw-r--r-- 1 root root 512 2009-09-13 14:19 stage1
-rw-r--r-- 1 root root 119K 2009-09-13 14:19 stage2
-rw-r--r-- 1 root root 9.4K 2009-09-13 14:19 xfs_stage1_5

grub.old:
总用量 296K
-rw-r--r-- 1 root root 197 2009-05-20 10:57 default
-rw-r--r-- 1 root root 30 2009-05-20 10:57 device.map
-rw-r--r-- 1 root root 8.1K 2009-05-20 10:57 e2fs_stage1_5
-rw-r--r-- 1 root root 7.7K 2009-05-20 10:57 fat_stage1_5
-rw-r--r-- 1 root root 16 2009-05-20 10:57 installed-version
-rw-r--r-- 1 root root 8.6K 2009-05-20 10:57 jfs_stage1_5
-rw-r--r-- 1 root root 5.5K 2009-09-11 23:34 menu.lst
-rw-r--r-- 1 root root 7.2K 2009-05-20 10:57 minix_stage1_5
-rw-r--r-- 1 root root 9.6K 2009-05-20 10:57 reiserfs_stage1_5
-rw-r--r-- 1 root root 70K 2009-07-25 23:00 splash.xpm.gz
-rw-r--r-- 1 root root 512 2009-05-20 10:57 stage1
-rw-r--r-- 1 root root 119K 2009-05-20 10:57 stage2
-rw-r--r-- 1 root root 9.4K 2009-05-20 10:57 xfs_stage1_5
这些我都没动,是ubuntu-cloner弄的。相应的文件肯定是全的。

在ubuntu-cloner里面,我选择的是在/dev/sdc上面装grub,也就是在mbr上面装,它的命令行如下:
grub-install --root-directory=/media/Root /dev/sdc

后来不行,我又在/dev/sdc1的引导扇区又写了一个grub
grub-install --root-directory=/media/Root /dev/sdc1

这里要说一下,如果不加root-directory,那么grub-install会提升出错:
starwing@starwing-desktop:/media/Root/boot$ sudo grub-install /dev/sdc
[sudo] password for starwing:
/dev/sdc does not have any corresponding BIOS drive.
starwing@starwing-desktop:/media/Root/boot$ sudo grub-install /dev/sdc1
/dev/sdc1 does not have any corresponding BIOS drive.
不知道有没有关系。

然后我又进grub命令行写了一次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> root (hd
Possible disks are: hd0 hd1 hd2

grub> root (hd2,0)

grub> setup (hd2)
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 (hd2)"... 17 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd2) (hd2)1+17 p (hd2,0)/boot/grub/stage2
/boot/grub/menu.lst"... succeeded
Done.

grub>
里面有个出错,不知道有没有关系。

移动硬盘里面的menu.lst贴出来,是这样的:
# menu.lst - See: grub(8), info grub, update-grub(8)
# grub-install(8), grub-floppy(8),
# grub-md5-crypt, /usr/share/doc/grub
# and /usr/share/doc/grub-doc/.

## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
#
# You can specify 'saved' instead of a number. In this case, the default entry
# is the entry saved with the command 'savedefault'.
# WARNING: If you are using dmraid do not use 'savedefault' or your
# array will desync and will not let you boot your system.
default 0

## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
timeout 3

## hiddenmenu
# Hides the menu by default (press ESC to see the menu)
hiddenmenu

# Pretty colours
#color cyan/blue white/blue

## password ['--md5'] passwd
# If used in the first section of a menu file, disable all interactive editing
# control (menu entry editor and command-line) and entries protected by the
# command 'lock'
# e.g. password topsecret
# password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
# password topsecret

#
# examples
#
# title Windows 95/98/NT/2000
# root (hd0,0)
# makeactive
# chainloader +1
#
# title Linux
# root (hd0,1)
# kernel /vmlinuz root=/dev/hda2 ro
#

#
# Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST

### BEGIN AUTOMAGIC KERNELS LIST
## lines between the AUTOMAGIC KERNELS LIST markers will be modified
## by the debian update-grub script except for the default options below

## DO NOT UNCOMMENT THEM, Just edit them to your needs

## ## Start Default Options ##
## default kernel options
## default kernel options for automagic boot options
## If you want special options for specific kernels use kopt_x_y_z
## where x.y.z is kernel version. Minor versions can be omitted.
## e.g. kopt=root=/dev/hda1 ro
## kopt_2_6_8=root=/dev/hdc1 ro
## kopt_2_6_8_2_686=root=/dev/hdc2 ro
# kopt=root=UUID=b6d241ad-f183-4200-8795-c23cb2e280e5 ro

## default grub root device
## e.g. groot=(hd0,0)
# groot=b6d241ad-f183-4200-8795-c23cb2e280e5

## should update-grub create alternative automagic boot options
## e.g. alternative=true
## alternative=false
# alternative=true

## should update-grub lock alternative automagic boot options
## e.g. lockalternative=true
## lockalternative=false
# lockalternative=false

## additional options to use with the default boot option, but not with the
## alternatives
## e.g. defoptions=vga=791 resume=/dev/hda5
# defoptions=quiet splash

## should update-grub lock old automagic boot options
## e.g. lockold=false
## lockold=true
# lockold=false

## Xen hypervisor options to use with the default Xen boot option
# xenhopt=

## Xen Linux kernel options to use with the default Xen boot option
# xenkopt=console=tty0

## altoption boot targets option
## multiple altoptions lines are allowed
## e.g. altoptions=(extra menu suffix) extra boot options
## altoptions=(recovery) single
# altoptions=(recovery mode) single

## controls how many kernels should be put into the menu.lst
## only counts the first occurence of a kernel, not the
## alternative kernel options
## e.g. howmany=all
## howmany=7
# howmany=all

## specify if running in Xen domU or have grub detect automatically
## update-grub will ignore non-xen kernels when running in domU and vice versa
## e.g. indomU=detect
## indomU=true
## indomU=false
# indomU=detect

## should update-grub create memtest86 boot option
## e.g. memtest86=true
## memtest86=false
# memtest86=true

## should update-grub adjust the value of the default booted system
## can be true or false
# updatedefaultentry=false

## should update-grub add savedefault to the default options
## can be true or false
# savedefault=false

## ## End Default Options ##

title Ubuntu 9.04, kernel 2.6.28-15-generic
root (hd0,0) #注意这个地方,这个是因为使用uuid不行,我换掉的。实践证明这样还是不行(现在使用下面这行照样没用)
#uuid b6d241ad-f183-4200-8795-c23cb2e280e5
kernel /boot/vmlinuz-2.6.28-15-generic root=UUID=b6d241ad-f183-4200-8795-c23cb2e280e5 ro quiet splash
initrd /boot/initrd.img-2.6.28-15-generic
quiet

title Ubuntu 9.04, kernel 2.6.28-15-generic (recovery mode)
uuid b6d241ad-f183-4200-8795-c23cb2e280e5
kernel /boot/vmlinuz-2.6.28-15-generic root=UUID=b6d241ad-f183-4200-8795-c23cb2e280e5 ro single
initrd /boot/initrd.img-2.6.28-15-generic

title Ubuntu 9.04, kernel 2.6.28-14-generic
uuid b6d241ad-f183-4200-8795-c23cb2e280e5
kernel /boot/vmlinuz-2.6.28-14-generic root=UUID=b6d241ad-f183-4200-8795-c23cb2e280e5 ro quiet splash
initrd /boot/initrd.img-2.6.28-14-generic
quiet

title Ubuntu 9.04, kernel 2.6.28-14-generic (recovery mode)
uuid b6d241ad-f183-4200-8795-c23cb2e280e5
kernel /boot/vmlinuz-2.6.28-14-generic root=UUID=b6d241ad-f183-4200-8795-c23cb2e280e5 ro single
initrd /boot/initrd.img-2.6.28-14-generic

title Ubuntu 9.04, memtest86+
uuid b6d241ad-f183-4200-8795-c23cb2e280e5
kernel /boot/memtest86+.bin
quiet

### END DEBIAN AUTOMAGIC KERNELS LIST

# This entry may not be correct when you have multiple hard disks
title windows
rootnoverify (hd0,0)
chainloader +1
上次由 starwing 在 2009-09-13 18:18,总共编辑 1 次。
starwing
帖子: 100
注册时间: 2008-09-19 1:03

Re: [求助]将GRUB安装到移动硬盘的方法

#9

帖子 starwing » 2009-09-13 18:09

试验完毕,输入:
uuid 。。。。
无论是/dev/sdb1还是/dev/sdc1的uuid,全部都是
Error15: File No Found

这次,输入root按tab,只显示了两个hd:
hd1 hd2
没了hd0,从分区情况来看,刚好是/dev/sda /dev/sdb。

这是怎么回事?移动硬盘上面的grub反而找不到自己了??
头像
smallapple
论坛版主
帖子: 7868
注册时间: 2009-03-28 15:12

Re: [求助]将GRUB安装到移动硬盘的方法

#10

帖子 smallapple » 2009-09-13 18:19

应该是 grub 不能识别你的移动硬盘。
先把移动盘拿到别人电脑上试试。
starwing
帖子: 100
注册时间: 2008-09-19 1:03

Re: [求助]将GRUB安装到移动硬盘的方法

#11

帖子 starwing » 2009-09-13 19:58

Orz……这是不是Grub的版本问题?能不能推荐一个可能没问题的引导器?我准备试验grub4dos、grub2和lilo了= =可是后两个我不熟= =|||
头像
smallapple
论坛版主
帖子: 7868
注册时间: 2009-03-28 15:12

Re: [求助]将GRUB安装到移动硬盘的方法

#12

帖子 smallapple » 2009-09-13 20:00

不一定是grub的问题,可能是主板或 移动盘的问题。
试过了才知道,
先试试grub4dos,
要用grub2先看看我的签名。 :em05
lilo我也不熟
starwing
帖子: 100
注册时间: 2008-09-19 1:03

Re: [求助]将GRUB安装到移动硬盘的方法

#13

帖子 starwing » 2009-09-13 20:18

决定使用grub4dos了。三个问题:
1. 如何直接在Ubuntu下面使用grub4dos?我没有Windows环境,也不知道能不能直接wine。
2. grub4dos能不能用来引导Ubuntu?如果能,menu.lst怎么改?
3. 以后Ubuntu升级内核的时候修改menu.lst,会不会造成问题?
头像
smallapple
论坛版主
帖子: 7868
注册时间: 2009-03-28 15:12

Re: [求助]将GRUB安装到移动硬盘的方法

#14

帖子 smallapple » 2009-09-13 20:30

先把grub4dos中的grub.exe解压出来放在三硬盘某一分区内,
从硬盘启动,以下代码转到grub4dos
root (hd0,?) <----- 硬盘分区号
kernel /grub.exe
boot

再在grub4dos下
root (hd, Tab键,看看能不能识别移动盘,确定能识别启动再安装grub4dos到mbr。
starwing
帖子: 100
注册时间: 2008-09-19 1:03

Re: [求助]将GRUB安装到移动硬盘的方法

#15

帖子 starwing » 2009-09-13 21:02

哈!!!完全成功啦!! :em11


现在就是在移动硬盘的Ubuntu中发帖,嘿嘿。不过目前menu.lst写的简单,只是试验一下~

没想到bootlace.com居然可以直接在linux下面使用。用它把grldr.mbr写入mbr就可以了!

现在的问题是,因为更新内核的时候,会自动更新/boot/grub/menu.lst的内容。我想把主要的东西放那个里面。那么怎么在前一个menu.lst中include后一个的内容呢?
回复