Last active
October 16, 2024 17:45
-
-
Save ip75/74f5b3f9cd056a0ef25baa356ff9eb4b to your computer and use it in GitHub Desktop.
Migrate bootable zfs pool from zsys to sys (FreeBSD 14)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# ada3 new drive where migration intended | |
gpart add -t efi -s10G -lEFI /dev/ada3 | |
gpart add -t freebsd-swap -s64G -lSWAP /dev/ada3 | |
gpart add -t freebsd-zfs -lSYS /dev/ada3 | |
zfs snapshot -r zsys@full # create snapshot in source pool | |
zfs list -t snapshot # check | |
zfs destroy -r zsys/usr/obj@full # remove useless zfs point | |
mkdir /mnt/sys | |
zpool create -d -o altroot=/mnt/sys sys /dev/gpt/SYS # create destination pool and mount it to /mnt/sys | |
zfs send -R --skip-missing zsys@full | zfs receive -vF sys # transfer data | |
zfs destroy -r zsys@full # destroy snapshot from source pool | |
# to get FS tree work | |
zpool export sys | |
zpool import -o altroot=/mnt/sys -f sys | |
zpool get all sys # get all pool properties to check. | |
zfs create -o mountpoint=/usr/obj sys/usr/obj # restore zfs point for obj | |
zpool set bootfs=sys/ROOT/default sys # make `sys` pool bootable | |
mount -t msdosfs /dev/ada3p1 /mnt/sys/boot/efi # mount EFI partition to mounted `sys` pool | |
# create UEFI boot record to boot from this device | |
# efibootmgr will create correctly path in BIOS NVRAM. It will start paths from efi media (see `gpart list /dev/ada3`). | |
# BootOrder : 0002, 0000, 0001, 0003 | |
# Boot0002* kingston.bvgm.su HD(1,GPT,0011d507-7f3c-11ef-ae74-001b21d2a5b3,0x28,0x1400000)/File(\EFI\BOOT\loader.efi) | |
# ada3p1:/EFI/BOOT/loader.efi (null) | |
efibootmgr --activate --create --loader /mnt/sys/boot/efi/EFI/BOOT/loader.efi --label kingston.bvgm.su | |
# to unmount new `sys` pool before reboot | |
umount /mnt/sys/boot/efi | |
zpool export sys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment