I've followed bunch of advice from different threads on here and I tried to test replacing a disk for zroot in case I get into that situation.
I'm testing this on a FreeBSD VM running on vm-bhyve with uefi bootloader and uefivars enabled.
VM has 3 zvol disks. All 3 disks are created at the time of VM creation.
I installed FreeBSD on two disks in a mirror.
Then I copied the GPT
Table did look a bit different
Edited the labels
So then I did
Edited fstab
from
to
Then attached the partition to zroot
zpool status also looked weird
second time arount zpool looked fine
This worked. I could boot into FreeBSD.
However, I could not get it to work using the below commands.
Some of those commands said file is too large so I guess either gpart restore did something wrong or I'm not supposed to use those files.
When I installed FreeBSD I chose GPT(UEFI). So which files are the correct files to copy over with gpart bootcode. I did read that /boot/pmbr will load gptzfsboot, but I can't confirm that's the one because it didn't work for me.
When I did `gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 vtbd2` and edited fstab, the bootloader starts but the partition can not get mounted. It says invalid signature in boot block.
I can see all of the datasets but I can not write to fstab file.
I also did "dd if=/boot/gptzfsboot of=/dev/vtbd2p1" and that didn't work either.
I'm testing this on a FreeBSD VM running on vm-bhyve with uefi bootloader and uefivars enabled.
VM has 3 zvol disks. All 3 disks are created at the time of VM creation.
Code:
loader="uefi"
cpu=8
memory=8G
network0_type="virtio-net"
network0_switch="public"
disk0_type="virtio-blk"
disk0_name="disk0"
disk0_dev="sparse-zvol"
disk1_name="disk1"
disk1_dev="sparse-zvol"
disk1_type="virtio-blk"
disk2_name="disk2"
disk2_dev="sparse-zvol"
disk2_type="virtio-blk"
graphics="yes"
xhci_mouse="yes"
graphics_res="1600x900"
zfs_zvol_opts="volblocksize=128k"
uefi_vars="yes"
I installed FreeBSD on two disks in a mirror.
Then I copied the GPT
Code:
gpart backup vtbd0 | gpart restore -F vtbd2
Table did look a bit different
Code:
root@:~ # gpart show -l
=> 40 41942960 vtbd0 GPT (20G)
40 532480 1 efiboot0 (260M)
532520 2008 - free - (1.0M)
534528 41406464 2 zfs0 (20G)
41940992 2008 - free - (1.0M)
=> 40 41942960 vtbd1 GPT (20G)
40 532480 1 efiboot1 (260M)
532520 2008 - free - (1.0M)
534528 41406464 2 zfs1 (20G)
41940992 2008 - free - (1.0M)
=> 34 41942973 vtbd2 GPT (20G)
34 6 - free - (3.0K)
40 532480 1 efiboot2 (260M)
532520 2008 - free - (1.0M)
534528 41406464 2 zfs2 (20G)
41940992 2015 - free - (1.0M)
Edited the labels
Code:
gpart modify -i 1 -l efiboot2 vtbd2
gpart modify -i 2 -l zfs2 vtbd2
So then I did
Code:
dd if=/dev/vtbd0p1 of=/dev/vtbd2p1
Edited fstab
from
Code:
# Device Mountpoint FStype Options Dump Pass#
/dev/gpt/efiboot0 /boot/efi msdosfs rw 2 2
to
Code:
# Device Mountpoint FStype Options Dump Pass#
/dev/gpt/efiboot2 /boot/efi msdosfs rw 2 2
Then attached the partition to zroot
Code:
zpool attach zroot /dev/vtbd0p2 /dev/vtbd2p2
zpool status also looked weird
Code:
root@:~ # zpool status
pool: zroot
state: ONLINE
status: One or more devices are configured to use a non-native block size.
Expect reduced performance.
action: Replace affected devices with devices that support the
configured block size, or migrate data to a properly configured
pool.
scan: resilvered 935M in 00:00:29 with 0 errors on Fri Jul 26 09:38:23 2024
config:
NAME STATE READ WRITE CKSUM
zroot ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
vtbd0p2 ONLINE 0 0 0
vtbd2p2 ONLINE 0 0 0 block size: 4096B configured, 16384B native
second time arount zpool looked fine
Code:
root@:~ # zpool status
pool: zroot
state: ONLINE
scan: resilvered 934M in 00:00:20 with 0 errors on Fri Jul 26 10:13:55 2024
config:
NAME STATE READ WRITE CKSUM
zroot ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
vtbd0p2 ONLINE 0 0 0
vtbd1p2 ONLINE 0 0 0
vtbd2p2 ONLINE 0 0 0
This worked. I could boot into FreeBSD.
However, I could not get it to work using the below commands.
Code:
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 vtbd2
gpart bootcode -b /boot/zfsloader -p /boot/gptzfsboot -i 1 vtbd2
gpart bootcode -b /boot/efi/efi/freebsd/loader.efi -p /boot/gptzfsboot -i 1 vtbd2
gpart bootcode -b /boot/efi/efi/boot/bootx64.efi -p /boot/gptzfsboot -i 1 vtbd2
gpart bootcode -b /boot/efi.4th -p /boot/gptzfsboot -i 1 vtbd2
gpart bootcode -b /boot/loader.efi -p /boot/gptzfsboot -i 1 vtbd2
gpart bootcode -b /boot/gptboot -p /boot/gptzfsboot -i 1 vtbd2
gpart bootcode -b /boot/zfsboot -p /boot/gptzfsboot -i 1 vtbd2
Some of those commands said file is too large so I guess either gpart restore did something wrong or I'm not supposed to use those files.
When I installed FreeBSD I chose GPT(UEFI). So which files are the correct files to copy over with gpart bootcode. I did read that /boot/pmbr will load gptzfsboot, but I can't confirm that's the one because it didn't work for me.
When I did `gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 vtbd2` and edited fstab, the bootloader starts but the partition can not get mounted. It says invalid signature in boot block.
I can see all of the datasets but I can not write to fstab file.
I also did "dd if=/boot/gptzfsboot of=/dev/vtbd2p1" and that didn't work either.