From 607315fe4b3af332fb0ae2b0707223e352a347e5 Mon Sep 17 00:00:00 2001 From: Aleksandr Mezin Date: Sun, 5 Jan 2025 09:55:32 +0200 Subject: [PATCH] Run fstrim (try to reduce image size) --- alpine-3.18.pkr.hcl | 1 + alpine-3.19.pkr.hcl | 1 + alpine-3.20.pkr.hcl | 1 + alpine-3.21.pkr.hcl | 1 + debian-12.pkr.hcl | 1 + fedora.ks | 2 ++ opensuse-leap-15.6.pkr.hcl | 6 ++++++ opensuse-tumbleweed.pkr.hcl | 6 ++++++ silverblue.ks | 2 ++ ubuntu-22.04.pkr.hcl | 1 + ubuntu-24.04.pkr.hcl | 1 + ubuntu-24.10.pkr.hcl | 1 + 12 files changed, 24 insertions(+) diff --git a/alpine-3.18.pkr.hcl b/alpine-3.18.pkr.hcl index 9127e49..00e4cb5 100644 --- a/alpine-3.18.pkr.hcl +++ b/alpine-3.18.pkr.hcl @@ -68,6 +68,7 @@ build { "usermod -p '${bcrypt("vagrant")}' root", "echo 'permit nopass :vagrant' >/etc/doas.d/vagrant.conf", "rm -rf /var/cache/apk/*", + "fstrim -av --quiet-unsupported", ] } diff --git a/alpine-3.19.pkr.hcl b/alpine-3.19.pkr.hcl index 28844cd..b9aa296 100644 --- a/alpine-3.19.pkr.hcl +++ b/alpine-3.19.pkr.hcl @@ -68,6 +68,7 @@ build { "usermod -p '${bcrypt("vagrant")}' root", "echo 'permit nopass :vagrant' >/etc/doas.d/vagrant.conf", "rm -rf /var/cache/apk/*", + "fstrim -av --quiet-unsupported", ] } diff --git a/alpine-3.20.pkr.hcl b/alpine-3.20.pkr.hcl index 04a84fc..dd98dff 100644 --- a/alpine-3.20.pkr.hcl +++ b/alpine-3.20.pkr.hcl @@ -68,6 +68,7 @@ build { "usermod -p '${bcrypt("vagrant")}' root", "echo 'permit nopass :vagrant' >/etc/doas.d/vagrant.conf", "rm -rf /var/cache/apk/*", + "fstrim -av --quiet-unsupported", ] } diff --git a/alpine-3.21.pkr.hcl b/alpine-3.21.pkr.hcl index 6732fa3..6d292d0 100644 --- a/alpine-3.21.pkr.hcl +++ b/alpine-3.21.pkr.hcl @@ -68,6 +68,7 @@ build { "usermod -p '${bcrypt("vagrant")}' root", "echo 'permit nopass :vagrant' >/etc/doas.d/vagrant.conf", "rm -rf /var/cache/apk/*", + "fstrim -av --quiet-unsupported", ] } diff --git a/debian-12.pkr.hcl b/debian-12.pkr.hcl index e8f4bcc..6154e5d 100644 --- a/debian-12.pkr.hcl +++ b/debian-12.pkr.hcl @@ -76,6 +76,7 @@ build { provisioner "shell" { inline = [ "apt-get clean -y", + "sudo fstrim -av --quiet-unsupported", ] } diff --git a/fedora.ks b/fedora.ks index cb2d165..596372e 100644 --- a/fedora.ks +++ b/fedora.ks @@ -34,4 +34,6 @@ sed -i -e "s/.*PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config sed -i -e "s/.*PasswordAuthentication.*/PasswordAuthentication yes/g" /etc/ssh/sshd_config dnf clean all -y + +fstrim -av --quiet-unsupported %end diff --git a/opensuse-leap-15.6.pkr.hcl b/opensuse-leap-15.6.pkr.hcl index ca4c947..b2ef7cb 100644 --- a/opensuse-leap-15.6.pkr.hcl +++ b/opensuse-leap-15.6.pkr.hcl @@ -33,6 +33,12 @@ build { "source.qemu.opensuseleap156" ] + provisioner "shell" { + inline = [ + "sudo fstrim -av --quiet-unsupported", + ] + } + post-processors { post-processor "vagrant" { vagrantfile_template = "Vagrantfile" diff --git a/opensuse-tumbleweed.pkr.hcl b/opensuse-tumbleweed.pkr.hcl index 90fb527..44d0b80 100644 --- a/opensuse-tumbleweed.pkr.hcl +++ b/opensuse-tumbleweed.pkr.hcl @@ -49,6 +49,12 @@ build { "source.qemu.opensusetumbleweed" ] + provisioner "shell" { + inline = [ + "sudo fstrim -av --quiet-unsupported", + ] + } + post-processors { post-processor "vagrant" { vagrantfile_template = "Vagrantfile" diff --git a/silverblue.ks b/silverblue.ks index 3d52537..03a2f3a 100644 --- a/silverblue.ks +++ b/silverblue.ks @@ -21,4 +21,6 @@ chmod 0440 /etc/sudoers.d/vagrant sed -i -e "s/.*PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config sed -i -e "s/.*PasswordAuthentication.*/PasswordAuthentication yes/g" /etc/ssh/sshd_config + +fstrim -av --quiet-unsupported %end diff --git a/ubuntu-22.04.pkr.hcl b/ubuntu-22.04.pkr.hcl index 5d58b8d..4b7b61d 100644 --- a/ubuntu-22.04.pkr.hcl +++ b/ubuntu-22.04.pkr.hcl @@ -36,6 +36,7 @@ build { provisioner "shell" { inline = [ "sudo apt-get clean -y", + "sudo fstrim -av --quiet-unsupported", ] } diff --git a/ubuntu-24.04.pkr.hcl b/ubuntu-24.04.pkr.hcl index 1059b87..712d01a 100644 --- a/ubuntu-24.04.pkr.hcl +++ b/ubuntu-24.04.pkr.hcl @@ -36,6 +36,7 @@ build { provisioner "shell" { inline = [ "sudo apt-get clean -y", + "sudo fstrim -av --quiet-unsupported", ] } diff --git a/ubuntu-24.10.pkr.hcl b/ubuntu-24.10.pkr.hcl index 9683240..1cde089 100644 --- a/ubuntu-24.10.pkr.hcl +++ b/ubuntu-24.10.pkr.hcl @@ -36,6 +36,7 @@ build { provisioner "shell" { inline = [ "sudo apt-get clean -y", + "sudo fstrim -av --quiet-unsupported", ] }