aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xkvmx5
-rw-r--r--kvmxfile5
-rwxr-xr-xshare/provision/debian/basic3
3 files changed, 13 insertions, 0 deletions
diff --git a/kvmx b/kvmx
index a486271..42252dd 100755
--- a/kvmx
+++ b/kvmx
@@ -547,6 +547,11 @@ function kvmx_up {
image_opts="-cdrom $image"
else
image_opts="-drive file=$image,if=$drive_interface"
+
+ # TRIM support
+ if [ "$image_discards" != "n" ]; then
+ image_opts="$image_opts,discard=unmap"
+ fi
fi
if [ ! -z "$virtio_rng" ]; then
diff --git a/kvmxfile b/kvmxfile
index 48bc9cc..308a59d 100644
--- a/kvmxfile
+++ b/kvmxfile
@@ -149,6 +149,11 @@ xrandr="0"
# Image type: file or device (kvmx-create only)
image_type="file"
+# Discards support
+# See https://jschumacher.info/2020/11/debian-qemu-libvirt-qcow2-and-fstrim/
+# https://chrisirwin.ca/posts/discard-with-kvm-2020/
+image_discards="y"
+
# Image size
size="10G"
diff --git a/share/provision/debian/basic b/share/provision/debian/basic
index f3a282c..1ef8e13 100755
--- a/share/provision/debian/basic
+++ b/share/provision/debian/basic
@@ -75,5 +75,8 @@ fi
# Fstrim
# See https://pve.proxmox.com/wiki/Shrink_Qcow2_Disk_Files
+# See also image_discards kvmxfile option
+sudo systemctl enable fstrim.timer
+sudo systemctl start fstrim.timer
sudo fstrim -av
sudo sync