zfs:clone_a_system:detailed_instructions
Differences
This shows you the differences between two versions of the page.
zfs:clone_a_system:detailed_instructions [2021/10/13 12:26] – created peter | zfs:clone_a_system:detailed_instructions [2021/10/13 12:26] (current) – peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== 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 ===== | ||
+ | |||
+ | <code bash> | ||
+ | zpool import -f tank | ||
+ | zfs destroy -Rv ' | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Create a snapshot on the source system ===== | ||
+ | |||
+ | On the source system, create a new snapshot, and send it to the target. | ||
+ | |||
+ | <code bash> | ||
+ | zfs snapshot -r ' | ||
+ | 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: | ||
+ | |||
+ | <code bash> | ||
+ | zfs set mountpoint=/ | ||
+ | zfs set mountpoint=/ | ||
+ | zfs set mountpoint=/ | ||
+ | zfs set mountpoint=/ | ||
+ | zfs mount -a | ||
+ | mount --rbind /dev/ / | ||
+ | mount --rbind /proc/ / | ||
+ | mount --rbind /sys/ / | ||
+ | mount --rbind /run/ / | ||
+ | chroot /sysroot/ /bin/bash | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== SELinux relabel ===== | ||
+ | |||
+ | Sets the system to do an SELinux relabel: | ||
+ | |||
+ | <code bash> | ||
+ | touch / | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Update /etc/fstab ===== | ||
+ | |||
+ | Edit /etc/fstab, and fix any UUIDs: | ||
+ | |||
+ | <file bash / | ||
+ | UUID=" | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Update hostname ===== | ||
+ | |||
+ | Correct the hostname on the target: | ||
+ | |||
+ | <code bash> | ||
+ | echo some_hostname > / | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Limit Memory Usage (Optional) ===== | ||
+ | |||
+ | If the system receiving the clone is low spec, add the zfs configuration limiting memory usage: | ||
+ | |||
+ | <code bash> | ||
+ | cp / | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Rebuild boot ===== | ||
+ | |||
+ | <code bash> | ||
+ | dracut --force / | ||
+ | ZPOOL_VDEV_NAME_PATH=YES grub2-mkconfig > / | ||
+ | sed -i '/^set pager/ s/ | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | * rebuilds the initial ram-filesystem. | ||
+ | * rebuilds the grub.cfg. | ||
+ | * disables the grub pager. | ||
+ | |||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Export the tank ===== | ||
+ | |||
+ | On the target: | ||
+ | |||
+ | Exit the chroot, unmount filesystems, | ||
+ | |||
+ | <code bash> | ||
+ | exit | ||
+ | umount -l / | ||
+ | zfs set mountpoint=/ | ||
+ | zfs set mountpoint=legacy tank/ | ||
+ | zfs set mountpoint=legacy tank/ | ||
+ | zfs set mountpoint=legacy tank/ | ||
+ | zpool export tank | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Reboot the Target ===== | ||
+ | |||
+ | <code bash> | ||
+ | reboot -f | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Remove the snapshot on the target ===== | ||
+ | |||
+ | On the target, remove the snapshot p1snap: | ||
+ | |||
+ | <code bash> | ||
+ | zfs destroy -vr ' | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Remove the snapshot on the source ===== | ||
+ | |||
+ | On the sender, remove the snapshot p1snap: | ||
+ | |||
+ | <code bash> | ||
+ | zfs destroy -vr ' | ||
+ | </ | ||
+ | |||
+ | |||
zfs/clone_a_system/detailed_instructions.1634127974.txt.gz · Last modified: 2021/10/13 12:26 by peter