VDO has been mentioned here, but with no specifics. So I went ahead and fully tested the case and here I explain the experience and how to set it up. -------- VDO is an LVM feature providing compression and deduplication. It is supported since Linux kernel 6.9 *(for older versions there was a KVDO out-of-tree module)*. Depending on your distro you may also need to install vdo utils *(if it's necessary you'll get an error from `lvcreate`)*. Case: I've recently been travelling with my old laptop which is both low on RAM and has very slow HDD ST1000LM024 with a [passmark rating of 658](https://www.harddrivebenchmark.net/hdd.php?hdd=Seagate%20ST1000LM024&id=362). Running Firefox and Qutebrowser simultaneously and opening an HD video in one of them quickly results in `/proc/pressure/io` peaking to ≈90% most of the time and freezes. Launching browsers with `ionice -c3` kind of helped, but constant swapping was another source of lags. Solution: after having set up swap over VDO compressed device the system responsiveness improved considerably. Unfortunately Idk offhand how to measure it more scientifically, but based on my experience freezes upon switching virtual desktops were almost gone. 1. `pvcreate /dev/sdXn`: mark device for LVM to use 2. `vgcreate vg /dev/sdXn`: create an LVM pool named `vg` 3. `lvcreate --type vdo -L 5G -V 3G --compression y --deduplication n vg/lv_vdo`: create a VDO volume of size 5G that will be seen as a 3G block device. Considerable size here will be taken for VDO internal purposes, so wasn't it for `-V`, I was getting 2G-sized block device on these sizes. You might want a different size or even drop `-V` completely. I just kind of presumed that I will get compression of at least 33%, so replacing 2G to 3G should be more-or-less safe, but I may be wrong. We also disable deduplication here, as it has no use for our case *(moreover, deduplication typically takes additional memory which we just don't have)*. Resulting block device should appear at `/dev/vg/lvol0`. 4. `mkswap /dev/vg/lvol0`: create swap partition over the compressed device 5. *(optional)* get swap UUID with `lsblk -fQ 'FSTYPE=="swap"'`, and then write a line in `/etc/fstab` so swap is getting used on boot: ```haskell UUID=<INSERT_SWAP_UUID> none swap defaults 0 0 ``` On Archlinux at least I didn't need any other settings. In particular, since swap is loaded after `/` is mounted, nothing has to be added to initramfs. # Misc * Current usage may be monitored with command `vdostats --human-readable`. If by any chance the `Use%` column would get to 100%, writing to the device would result in `ENOSPC`. It should be noted though that depending on the pool and volume sizes, the `Used` column may get increased once `Use%` is ≈85-87%. If you use large enough partitions you shouldn't need to monitor that though. * Upon creation noticeable size is taken by VDO for internal use, so make sure to create SWAP partition of a larger size than what you'd want to use for swap.