From f24303d021b6af46870be237b58bdb6d01e96ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rn=20=C3=85ne=20de=20Jong?= Date: Mon, 2 May 2022 09:27:59 +0200 Subject: [PATCH] Make the image zstd-19 compressed --- opennebula-images/freebsd-zfs-build-opennebula-image.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/opennebula-images/freebsd-zfs-build-opennebula-image.sh b/opennebula-images/freebsd-zfs-build-opennebula-image.sh index 41b845f..d3a2847 100755 --- a/opennebula-images/freebsd-zfs-build-opennebula-image.sh +++ b/opennebula-images/freebsd-zfs-build-opennebula-image.sh @@ -53,7 +53,9 @@ gpart add -t freebsd-zfs -l zfs0 -b 1M -s 5G md0 zpool create -O compression=on -o ashift=12 -o altroot=/mnt -m none $ZPOOL md0p2 zfs create -o mountpoint=none $ZPOOL/ROOT -zfs create -o mountpoint=/ -o canmount=noauto $ZPOOL/ROOT/default +# We set zstd-19 so our image will become smaller, at the cost of a longer build time +# At the end, we remove zstd-19 again, but all files already written will remain zstd-19 compressed +zfs create -o mountpoint=/ -o canmount=noauto -o compression=zstd-19 $ZPOOL/ROOT/default mount -t zfs $ZPOOL/ROOT/default /mnt zpool set bootfs=$ZPOOL/ROOT/default $ZPOOL @@ -133,6 +135,11 @@ env ASSUME_ALWAYS_YES=YES pkg -c /mnt install sudo bash curl base64 ruby open-vm env ASSUME_ALWAYS_YES=YES pkg -c /mnt clean --all rm /mnt/one-context.txz +# Remove zstd-19 again, as it would be too slow for daily use. +# But all files that were already writtne will remain zstd-19 compressed. +# zstd-19 is slow to compress but fast to read. +zfs inherit compression $ZPOOL/ROOT/default + trap : EXIT cleanup