Every guide presents disabling swap permanently as simply commenting out the corresponding line in
/etc/fstab to prevent swap from mounting on reboot; however, that does not work in Debian 11.
sudo swapoff -a works perfectly, but doesn't persist across reboots.
Example fstab File, with line commented out:
# /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # systemd generates mount units based on this file, see systemd.mount(5). # Please run 'systemctl daemon-reload' after making changes here. # # <file system> <mount point> <type> <options> <dump> <pass> # / was on /dev/sda2 during installation UUID=6b762cb8-b92b-489a-98cf-2bf200e3c4ae / ext4 errors=remount-ro 0 1 # /boot/efi was on /dev/sda1 during installation UUID=4847-3887 /boot/efi vfat umask=0077 0 1 # swap was on /dev/sda3 during installation # UUID=b9aeb506-ad7d-488d-b2b9-7c68dff21906 none swap sw 0 0 /dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
After turning off swap manually:
sudo swapoff -a
the Swap Partition is still mounted but is no longer listed as a swap partition. Swap is successfully disabled:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 127G 0 disk ├─sda1 8:1 0 512M 0 part /boot/efi ├─sda2 8:2 0 125.5G 0 part / └─sda3 8:3 0 976M 0 part sr0 11:0 1 1024M 0 rom
After editing fstab file, running
sudo systemctl daemon-reload and performing a system reboot, swap is still there
lsblk -o +PARTTYPE
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT PARTTYPE sda 8:0 0 127G 0 disk ├─sda1 8:1 0 512M 0 part /boot/efi c12a7328-f81f-11d2-ba4b-00a0c93ec93b ├─sda2 8:2 0 125.5G 0 part / 0fc63daf-8483-4772-8e79-3d69d8477de4 └─sda3 8:3 0 976M 0 part [SWAP] 0657fd6d-a4ab-43c4-84e5-0933c84b4f4f sr0 11:0 1 1024M 0 rom
Clearly there's still a step missing.