2

My computer is running Debian 13. During installation of Debian 13, I chose to have full disk encryption and use the BTRFS filesystem (instead of the default ext4 filesystem). The Debian installer automatically configured about 32 GB of swap. I have been using this Debian 13 installation for a few weeks, but I now want to reduce the swap from 32 GB to 8 GB without reinstalling Debian. How can I do that?

Relevant information:

$ lsblk                                                                                               
NAME                  MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINTS
nvme0n1               259:0    0  1.8T  0 disk  
├─nvme0n1p1           259:1    0  976M  0 part  /boot/efi
├─nvme0n1p2           259:2    0  977M  0 part  /boot
└─nvme0n1p3           259:3    0  1.8T  0 part  
  └─nvme0n1p3_crypt   254:0    0  1.8T  0 crypt 
    ├─mypc--vg-root   254:1    0  1.8T  0 lvm   /
    └─mypc--vg-swap_1 254:2    0 31.1G  0 lvm   [SWAP]
$ cat /etc/fstab
# /boot was on /dev/nvme0n1p2 during installation
UUID=c68e63e2-2183-4cf3-9503-58fd5e6379b0  /boot  ext4  defaults  0  2
# /boot/efi was on /dev/nvme0n1p1 during installation
UUID=5D60-ADDA               /boot/efi  vfat   umask=0077  0  1
/dev/mapper/mypc--vg-root    /          btrfs  defaults,compress=zstd:1,subvol=@rootfs  0  0
/dev/mapper/mypc--vg-swap_1  none       swap   sw  0  0
1
  • I answered not noticing lvm storage and so deleted my reply. Sorry everyone. Commented Oct 29 at 6:49

1 Answer 1

3

The easiest here is simply to (and all this can be done live, no risk to your data or need to reboot)

  1. turn swap off (as thecarpy says, sudo swapoff /dev/mapper/mypc--vg-swap_1)
  2. remove the swap volume (it's an LVM volume, not a partition, so this is all extremly much easier); sudo lvremove mypc-vg swap_1
  3. enlarge the size of your storage volume group by the amount you want: sudo lvresize -L +24G -r mypc-vg root. This enlarges the volume, and also runs the commands necessary to make the btrfs file system use the new available space
  4. recreate a smaller swap volume to use all of the remaining space: sudo lvcreate -l 100%FREE mypc-vg swap1 && sudo mkswap /dev/mapper/mypc--vg-swap_1
  5. finally, reactivate the swap: sudo swapon /dev/mapper/mypc--vg-swap_1

Real talk, though.
Your plan is nonsense. You have 1.8 TB space in your root partition. Adding 24 GB is just 1.33% of that. Don't do that. You're winning nothing, and the debian installer probably made the swap partition so large for good reason: it's where Linux stores the state of your computer when you send it to hibernation.

If, one day, you find your 1.8 TB root btrfs pool is full, and you really need these additional few GB (this won't happen. If that happens, chances are, the few extra GB is not what is going to help you!), then do that resizing then. You win exactly nothing doing it now, before there's any reason for it.

1
  • 1
    +1. "do that resizing then" - it's probably not worth it even then unless the OP either replaces the 1.8TB NVME with a larger one or adds a second NVME to the VG. Unless they have a huge music or video collection or need to edit huge video files, it'll take years to fill up 1.8 TB and by that time, 4T or 8T or larger NVME drives will be reasonably priced. Personally, I'd add a second drive anyway for redundancy because I use at least RAID-1 or equivalent everywhere - it costs me double for storage, but is worth it for the time and not-yet-backed-up files it saves me in case of drive failure. Commented Oct 26 at 6:02

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.