I want to move /var from a simple ext4 partition to a zfs pool I've built on a RAID array. I understand I've got to reboot in single user mode to cp -avr the /var partition across, but how do I make sure all of the kernel modules are loaded on boot and in the single user environment, do I have to put them in an initrd?
Solved this (Debian 10);
- Set up your ZFS structure but not mount points
- Reboot in single-user mode
- Import ZFS structure using zpool import -d /dev/disk/by-id
- Copy /var to new pool, I used rsync -avxHAX /var/
- Move /var to /var2 as a backup
- Edit /etc/fstab to prevent mount of old var
- Change the mount point of your ZFS partition to zfs set mountpoint=/var
Optional; you might need to "zfs set overlay=on ". I didn't need to do this on a test VM with zfs on a single disk, but did on a crufty old server. This is because the kernel was starting to fill /var before ZFS mounted. looking at the systemd log, this was about the same point in the boot as my old ext4 partition got mounted over /var and the system works, but ymmv.
Rationale; I wanted more space for my docker containers and VMs and them to be in the standard location on the filesystem and I wanted to try ZFS for the snapshotting, compression and stability. I'll update this if it goes horribly wrong.