Booting a GPT+ESP+UFS system on a BIOS-only machine

For reasons too convoluted to go into, I find myself needing to do the following:
  1. Take an SSD with a working 11.4-RELEASE install that uses UEFI/ESP on GPT to boot the system from a UFS partition, and
  2. put that SSD into another machine that does not support UEFI booting (only BIOS), and
  3. boot the 11.4-RELEASE system.
My preferred solution would be to prepare a BIOS-bootable USB stick that could "redirect" the boot process to the system's UFS partition. I'd be willing to type some commands to achieve this, it doesn't need to "boot through" unattended.

Any hints on how to do that?
 
In fact you only need a /boot filesystem on your USB and tell in loader.conf where to mount root.
Boot0 tells where to find boot1. Boot1 tells where to find the loader. The loader tells where to mount root.
 
  • Thanks
Reactions: mtu
if the change is for good you can nuke the esp and convert it to freebsd boot
if its a one time use then do the usb stick. you need to have up to loader and all loader deps on it, change currdev and rootfs and boot
 
  • Thanks
Reactions: mtu
In fact I will try this idea with my PC now and try to make a boot usb.
There are some interesting man pages.
man gpart
man makefs
man mkimg
 
How big is that efi ESP partition? You might be able to split it up into a efi and freebsd-boot partition. Then you can "multi" boot between EUFI and CSM. The freebsd-boot partition is 512K with a default install but can be a lot smaller, it only has to fit /boot/gptzfsboot (for ZFS systems) or /boot/gptboot for UFS.
 
I would make a GPT scheme on the USB stick. Add pmbr as boot code and gptboot to fill the freebsd-boot partition. Then, create an UFS partition with boot.config file. Inside, you can specify where to find the loader.

gptboot()
boot.config(5)

But, I don't know if this will work.
 
Here what i did and it worked.
Code:
gpart create -s MBR myusbdisk
gpart add -t freebsd myusbdisk
gpart set -a active -i 1 myusbdisk
gpart bootcode -b /boot/boot0 myusbdisk
gpart create -s BSD -n 20 mypartition
gpart add -t freebsd-ufs mypartition
gpart bootcode -b /boot/boot mypartition
news -O 2 -U -j myslice
mount_the_slice
Copy over your /boot directory
Verify the loader.conf on the destination
This works fine.
I tried the same after removing /boot/kernel directory from the USB stick but that did not worked.
I don't know why.
I thought the loader was taking the kernel from the to mount root filesystem but it seems not, or the loader needs a module from the kernel directory ?
 
  • Thanks
Reactions: mtu
Here what i did and it worked.
Code:
gpart create -s MBR myusbdisk
gpart add -t freebsd myusbdisk
gpart set -a active -i 1 myusbdisk
gpart bootcode -b /boot/boot0 myusbdisk
gpart create -s BSD -n 20 mypartition
gpart add -t freebsd-ufs mypartition
gpart bootcode -b /boot/boot mypartition
news -O 2 -U -j myslice
mount_the_slice
Copy over your /boot partition
Verify the loader.conf on the destination
This works fine.
I tried the same after removing /boot/kernel directory from the USB stick but that did not worked.
I don't know why.
I thought the loader was taking the kernel from the to mount root filesystem but it seems not.
loader does not "understand" kernel device specs as in vfs.root.mountfrom=
you need to play with set currdev before loading modules and kernel
 
I added to loader.conf
Code:
currdev="zfs:ZT/ROOT/default:"
And the loader took the kernel from the zpool. It worked.
There was no need for a boot.config file on the USB stick.
 
Back
Top