Recently I swapped my primary disk for another one. (on a Thinkpad X230 running Arch Linux)
Since I am using an uncommon setup, I thought it would be nice to document the process.
So this article is about cloning an ecrypted zfs partition.
Maybe I could just dd one to the other, but I am moving to a smalled disk (hopefully with better reliability).
I use one disk with two primary partions :
- One 4GB as /boot
- The rest as an encrypted partiotion which contains ZFS.
- Create the corresponding new partitions on the new disk.
- Cloning the ZFS using
- Installing grub on the new disk.
- Swaping the old with the new disk.
The process detailed
Initialy, on my old disk I took a snapshot.
zfs snapshot -r zrt/r@201707_16
Now, on to the new disk:
After I created two partitions (using fdisk, the first marked as boot) I went on to :
- Create an encrypted partiotion using cryptsetup
- Create a new pool using the encryped partiotion
- Copy the old snapshot (
zfsz2/flash_2017@201707_16) to the new filesystem (
Continuing on the new disk:
- Create the boot partiotion
- Copy all files of the old boot partiotion to the new one
After having copied the zfs filesystem, I import the new filesystem under a different directory (/mnt/external instead of /)
I mount the new boot under the /mnt/external/boot
Shutdown, replace the old with the new disk and PowerOn!