分页: 1 / 1
(求助)grub里硬盘分区命名的困惑
发表于 : 2007-08-26 17:02
由 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
感觉自己都晕了
Re: (求助)grub里硬盘分区命名的困惑
发表于 : 2007-08-26 17:10
由 janker2lonely
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
(sd0,7)是指你的第一个硬盘的第8个分区,也就是你的第4个逻辑分区,(sd0,8)是你的第一个硬盘的第9个分区,也就是你的第5个逻辑分区。
发表于 : 2007-08-26 17:56
由 依寻依然
这是两种不同的硬盘分区计数方式
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个,但是分区号仍然保留
Re: (求助)grub里硬盘分区命名的困惑
发表于 : 2007-08-26 18:24
由 yhlfh
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
感觉自己都晕了
你这个搞错了吧?怎么vmlinuz和initrd不在同一分区下?还有,grub认识
sd吗?
貌似对于grub来说,硬盘都是用hd表示的,磁盘序号和分区号都是从0开始计算的。而对于Linux(内核)来说,IDE硬盘是用hd表示的,SATA硬盘是用sd表示的,磁盘序号是从a开始计算的,分区号是从1开始计算的。
发表于 : 2007-08-26 18:53
由 冲浪板
分别放又有什么不对?
btw:lilo被彻底扔掉了么(就是没发展)?
Re: (求助)grub里硬盘分区命名的困惑
发表于 : 2007-08-26 21:09
由 sivaj
yhlfh 写了: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
感觉自己都晕了
你这个搞错了吧?怎么vmlinuz和initrd不在同一分区下?还有,grub认识
sd吗?
貌似对于grub来说,硬盘都是用hd表示的,磁盘序号和分区号都是从0开始计算的。而对于Linux(内核)来说,IDE硬盘是用hd表示的,SATA硬盘是用sd表示的,磁盘序号是从a开始计算的,分区号是从1开始计算的。
这个是一个论坛里的grub指南,我也认为vmlinuz和initrd应该在同一分区下
我的问题是kernel项后的root这里不应该是(sd0,7)吗?怎么有成(sd0,8)了呢?
root项和kernel项里的两个分区不应该是一样的吗?
Re: (求助)grub里硬盘分区命名的困惑
发表于 : 2007-08-26 21:15
由 janker2lonely
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
估计蓝色部分的写法有误,应该是笔者粗心大意,这里应该是sd(0,8)。根分区应该位于sda8也就是sd(0,7),而/boot在sda9也就是sd(0,8)。
发表于 : 2007-08-27 2:43
由 xhy
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.
发表于 : 2007-08-27 3:19
由 xhy
grub0.97的源码
可见 并没有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 }
发表于 : 2007-08-27 15:13
由 sivaj
呃...这个...呃... 虽然现在还看不懂,但是学习代码是我远大的目标之一
谢谢
发表于 : 2007-08-27 20:04
由 冲浪板
可是现在确实是sda....哇
845D板子。
发表于 : 2007-08-27 20:23
由 yhlfh
kernel才认识sd
发表于 : 2007-08-28 10:52
由 nofoghu
不管是SD还是什么,全写成HD
发表于 : 2007-09-01 19:59
由 sivaj
我的不是sata硬盘,但是都是sda,奇怪