From 82ee65e5aefdd16ab68c1fa4e3625a6421a118c1 Mon Sep 17 00:00:00 2001 From: Richard Laager Date: Sat, 30 Mar 2019 08:02:40 -0500 Subject: [PATCH] Ubuntu/Debian: Enable discard on swap There is no need to be keeping old swap data around. When Linux is done with some data (or all data at swapon time), it can issue a discard, which will cause ZFS to free those blocks. --- Debian-Stretch-Root-on-ZFS.md | 2 +- Ubuntu-18.04-Root-on-ZFS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Debian-Stretch-Root-on-ZFS.md b/Debian-Stretch-Root-on-ZFS.md index 8b51fc3..ca463e6 100644 --- a/Debian-Stretch-Root-on-ZFS.md +++ b/Debian-Stretch-Root-on-ZFS.md @@ -425,7 +425,7 @@ The compression algorithm is set to `zle` because it is the cheapest available a **Caution**: Always use long `/dev/zvol` aliases in configuration files. Never use a short `/dev/zdX` device name. # mkswap -f /dev/zvol/rpool/swap - # echo /dev/zvol/rpool/swap none swap defaults 0 0 >> /etc/fstab + # echo /dev/zvol/rpool/swap none swap discard 0 0 >> /etc/fstab 7.3 Enable the swap device: diff --git a/Ubuntu-18.04-Root-on-ZFS.md b/Ubuntu-18.04-Root-on-ZFS.md index 1a106b6..f1c8822 100644 --- a/Ubuntu-18.04-Root-on-ZFS.md +++ b/Ubuntu-18.04-Root-on-ZFS.md @@ -544,7 +544,7 @@ The compression algorithm is set to `zle` because it is the cheapest available a **Caution**: Always use long `/dev/zvol` aliases in configuration files. Never use a short `/dev/zdX` device name. # mkswap -f /dev/zvol/rpool/swap - # echo /dev/zvol/rpool/swap none swap defaults 0 0 >> /etc/fstab + # echo /dev/zvol/rpool/swap none swap discard 0 0 >> /etc/fstab # echo RESUME=none > /etc/initramfs-tools/conf.d/resume The `RESUME=none` is necessary to disable resuming from hibernation. This does not work, as the zvol is not present (because the pool has not yet been imported) at the time the resume script runs. If it is not disabled, the boot process hangs for 30 seconds waiting for the swap zvol to appear.