User Tools

Site Tools


zfs:clone_a_system:detailed_instructions

ZFS - Clone a system - Detailed Instructions

Boot the target system

Boot the target system that will receive the ZFS Snapshot.


Remove all previous snapshots on the target system

zpool import -f tank
zfs destroy -Rv 'tank@%'

Create a snapshot on the source system

On the source system, create a new snapshot, and send it to the target.

zfs snapshot -r 'tank@p1snap'
zfs send -v --props --replicate --large-block --compressed tank@p1snap | ssh root@target 'zfs receive -F tank'

Mount the received tank on the target system

On the target:

zfs set mountpoint=/sysroot tank/root
zfs set mountpoint=/sysroot/boot tank/root/boot
zfs set mountpoint=/sysroot/tmp tank/root/tmp
zfs set mountpoint=/sysroot/var tank/root/var
zfs mount -a
mount --rbind /dev/ /sysroot/dev/
mount --rbind /proc/ /sysroot/proc/
mount --rbind /sys/ /sysroot/sys/
mount --rbind /run/ /sysroot/run/
chroot /sysroot/ /bin/bash

NOTE: This mounts the freshly received tank, and chroots into it.


SELinux relabel

Sets the system to do an SELinux relabel:

touch /.autorelabel

Update /etc/fstab

Edit /etc/fstab, and fix any UUIDs:

/etc/fstab
UUID="ABCD-E123"     /boot/efi  vfat  defaults                          0  0

Update hostname

Correct the hostname on the target:

echo some_hostname > /etc/hostname

Limit Memory Usage (Optional)

If the system receiving the clone is low spec, add the zfs configuration limiting memory usage:

cp /root/tiny-modprobe.d-zfs.conf /etc/modprobe.d/zfs.conf

Rebuild boot

dracut --force /boot/initramfs-5.2.9-200.fc30.x86_64.img 5.2.9-200.fc30.x86_64
ZPOOL_VDEV_NAME_PATH=YES grub2-mkconfig > /boot/grub2/grub.cfg
sed -i '/^set pager/ s/1/0/' /boot/grub2/grub.cfg

**NOTE: This:

  • rebuilds the initial ram-filesystem.
  • rebuilds the grub.cfg.
  • disables the grub pager.

Export the tank

On the target:

Exit the chroot, unmount filesystems, and export tank:

exit
umount -l /sysroot/{dev,proc,sys,run}/
zfs set mountpoint=/ tank/root
zfs set mountpoint=legacy tank/root/boot
zfs set mountpoint=legacy tank/root/tmp
zfs set mountpoint=legacy tank/root/var
zpool export tank

Reboot the Target

reboot -f

Remove the snapshot on the target

On the target, remove the snapshot p1snap:

zfs destroy -vr 'tank@p1snap'

Remove the snapshot on the source

On the sender, remove the snapshot p1snap:

zfs destroy -vr 'tank@p1snap'
zfs/clone_a_system/detailed_instructions.txt · Last modified: 2021/10/13 12:26 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki