(求助)grub里硬盘分区命名的困惑
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
-
- 帖子: 541
- 注册时间: 2007-05-19 16:36
(求助)grub里硬盘分区命名的困惑
grub里的硬盘和分区都是从零开始,但是kernel选项后面的root项和initrd项却有不是从零开始,为什么呢?
比如:
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
感觉自己都晕了
比如:
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
感觉自己都晕了
-
- 帖子: 557
- 注册时间: 2007-01-09 11:09
- 来自: 廣州
Re: (求助)grub里硬盘分区命名的困惑
(sd0,7)是指你的第一个硬盘的第8个分区,也就是你的第4个逻辑分区,(sd0,8)是你的第一个硬盘的第9个分区,也就是你的第5个逻辑分区。sivaj 写了:grub里的硬盘和分区都是从零开始,但是kernel选项后面的root项和initrd项却有不是从零开始,为什么呢?
比如:
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
上次由 janker2lonely 在 2007-08-26 21:46,总共编辑 2 次。
- 依寻依然
- 帖子: 1617
- 注册时间: 2006-10-31 14:49
这是两种不同的硬盘分区计数方式
grub:grub中不管是SATA还是IDE的都用hd表示(不好意思写顺手了,忘记了。谢谢4楼提醒)
1.硬盘的块数即您有多少块硬盘,那么硬盘编号就从hd0,hd1,hd2,……一直继续下去
2.一块硬盘仅能分四个主分区。那么这四个主分区就占用四个分区名,
比如第一块硬盘:(hd0,0),(hd0,1),(hd0,2),(hd0,3)
剩余的分区就是逻辑分区,按照顺序编号
dev:
1.sd指的是SATA硬盘,hd指的是IDE硬盘,如hd0,sd1。以为sd为例,hd相当
2.硬盘的块数用sda,sdb,sdc……继续下去,超过26个硬盘就是sdaa,sdab,sdac,……继续下去
3.一块硬盘仅能分四个主分区。那么这四个主分区就占用四个分区名,
比如第一块硬盘:sda1,sda2,sda3,sda4
剩余的分区就是逻辑分区,按照顺序编号
另外,主分区即使没有分到4个,但是分区号仍然保留
grub:grub中不管是SATA还是IDE的都用hd表示(不好意思写顺手了,忘记了。谢谢4楼提醒)
1.硬盘的块数即您有多少块硬盘,那么硬盘编号就从hd0,hd1,hd2,……一直继续下去
2.一块硬盘仅能分四个主分区。那么这四个主分区就占用四个分区名,
比如第一块硬盘:(hd0,0),(hd0,1),(hd0,2),(hd0,3)
剩余的分区就是逻辑分区,按照顺序编号
dev:
1.sd指的是SATA硬盘,hd指的是IDE硬盘,如hd0,sd1。以为sd为例,hd相当
2.硬盘的块数用sda,sdb,sdc……继续下去,超过26个硬盘就是sdaa,sdab,sdac,……继续下去
3.一块硬盘仅能分四个主分区。那么这四个主分区就占用四个分区名,
比如第一块硬盘:sda1,sda2,sda3,sda4
剩余的分区就是逻辑分区,按照顺序编号
另外,主分区即使没有分到4个,但是分区号仍然保留
上次由 依寻依然 在 2007-08-26 18:56,总共编辑 1 次。
Borders are meant to be crossed
- yhlfh
- 帖子: 579
- 注册时间: 2006-09-02 20:42
- 来自: 东海明珠
Re: (求助)grub里硬盘分区命名的困惑
你这个搞错了吧?怎么vmlinuz和initrd不在同一分区下?还有,grub认识sd吗?sivaj 写了:grub里的硬盘和分区都是从零开始,但是kernel选项后面的root项和initrd项却有不是从零开始,为什么呢?
比如:
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
感觉自己都晕了
貌似对于grub来说,硬盘都是用hd表示的,磁盘序号和分区号都是从0开始计算的。而对于Linux(内核)来说,IDE硬盘是用hd表示的,SATA硬盘是用sd表示的,磁盘序号是从a开始计算的,分区号是从1开始计算的。
Life is like a box of chocolates, you never know what you're going to get.
-
- 帖子: 541
- 注册时间: 2007-05-19 16:36
Re: (求助)grub里硬盘分区命名的困惑
这个是一个论坛里的grub指南,我也认为vmlinuz和initrd应该在同一分区下yhlfh 写了:你这个搞错了吧?怎么vmlinuz和initrd不在同一分区下?还有,grub认识sd吗?sivaj 写了:grub里的硬盘和分区都是从零开始,但是kernel选项后面的root项和initrd项却有不是从零开始,为什么呢?
比如:
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
感觉自己都晕了
貌似对于grub来说,硬盘都是用hd表示的,磁盘序号和分区号都是从0开始计算的。而对于Linux(内核)来说,IDE硬盘是用hd表示的,SATA硬盘是用sd表示的,磁盘序号是从a开始计算的,分区号是从1开始计算的。
我的问题是kernel项后的root这里不应该是(sd0,7)吗?怎么有成(sd0,8)了呢?
root项和kernel项里的两个分区不应该是一样的吗?
-
- 帖子: 557
- 注册时间: 2007-01-09 11:09
- 来自: 廣州
Re: (求助)grub里硬盘分区命名的困惑
估计蓝色部分的写法有误,应该是笔者粗心大意,这里应该是sd(0,8)。根分区应该位于sda8也就是sd(0,7),而/boot在sda9也就是sd(0,8)。sivaj 写了:grub里的硬盘和分区都是从零开始,但是kernel选项后面的root项和initrd项却有不是从零开始,为什么呢?
比如:
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
- xhy
- 帖子: 3916
- 注册时间: 2005-12-28 1:16
- 系统: Ubuntu 12.10 X64
- 来自: 火星
sata和IDE全部都用hd
代码: 全选
2 Naming convention
*******************
The device syntax used in GRUB is a wee bit different from what you may
have seen before in your operating system(s), and you need to know it so
that you can specify a drive/partition.
Look at the following examples and explanations:
(fd0)
First of all, GRUB requires that the device name be enclosed with
`(' and `)'. The `fd' part means that it is a floppy disk. The number
`0' is the drive number, which is counted from _zero_. This expression
means that GRUB will use the whole floppy disk.
(hd0,1)
Here, `hd' means it is a hard disk drive. The first integer `0'
indicates the drive number, that is, the first hard disk, while the
second integer, `1', indicates the partition number (or the PC slice
number in the BSD terminology). Once again, please note that the
partition numbers are counted from _zero_, not from one. This
expression means the second partition of the first hard disk drive. In
this case, GRUB uses one partition of the disk, instead of the whole
disk.
(hd0,4)
This specifies the first "extended partition" of the first hard disk
drive. Note that the partition numbers for extended partitions are
counted from `4', regardless of the actual number of primary partitions
on your hard disk.
(hd1,a)
This means the BSD `a' partition of the second hard disk. If you
need to specify which PC slice number should be used, use something
like this: `(hd1,0,a)'. If the PC slice number is omitted, GRUB
searches for the first PC slice which has a BSD `a' partition.
Of course, to actually access the disks or partitions with GRUB, you
need to use the device specification in a command, like `root (fd0)' or
`unhide (hd0,2)'. To help you find out which number specifies a
partition you want, the GRUB command-line (*note Command-line
interface::) options have argument completion. This means that, for
example, you only need to type
root (
followed by a <TAB>, and GRUB will display the list of drives,
partitions, or file names. So it should be quite easy to determine the
name of your target partition, even with minimal knowledge of the
syntax.
Note that GRUB does _not_ distinguish IDE from SCSI - it simply
counts the drive numbers from zero, regardless of their type. Normally,
any IDE drive number is less than any SCSI drive number, although that
is not true if you change the boot sequence by swapping IDE and SCSI
drives in your BIOS.
Now the question is, how to specify a file? Again, consider an
example:
(hd0,0)/vmlinuz
This specifies the file named `vmlinuz', found on the first
partition of the first hard disk drive. Note that the argument
completion works with file names, too.
That was easy, admit it. Now read the next chapter, to find out how
to actually install GRUB on your drive.
目前负债150多万
- xhy
- 帖子: 3916
- 注册时间: 2005-12-28 1:16
- 系统: Ubuntu 12.10 X64
- 来自: 火星
grub0.97的源码
可见 并没有s开头的表示方法
可见 并没有s开头的表示方法
代码: 全选
980 char ch = *device;
981 #ifdef SUPPORT_NETBOOT
982 if (*device == 'f' || *device == 'h'
983 || (*device == 'n' && network_ready)
984 || (*device == 'c' && cdrom_drive != GRUB_INVALID_DRIVE))
985 #else
986 if (*device == 'f' || *device == 'h'
987 || (*device == 'c' && cdrom_drive != GRUB_INVALID_DRIVE))
988 #endif /* SUPPORT_NETBOOT */
989 {
990 /* user has given '([fhn]', check for resp. add 'd' and
991 let disk_choice handle what disks we have */
992 if (!*(device + 1))
993 {
994 device++;
995 *device++ = 'd';
996 *device = '\0';
997 return device;
998 }
999 else if (*(device + 1) == 'd' && !*(device + 2))
1000 return device + 2;
1001 }
1002
1003 if ((*device == 'f'
1004 || *device == 'h'
1005 #ifdef SUPPORT_NETBOOT
1006 || (*device == 'n' && network_ready)
1007 #endif
1008 || (*device == 'c' && cdrom_drive != GRUB_INVALID_DRIVE))
1009 && (device += 2, (*(device - 1) != 'd')))
1010 errnum = ERR_NUMBER_PARSING;
1011
1012 #ifdef SUPPORT_NETBOOT
1013 if (ch == 'n' && network_ready)
1014 current_drive = NETWORK_DRIVE;
1015 else
1016 #endif /* SUPPORT_NETBOOT */
1017 {
1018 if (ch == 'c' && cdrom_drive != GRUB_INVALID_DRIVE)
1019 current_drive = cdrom_drive;
1020 else
1021 {
1022 safe_parse_maxint (&device, (int *) ¤t_drive);
1023
1024 disk_choice = 0;
1025 if (ch == 'h')
1026 current_drive += 0x80;
1027 }
1028 }
1029 }
目前负债150多万
- yhlfh
- 帖子: 579
- 注册时间: 2006-09-02 20:42
- 来自: 东海明珠