User Tools

Site Tools


zfs:clone_a_system

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
zfs:clone_a_system [2021/10/13 12:26] peterzfs:clone_a_system [2021/10/13 12:26] (current) peter
Line 20: Line 20:
  
 [[ZFS:Clone a system:Detailed Instructions|Detailed Instructions]] [[ZFS:Clone a system:Detailed Instructions|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 'tank@%' 
-</code> 
- 
----- 
- 
-===== 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 'tank@p1snap' 
-zfs send -v --props --replicate --large-block --compressed tank@p1snap | ssh root@target 'zfs receive -F tank' 
-</code> 
- 
----- 
- 
-===== Mount the received tank on the target system ===== 
- 
-On the target: 
- 
-<code bash> 
-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 
-</code> 
- 
-<WRAP info> 
-**NOTE:**  This mounts the freshly received tank, and chroots into it. 
-</WRAP> 
- 
----- 
- 
-===== SELinux relabel ===== 
- 
-Sets the system to do an SELinux relabel: 
- 
-<code bash> 
-touch /.autorelabel 
-</code> 
- 
----- 
- 
-===== Update /etc/fstab ===== 
- 
-Edit /etc/fstab, and fix any UUIDs: 
- 
-<file bash /etc/fstab> 
-UUID="ABCD-E123"     /boot/efi  vfat  defaults                          0  0 
-</file> 
- 
----- 
- 
-===== Update hostname ===== 
- 
-Correct the hostname on the target: 
- 
-<code bash> 
-echo some_hostname > /etc/hostname 
-</code> 
- 
----- 
- 
-===== Limit Memory Usage (Optional) ===== 
- 
-If the system receiving the clone is low spec, add the zfs configuration limiting memory usage: 
- 
-<code bash> 
-cp /root/tiny-modprobe.d-zfs.conf /etc/modprobe.d/zfs.conf 
-</code> 
- 
----- 
- 
-===== Rebuild boot ===== 
- 
-<code bash> 
-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 
-</code> 
- 
-<WRAP info> 
-**NOTE:  This: 
- 
-  * rebuilds the initial ram-filesystem. 
-  * rebuilds the grub.cfg. 
-  * disables the grub pager. 
- 
-</WRAP> 
- 
----- 
- 
-===== Export the tank ===== 
- 
-On the target: 
- 
-Exit the chroot, unmount filesystems, and export tank: 
- 
-<code bash> 
-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 
-</code> 
- 
----- 
- 
-===== Reboot the Target ===== 
- 
-<code bash> 
-reboot -f 
-</code> 
- 
----- 
- 
-===== Remove the snapshot on the target ===== 
- 
-On the target, remove the snapshot p1snap: 
- 
-<code bash> 
-zfs destroy -vr 'tank@p1snap' 
-</code> 
- 
----- 
- 
-===== Remove the snapshot on the source ===== 
- 
-On the sender, remove the snapshot p1snap: 
- 
-<code bash> 
-zfs destroy -vr 'tank@p1snap' 
-</code> 
- 
  
  
zfs/clone_a_system.1634127960.txt.gz · Last modified: 2021/10/13 12:26 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki