Debian – Why is GRUB drive enumeration different before and after boot

bootdebiangrubhard driveraid

I'm looking at a system with Debian/Lenny on a couple of old IDE PATA drives (several RAID-1 partitions including /boot) and a relatively recently added SATA drive. The system works fine but I've been poking around the GRUB setup in anticipation of upgrading the old drives…

If I go straight to the grub command line when the boot menu appears and inspect the drives there (using

grub> root (<TAB>...)

) then I see hd0 and hd1 as the PATAs and hd2 as the SATA.

However, after the system boots up if I do the same thing then I see hd0 is now the SATA and hd1 and hd2 are the PATAs. (Also, the system maps /dev/sda,c,b to SATA,PATA,PATA.)

This makes me a bit nervous about making changes from the grub> prompt once the machine has booted. So:

Why does the device order seen by grub change between these 2 cases ?

Also:

Correct functioning of some GRUB commands seems to rely on device.map being correct. Currently it contains a single line:

(hd0)   /dev/md0

(Which is the RAID1 /boot) but I've no idea where that came from (this system goes back to woody I think)! grub-mkdevicemap wants to regenerate this as hd[0,1,2]->sd[a,b,c](but I haven't let it). update-grub tells me: warning: grub-probe can't find drive for /dev/sdb1. Any suggestions as to what a healthy device.map should look like, in light of the changing enumeration order ? (It's unclear to me whether it should contain the pre- or post- boot device enumeration order).

Best Answer

The pre-boot drive ordering seemed to correspond to the the order in the BIOS boot-menu. Making changes there had no effect on the post-boot ordering, so I just changed it to be the same as the post-boot order, and a fresh devices.map generated post-boot now contains some content which is valid pre-boot too.

Achieved the desired result: I feel a lot more comfortable about messing around in the pre- or post-boot grub shells, and I know whera a >grub setup (hd1) (hd1,0) is really going.