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=...
--size NNN
option. – user68186 Jun 23 '22 at 21:42sudo cryptsetup resize cryptswap1
. I left the--size
option out, as I wanted to use all of it. Then I usedsudo mkswap /dev/mapper/cryptswap1
command to initialize the swap partition. Without these the swap size didn't change. – user68186 Jul 14 '22 at 15:39cryptsetup resize
... – goulashsoup Jul 14 '22 at 16:28mkswap
part to the answer. – goulashsoup Jan 01 '23 at 20:44