Cloning a ZFS dataset using only zfs snapshot
, zfs send
, and zfs receive
Creating new BE’s using snapshots and clones can get messy with dependencies all over the place. I had an epiphany the other day, why not create a snapshot on the current dataset, send that snapshot to a new dataset within the same zpool (or elsewhere), and subsequently destroy the (two!) snapshots?
Instant transfer of data, and no strings attached to either dataset once the snapshots have been removed.
zfs snapshot zroot/ROOT/current-be@transfer zfs send zroot/ROOT/current-be@transfer | zfs receive -uv zroot/ROOT/new-be zfs destroy zroot/ROOT/current-be@transfer zfs destroy zroot/ROOT/new-be@transfer
Maybe a new zfs copy
command should be created to simplify the typing when copying datasets within a zpool.
Proceed with:
- Mount the new BE on, say,
/new-be
. - Running
make -C /usr/src DESTDIR=/new-be installworld installkernel
, ensures new versions overwriting old versions. - Running
mergemaster -Fi -D /new-be
, ensures configuration changes are merged into the new BE. - Running
make -C /usr/src DESTDIR=/new-be delete-old
, ensures obsolete stuff are removed. - Inherit the
mountpoint
property for new BE, or explicitly set themountpoint
property tolegacy
. - Update the
bootfs
property on the zpool to point to the new BE, and reboot to begin using the new BE.
If you’re not short on disk space, the above suggestion might be an acceptable compromise.