linux - GRUB: how find partition number (hd0,x)?
2013-10
i am playing with grub and i change the root using:
root (hda,x)
how can i know what's x for /dev/sda7
?
fdisk -l
Device Boot Start End Blocks Id System /dev/sda1 * 1 1958 15727603+ 7 HPFS/NTFS /dev/sda2 1959 7476 44323335 f W95 Ext'd (LBA) /dev/sda5 1959 4569 20972826 7 HPFS/NTFS /dev/sda6 4570 5352 6289416 83 Linux /dev/sda7 6373 7119 6000246 83 Linux /dev/sda8 7120 7476 2867571 83 Linux /dev/sda9 5353 6135 6289416 83 Linux /dev/sda10 6136 6372 1903671 82 Linux swap / Solaris
the problem is that in Gparted view, the order is not like sda5, sda6, sda7, ... but the order is like:
- sda6
- sda9
- sda10
- sda7
- sda8
so what's x for /dev/sda7
?
First off, you need to realize that in grub, it does not use normal linux hard drive identifiers. Instead, the letters correlate to numbers, starting with zero (i.e. hda = hd0, hdb = hd1, etc).
Secondly, the partition number starts at 0, not 1 like in Linux, so subtract 1 from the linux partition number.
An example is: hda1 = (hd0, 0)
Finally, grub does not differentiate between hd and sd devices, so everything is labeled hd.
Thus, in your case, your grub entry for /dev/sda6 should read (hd0, 5)
Easiest way to be sure is from grub cli and using tab completion.
start by typing... root (hd0,
then hit [tab]
The tab completion should then list the partitions available.
pick the one you think makes most sense close off the parentheses and on the next line type
kernel /
then hit [tab] again... if the files and directory structure look right you picked the right one... if not.. back up and redo the root line.
The hardware:
- motherboard with one IDE slot(2 drives)
- PCI card with 2 slots(4 drives)
- hard drive with CentOS installed
- hard drive with an old Fedora installed
The normal situation:
I boot into grub(CentOS splashscreen) and that boots CentOS installed on the CentOS drive(hda).
The situation as it is now:
I hook up the Fedora drive(to either the master or slave on the primary channel on the PCI card, hdc or hdd) and boot. The CentOS grub boots, uses the CentOS kernel, and everything else is from Fedora. Modules, software versions, etc, almost like it's recognized the Fedora drive as hda. However, if I were to mount hda as /mnt/hda
, I get the CentOS drive. If I mount hdd or hdc as /mnt/hdc
or /mnt/hdd
, I get the Fedora drive as expect. But the mounted hda outside of any other paths(/usr
for example), I get the Fedora files.
Filesystem Size Used Avail Use% Mounted on
/dev/hda3 9.5G 7.5G 1.6G 83% /
/dev/hdd5 9.5G 7.5G 1.6G 83% /mnt/hdd5
/dev/hda3 6.4G 3.3G 2.8G 54% /mnt/hda3
Of particular note here are the drives mounted(from /dev
) and their filesystem sizes.
Has anyone seen this before? How do I go about starting the 6.5GB drive as an OS?
Update: The grub entry is:
title CentOS (2.6.18-128.4.1.el5.centos.plus)
root (hd0,0)
kernel /vmlinuz-2.6.18-128.4.1.el5.centos.plus ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.18-128.4.1.el5.centos.plus.img
cat devices.map
# this device map was generated by anaconda
(hd0) /dev/hda
fdisk -l(Fedora)
Disk /dev/hdd: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdd1 1 1275 10241406 7 HPFS/NTFS
/dev/hdd2 1276 4864 28828642+ f W95 Ext'd (LBA)
/dev/hdd3 4865 4865 8032+ 82 Linux swap / Solaris
/dev/hdd5 1276 2550 10241406 83 Linux
/dev/hdd6 2551 4864 18587173+ b W95 FAT32
fdisk -l(CentOS):
Disk /dev/hda: 20.0 GB, 20020396032 bytes
255 heads, 63 sectors/track, 2434 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 10 80293+ 83 Linux
/dev/hda2 11 402 3148740 82 Linux swap / Solaris
/dev/hda3 403 1258 6875820 83 Linux
/dev/hda4 1259 2434 9446220 5 Extended
/dev/hda5 1259 1911 5245191 83 Linux
/dev/hda6 1912 2433 4192933+ 83 Linux
Relabel the Fedora root partition. The bootloader is getting confused. Something like e2label /dev/hda3 /centos
, then modify your GRUB entry (and possibly /etc/fstab) to point at that as the label.
Alternatively, you could relabel the Fedora root. Or take the easy way and point /etc/fstab and the root=
directive in your menu.lst at /dev/hda3 rather than a filesystem label.