ZFS, zero drives to get better backup .IMG file compression... while running Linux

You can also do:
Detach first drive from rpool: sudo zpool detach rpool {Drive 1 PARTUUID}

Ensure rpool is still good: sudo zpool status

Attach first drive to rpool: sudo zpool attach rpool {Drive 2 PARTUUID} {Drive 1 PARTUUID}

Allow the automatic resilver to complete, monitor it with: sudo zpool status 5

Scrub rpool: sudo zpool scrub rpool
And monitor it with: sudo zpool status 5

Detach second drive from rpool: sudo zpool detach rpool {Drive 2 PARTUUID}

Ensure rpool is still good: sudo zpool status

Attach second drive to rpool: sudo zpool attach rpool {Drive 1 PARTUUID} {Drive 2 PARTUUID}

Allow the automatic resilver to complete, monitor it with: sudo zpool status 5

Scrub rpool: sudo zpool scrub rpool
And monitor it with: sudo zpool status 5

Doing the above apparently deletes the progress data that zpool initialize keeps, so it starts over from the beginning. If you don't delete that progress data, on subsequent runs zpool initialize believes it's already done, and exits quickly, so sectors don't get zero'd.

Then run:
gnome-terminal -- /bin/sh -c 'set zfs:zfs_initialize_value=0; sudo zpool initialize bpool {bpool PARTUUID}; sudo zpool initialize rpool {rpool Drive 1 PARTUUID} {rpool Drive 2 PARTUUID} {rpool Drive 3 (SLOG) PARTUUID} {rpool Drive 4 (SLOG) PARTUUID}; while sudo zpool status | grep "initializing" > /dev/null; do clear; sudo zpool status -Td; sleep 2; done; clear; sudo zpool status -Td; sleep 15'
... to zero the rpool free space.


Record the UUID (not PARTUUID) of the swap partition for later use:
sudo blkid

Unmount swap partition: sudo swapoff -v /dev/sda2 <== The swap partition

Zero swap partition: sudo dd if=/dev/zero of=/dev/sda2 bs=512 status=progress

Set up swap partition: sudo mkswap /dev/sda2 -U {Swap Partition UUID} <== The original UUID of the swap partition

Mount swap partition: sudo swapon -a

Zeroing the sectors on the swap drive resets its UUID. Setting the UUID as done above means you don't have to mess with your /etc/fstab file, if you've set up your swap partition to be mounted like:
/dev/disk/by-uuid/{Swap Partition UUID} none swap sw,noatime 0 0

Now boot into Zorin OS USB stick and run BackupToZip.sh.

1 Like