Saturday, December 22, 2007

Dealing with FreeBSD MountRoot Prompt

You will bump into a FreeBSD <mountroot> prompt if your system failed to correctly mount your root device. This normally happens when you modify your hardware and the disk configuration changes.

It's actually very simple to solve this situation and to get your system up and running again. If you're not familiar with the mount command then this a great time to familiarize yourself. You can read the man page at

Solving the problem. When you get the <mountroot> prompt, the dmesg info displayed right above it will pretty much tell you all that you need to know.

First, the message will probably be something like it 'couldn't mount root from ufs:/dev/ad8s1a' (or whatever your disk was). And above it, you should see your new disks set up (i.e. ad0 19877 Seagate, ad1 19871 Maxtor, etc). You should be able to recognize your old drive by HD size+brand or some other subtle difference (here we will assume that your drive became ad0 from ad8).

At the <mountroot> prompt you can type '?' to get a list of devices which should also display 'ad0s1a'. And that's what we are looking for. Then type (you'll be taken to single-user mode so that you can fix the rest)

In single-user mode, you can look at your current fstab file where the mount devices are specified.
# cat /etc/fstab

Then mount your /var, /tmp, /usr just like in your fstab but changing the disk number
# mount -t ufs /dev/ad0s1d /var
# mount -t ufs /dev/ad0s1e /tmp
# mount -t ufs /dev/ad0s1f /usr

You can confirm your mounts by typing either of these two commands:
# df
# mount -p

Make root writable so that you can update fstab
# mount -uw /

Update fstab with the correct disk IDs.
# vi /etc/fstab
Save it and reboot

Welcome back to your system! :)


Anonymous said...

Thanks!! This solved my problem. Very well laid out.


Anonymous said...

Thank you very much. This also fixed it for me after doing a major version upgrade using freebsd-update and it reassigned my disk-IDs.

istanbul engin said...

a very good document .. I worked a lot of work .. Thank you very very much.

Anonymous said...

Whole lotta thanks pal!!
You saved my day in just 15 mins!!


Marc said...

Thank you! Had a pfSense box die on me (capacitor plague) - moved the HDD and NICs to a new box, and it worked up to this point. You got me the rest of the way. Thank you, thank you!

Anonymous said...

Thank you so much. I had 3 hard drives and after I recompiled kernel with ahci and GEOM_ELI support it failed to boot.

Your method worked well.

Anonymous said...

Thank you very much

Anonymous said...

You are a life saver! Thanks!!!

Cesar Castellanos said...

Thanks a whole lot man! One laptop server kicked the bucket 2 days ago and I swapped the hard drive but never got past this point.

Your document saved me a tonne of stress and a complete reinstall and custom setup when I had a time-sensitive switch to make!

Just one comment for possible update. It turns out neither vi nor vim were installed to update /etc/fstab. Since I couldn't connect to the network to install those, I had to use ee as the text editor. I believe that is the built-in one with FreeBSD?

Thanks so much!!


Anonymous said...

Nicely done! Very clear and precise. Thanks.

André Luiz Norbim de Assis said...

Thanks from a friend from Brasil! Helped so much!

Anonymous said...

thanks from germany. Now its up and running again