Next: , Previous: Making a GRUB bootable CD-ROM, Up: Installation


3.3 The map between BIOS drives and OS devices

The grub-mkdevicemap program can be used to create the device map file. It is often run automatically by tools such as grub-install if the device map file does not already exist. The file name /boot/grub/device.map is preferred.

If the device map file exists, the GRUB utilities (grub-probe, grub-setup, etc.) read it to map BIOS drives to OS devices. This file consists of lines like this:

     device file

device is a drive specified in the GRUB syntax (see Device syntax), and file is an OS file, which is normally a device file.

Historically, the device map file was used because GRUB device names had to be used in the configuration file, and they were derived from BIOS drive numbers. The map between BIOS drives and OS devices cannot always be guessed correctly: for example, GRUB will get the order wrong if you exchange the boot sequence between IDE and SCSI in your BIOS.

Unfortunately, even OS device names are not always stable. Modern versions of the Linux kernel may probe drives in a different order from boot to boot, and the prefix (/dev/hd* versus /dev/sd*) may change depending on the driver subsystem in use. As a result, the device map file required frequent editing on some systems.

GRUB avoids this problem nowadays by using UUIDs or file system labels when generating grub.cfg, and we advise that you do the same for any custom menu entries you write. If the device map file does not exist, then the GRUB utilities will assume a temporary device map on the fly. This is often good enough, particularly in the common case of single-disk systems.

However, the device map file is not entirely obsolete yet, and there are still some situations that require it to exist. If necessary, you may edit the file if grub-mkdevicemap makes a mistake. You can put any comments in the file if needed, as the GRUB utilities assume that a line is just a comment if the first character is ‘#’.