I installed FreeBSD 14.2 onto one brand new SSD, on a UEFI machine. Next I used a script I wrote to add a second brand new SSD to the boot pool, as a mirror. Then I removed the first SSD, and attempted to boot from the second SSD, but I get this repeated error message, followed by the mountroot prompt. I've confirmed that the second SSD is indeed at /dev/ada0:
I've referenced sections of the bsdinstall script to try and perform the right steps. My script performs the following steps. When the script runs, the first disk (to which FreeBSD was installed) is at /dev/ada0, and the new disk is at /dev/ada1:
I can boot normally with both disks present though. And when I boot normally, the new disk appears online with zpool status. Did I miss a step for configuring the zfs partition on the new disk?
ZFS WARNING: Unable to open gpt/z-ad12345 for writing (error=1)
ZFS WARNING: Unable to open ada0p4 for writing (error=1)
. . .
Mounting from zfs:zroot/ROOT/default failed with error 1.
. . .
mountroot>
I've referenced sections of the bsdinstall script to try and perform the right steps. My script performs the following steps. When the script runs, the first disk (to which FreeBSD was installed) is at /dev/ada0, and the new disk is at /dev/ada1:
sh:
# wipe the new disk
swapoff [active_swap_device] # repeated to disable all active swap devices
gpart destroy -F /dev/ada1
zpool labelclear -f /dev/ada1
gpart create -s gpt /dev/ada1
gpart destroy -F /dev/ada1
# clone partition table from old disk to new disk
gpart backup /dev/ada0 | gpart restore -F /dev/ada1
zpool labelclear -f /dev/ada1p2
# label freebsd-boot partition with short disk serial number, and set BIOS bootcode
gpart modify -i 2 -l b-ad12345 /dev/ada1
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 2 /dev/ada1
# label EFI partition, and copy EFI partition from existing disk to new disk
umount /boot/efi
zpool labelclear -f /dev/ada1p1
dd if=/dev/ada0p1 /dev/ada1p1 bs=1m
gpart modify -i 1 -l e-ad12345 /dev/ada1
mount -t msdosfs /dev/ada1p1 /boot/efi
test -f /boot/efi/efi/freebsd/loader.efi # Note: confirm good copy
efibootmgr --delete -b 0002 # Note: delete existing "ad12345" entry for this disk
efibootmgr --create --activate --loader "/boot/efi/efi/freebsd/loader.efi" --label "FreeBSD OS Disk ad12345"
# Ensure /etc/fstab has only one entry to mount EFI part, and that it's the first mounted disk
sed -i '' '/\dev/\/gpt\/efiboot/d' /etc/fstab
sed -i '' '/\dev\/ada0p1/d' /etc/fstab
echo 'dev/ada0p1 /boot/efi msdosfs rw 2 2' >> /etc/fstab
# label swap partition, ensure only one disk swap entry in /etc/fstab
zpool labelclear -f /dev/ada1p3
gpart modify -i 3 -l s-ad12345 /dev/ada1
sed -i '' '/\/dev\/ad.*swap/d' /etc/fstab
sed -i '' '/\/dev\/nd.*swap/d' /etc/fstab
sed -i '' '/\/dev\/gpt\/s-ad12345/d' /etc/fstab
echo '/dev/gpt/s-ad12345 none swap sw 0 0' >> /etc/fstab
swapon -a
# label zfs partition, attach it to existing disk to make boot pool mirror
zpool labelclear -f /dev/ada1p4
gpart modify -i 4 -l z-ad12345 /dev/ada1
zpool attach -f -w zroot /dev/ada0p4 /dev/gpt/z-ad12345
I can boot normally with both disks present though. And when I boot normally, the new disk appears online with zpool status. Did I miss a step for configuring the zfs partition on the new disk?