4

I just installed kubuntu 20.04 but the swap size is way too small (~1GB). I used the encrypted LVM setup for a whole disk. How can I increase the swap size, since there is no space left?

[edit]

I found out that there seems to be a bug report open that has not solved since reported: https://bugs.launchpad.net/ubuntu/+source/partman-auto/+bug/1767299

A clean instruction on how to work around this would be really helpful. Or having at least the option to set this up properly during installation - it's "just a parameter".

Erik
  • 41

2 Answers2

1

A clean instruction on how to work around this would be really helpful.

Exactly my thought when searching for this.


Decrease root and increase swap

This answer is based on Ubuntu 22.04 LTS

Copied my answer from Increase size of encrypted swap.

Here we decrease root -40G AND increase swap +40G:

# Boot Ubuntu Live/Flash/"Try Ubuntu" AND open terminal
# Run subsequent commands as superuser
sudo su
    # `sudo`    => Execute a command as another user.
    # `sudo su [user]` => Run a command with substitute user, default is root.

Encrypted device should NOT be unlocked

lsblk # => list block devices # └─sda6 => no crypt/`lvm``

# Unlock encrypted device
cryptsetup open /dev/sda6 crypt # Enter passphrase
    # `cryptsetup` => Manage dm-crypt + LUKS encrypted volumes.
    # `cryptsetup open <device> <name>` => Opens encrypted lv as <name>

# Get logical volume identifiers
lsblk
    # └─sda6                  8:6    0 464,6G  0 part
    #   └─sda6_crypt        253:0    0 464,5G  0 crypt
    #     ├─vgubuntu-root   253:1    0 463,6G  0 lvm   /
    #     └─vgubuntu-swap_1 253:2    0   980M  0 lvm   [SWAP]

# Shrink logical root volume AND filesystem
lvresize --verbose --resizefs -L -40G /dev/mapper/vgubuntu-root
    # `lvresize` <volume> => resize a logical volume
    #   --verbose  => Give more info.
    #   --resizefs => Resize filesystem AND LV with fsadm(8).
    #   -L         => Specifies the new size of the LV, 
    #                 +/- add/subtracts to/from current size, g|G is GiB.

# Check filesystem of logical root volume for errors
e2fsck -f /dev/mapper/vgubuntu-root
    # `e2fsck`<fs-path> => Check a Linux ext2/ext3/ext4 file system
    #   -f => Force checking even if the file system seems clean.

# Increase swapsize
lvresize --verbose -L +40G /dev/mapper/vgubuntu-swap_1

After rebooting, Ubuntu should start normally, swap should be adjusted size:

lslbk
    # └─sda6                  8:6    0 464,6G  0 part  
    #   └─sda6_crypt        253:0    0 464,5G  0 crypt 
    #     ├─vgubuntu-root   253:1    0 423,6G  0 lvm   /
    #     └─vgubuntu-swap_1 253:2    0    41G  0 lvm   [SWAP]

If the system monitor still only has the initial 1G it is necessary to rewrite the logical swap device:

swapon --show
    # NAME      TYPE      SIZE USED PRIO
    # /dev/dm-2 partition 976M   0B   -2

swapoff -v /dev/dm-2 # swapoff /dev/dm-2

mkswap /dev/dm-2 # mkswap: /dev/dm-2: warning: wiping old swap signature. # Setting up swapspace version 1, size = 41 GiB (43973079040 bytes) # no label, UUID=...

0

This question has been answered well here: Resize swap partition on Ubuntu 20.04 using encrypted LVM

I have verified the solution, which involved booting with the kubuntu live usb, unlocking the encrypted partition from the command line, and resizing the root and swap partitions easily, using the kde partition manager.

Bon Ryu
  • 105