Image backup

I have a ZFS pool named “storage” I back up my NVMe drive to. These instructions are for my use case, if you find them useful, great, but be careful, as it is your data and your responsibility!

Boot from ArchLinux ISO
Make sure you have network access per the Installation wiki
timedatectl

Make sure we have enough space for installing needed packages, etc:
mount -o remount,size=50% /run/archiso/cowspace

Establish repos and update keyring:
pacman -Sy
pacman -S archlinux-keyring

Add the archzfs repo:
cat >> /etc/pacman.conf <<"EOF"
[archzfs]
Server = http://archzfs.com/archzfs/x86_64
EOF

Get keys sorted:
pacman-key --populate archlinux
pacman-key --recv-keys F75D9D76
pacman-key --lsign-key F75D9D76

Adde the ArchLinux archives to get the correct kernel and headers to match the booted ArchISO
NOTE: $version here is the date of the archiso, eg 2024/02/01, so for the ISO for Feb 2024:
echo “Server=https://archive.archlinux.org/repos/2024/02/01/\$repo/os/\$arch” > /etc/pacman.d/mirrorlist
Also note this DOES replace the existing mirrorlist, so make a backup before the next command, if you wish:
echo "Server=https://archive.archlinux.org/repos/$version/\$repo/os/\$arch" > /etc/pacman.d/mirrorlist

Now install the matching headers to the version of the kernel running while booted from the ArchISO – Note: you can leave out linux if you want, but it prevents an error during dkms installation – the error does not prevent loading of the zfs module:
pacman -Syy
pacman -S linux linux-headers

And install the zfs-dkms package from ArchZFS repo and other required packages:
pacman -S zfs-dkms

Load the zfs module – if you left out the linux package, updating linux initcpios will fail, but the module should still load:
modprobe zfs

Now we can mount the existing pool and backup:
zpool import storage
dd if=/dev/nvme0n1 bs=256M | zstd -19 -T11 --sparse > /storage/archwks.img.zst
zstd -t /storage/archwks.img.zst

For making a copy of qcow2, cleans up churn growth:
qemu-img convert -O qcow2 win10-2.qcow2 win10.qcow2

My notes for future me