Using GRUB to figure out the mapping of BIOS drive numbers
June 20, 2009
Suppose you have a piece of hardware where the mapping between BIOS drive numbers and Linux device names is not straightforward, and you want to figure out just what the mapping is (at least for your current disks). If you use GRUB (and you probably do), there's a relatively simple way of doing this.
GRUB has two important attributes for this: it can read Linux filesystems and tell you what's in them, and at boot time it is working with the BIOS drive numbering. So the basic approach is to plant unique flag files in filesystems on each drive, reboot your system, break into the GRUB shell, and use GRUB commands to find out what flag file is on each BIOS disk number.
(Okay, there's an important qualifier to this: this is the BIOS boot order, not the actual labels that the BIOS and the motherboard use. It is possible to have the BIOS perturb the boot order from the label order, so that 'SATA 3' is the boot drive, not 'SATA 1'.)
GRUB doesn't have an explicit
This will helpfully tell you which 'FLAG-*' file is on partition Y of BIOS disk number X (numbering from 0). You can repeat this sequence for each BIOS disk number that you have.
(You will probably have to break out of the usual GRUB menu into GRUB's command mode during booting. As far as I know there's no way back to menu mode, so just reboot the machine afterwards.)
Depending on your configuration, getting a unique flag file onto a
simple filesystem in a simple partition on each disk may be either
trivial or very complex (this is one situation where a mirrored
If you don't already have such a set of filesystems, here's some suggestions:
In my case, it turned out that ASUS M4N2-SLI motherboards invert the
order of the first pair of SATA channels relative to the last two;
SATA 1 and 2 were
Comments on this page:
Written on 20 June 2009.
* * *
Atom feeds are available; see the bottom of most pages.