setting root filesystem in kernel

Hi,

Is there a way to set the root file system in the kernel? My goal is to boot from one drive and then have it use another drive as root.

Thanks!
 
The reason for doing this is so that I can boot off the built in sata controller, and then move over the raid controller. I have not been able to make it boot from raid.
 
You can boot the root file system from a different disk-partition (raid volume) with a kernel loaded from another disk-partition.

When BIOS see boot.config(5).

When UEFI set a loader environment from a configuration file in the ESP. For example, the kernel from disk 1, partition 3 should boot the root file system from disk 2, partition 3, then set in the ESP's /efi/boot/freebsd/loader.env

currdev=disk1p3
Code:
rootdev=disk1p3
(In 13.0-RELEASE this doesn't work, presumably due to a bug, but it works in 13.1-RELEASE.)
 
Setting currdev= in /boot/loader.conf is a better solution than boot.config(5) or loader.env in ESP, independent if the firmware is BIOS or UEFI.

To quote from loader(8):
Code:
     currdev   Selects the default device to loader the kernel from.  The
               syntax is:
                     loader_device:
               or
                     zfs:dataset:
               Examples:
                     disk0p2:
                     zfs:zroot/ROOT/default:
(loader_device -> UFS2)
 
To clarify, there are two loader variables, currdev and rootdev, which can be used to set the root file system (see loader(8) for details).

The currdev variable selects the default device/partition from which the kernel should be loaded and the same root file system be mounted.

Example: The root file system where the variable is set is on disk 1 and the kernel and root file system which should be booted from and mounted is on disk 2, partition 2: currdev=disk1p2: (disk counting starts at 0), ZFS currdev=zroot1/ROOT/default: (zroot1 pool being here the file system on disk 2).


The rootdev variable specifies only the root file system to be mounted, not the kernel to be loaded.

Example: The kernel to boot from and the variable set is on disk 1 and the root file system which should be mounted is on disk 2, partition 2: rootdev=disk1p2:.

rootdev works well with UFS2, on ZFS it doesn't ( tested on 13.1-RELEASE). Neither the kernel nor the root file system specified is hand over as variable to the loader. Instead set vfs.root.mountfrom="zfs:zroot1/ROOT/default".

With the rootdev or vfs.root.mountfrom variable set, the kernel and and the mounted root file system must have the same version..
 
I am using UFS2 and had no success in setting currdev in /EFI/freebsd/loader.env but did have success setting rootdev even though kernel and root file system were on a different HDD than the ESP. I have not tried yet to set either of these variables in /boot/loader.conf. Maybe they would work there.
 
Back
Top