1

I installed FreeBSD 8.1 on a machine where the drive was /dev/ad6 but have moved it to a new system where the drive is now /dev/ad4. The new system boots but I need to manually specify that the root file system is on ad4s1.

How can I change the boot loader to do this automatically? Googling around turns up examples of disklabel -e being able to change the disk number, but I only get "Class not found" errors and no disk label changes with this method.

1
  • /etc/disktab and bsdlabel -B? /boot/kernel.conf?
    – Mikel
    Mar 22, 2011 at 3:34

4 Answers 4

4

I had the following scenario:

I intalled FreeBSD 10.1 USB .img file to 1GB stick and installed FreeBSD to the 16GB stick. 1GB stick was recognized as /dev/da0, and the 16GB stick as /dev/da1. FreeBSD was installed to 16GB stick under /dev/da1s2a. Then I removed 1GB stick and—normally—cannot boot to FreeBSD system automatically. The system said that cannot boot to vfs.root.mountfrom="/dev/da1s2a", but offered me to manually boot into FreeBSD, so I had to change the boot slice to /dev/da0s2a, and it worked. Off course, I don’t want to do it manually, so I found this post.

It inspired me to search for the location of variable vfs.root.mountfrom, so I remoot the system, pull out the 16GB stick, put back the 1GB stick, boot from it as a Live CD. At this point, I put back the 16GB stick, mounted it (mount /dev/da1s2a /mnt) and searched for "vfs.root.mountfrom". My findings were:

  1. DO NOT CHANGE the /boot/loader.conf file!
  2. DO NOT CHANGE the /boot/defaults/loader.conf file!

Since doing those things will mess up the loader!

The solution was to tweak the /etc/fstab on the /mnt (16GB stick) changing the entry /dev/da1s2a to /dev/da0s2a/ as the loader is looking the fstab for file systems in fstab during booting and automatically write the value of the vfs.Root.Mountfrom variable!!!

So during reboot I removed the 1GB stick and the machine successfully booted up the FreeBSD!

1
  • I installed FreeBSD on an XServe then moved the origial disk out so the drive numbers changed (ata1 to ata0). This simple solution fixed it instantly.
    – Allan
    Jan 17, 2016 at 1:16
2

The file /boot/loader.conf contains the instructions on which filesystem to mount as root.

Check this file for an enrty:

vfs.root.mountfrom="ufs:ad6s1a"

and tweak it (or add it if it's missing) to read:

vfs.root.mountfrom="ufs:ad4s1a"

(that is assuming partition a of slice 1 of device 4)

1
  • This was very simple, and worked for me. Thanks! May 16, 2015 at 16:10
1

Using sysinstall (Configure > Label) allowed fixing the disk label. One oddity was that the editor came up with the correct disk number (i.e. ad4), but selecting W wrote out the correct label and fixed the boot problem.

0

I think you want to change /boot.config.

See the boot.config man page.

It suggests you want something like

echo "1:ad(4,a)/boot/loader" > /boot.config

But cat the file first to see what /dev/ad6 is, then figure out what /dev/ad4 should be.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .