FreeBSD and ATA disks
October 21, 2006

(this issue might apply to the other BSDs, Linux, Solaris etc as well)

FreeBSD automatically names ATA hard disks like this:

controllerstate#name
primarymaster->drive 0ad0
primaryslave->drive 1ad1
secondarymaster->drive 2ad2
secondaryslave->drive 3ad3

On boot, the FreeBSD boot loader tries to mount the root partition; the location of the root partition is indexed using the drive number it is installed on (for example, ad0s1a or ad2s1a). However in the following circumstances, the FreeBSD boot loader will be unable to locate the root partition, and display a 'trying to mount root' message, followed by a prompt to mount manually:

These actions cause the FreeBSD drive to be renumbered. As the root partition is indexed by drive number, if the drive number changes, the root partition will no longer be where FreeBSD expects it to be.

The fix is as follows:

  1. boot from installation CD - select Fixit/Repair mode
  2. select live filesystem
  3. mount the drive (change the device and mountpoint name as appropriate):
    1. cd /mnt
    2. mkdir mypoint
    3. mount /dev/ad2s1a mypoint
  4. tweak fstab:
    1. ee mypoint/etc/fstab
    2. change each entry mentioning the old drive number to mention the new drive number instead - eg. ad0s1a is changed to ad2s1a for /usr, /var etc.
    3. save and exit
  5. exit Repair mode and the installer and reboot (don't forget to eject the installation CD)