Resizing disk for guest in KVM

I would like to increase the size of my KVM guest (Kicksecure) and for some to me obscure reason I am not able to. It would be easier and faster to do a fresh install (which I will likely do anyway later) but I like to understand the why.

I’m new to it, here is what I have done so far.
Let’s begin with

\[user \~\]% lsblk
NAME                                          MAJ:MIN RM SIZE RO TYPE  MOUNTPOINTS
vda                                           253:0    0  50G  0 disk
├─vda1                                        253:1    0   4G  0 part  /boot
└─vda2                                        253:2    0  46G  0 part
└─luks-1ed83f00-4659-4ef8-812a-3abd18f4d7d9 254:0    0  46G  0 crypt /
 \[user \~\]% df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/dm-0      ext4       16G  6,1G  8,8G  42% /
devtmpfs       devtmpfs  4,0M     0  4,0M   0% /dev
tmpfs          tmpfs     7,2G  6,3M  7,2G   1% /dev/shm
tmpfs          tmpfs     2,9G  1,9M  2,9G   1% /run
tmpfs          tmpfs     1,0M     0  1,0M   0% /run/credentials/systemd-cryptsetup@luks\\x2d1ed83f00\\x2d4659\\x2d4ef8\\x2d812a\\x2d3abd18f4d7d9.service
tmpfs          tmpfs     5,0M     0  5,0M   0% /run/lock
tmpfs          tmpfs     7,2G  188K  7,2G   1% /tmp
/dev/vda1      ext4      3,9G   42M  3,7G   2% /boot
shared         virtiofs  7,3T  4,5T  2,9T  62% /mnt/shared
tmpfs          tmpfs     1,5G  140K  1,5G   1% /run/user/1000
tmpfs          tmpfs     1,0M     0  1,0M   0% /run/credentials/getty@tty1.service
tmpfs          tmpfs     1,0M     0  1,0M   0% /run/credentials/systemd-journald.service

As you can see I already succeeded at, I guess, one stage of the process (done with qemu-img resize) by resizing the virtual size /dev/vda it was 20G now is 50G (done with fdisk). My first target was /dev/dm-0 but for the reasons below my next possible choice went to /dev/vda.

Fine. But that should be the VM’s Physical Volume, now I have to resize the Logical Volume, wrap the FS around the new size.
Since none of sudo lvdisplay & sudo vgdisplay showed anything I could only try with dm-0 which is what I see in df -Th and that shows still 16G.
`
I tried first with

sudo resize2fs /dev/dm-0 
resize2fs 1.47.2 (1-Jan-2025)
open: Device or resource busy while opening /dev/dm-0
zsh: exit 1     sudo resize2fs /dev/dm-0

Then I thought maybe I needed to

[user ~]% fdisk /dev/dm-0 

Welcome to fdisk (util-linux 2.41).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

fdisk: cannot open /dev/dm-0: Permission denied
zsh: exit 1     fdisk /dev/dm-0
[user ~]% sudo fdisk /dev/dm-0

Welcome to fdisk (util-linux 2.41).                                                                                                                                                                               
Changes will remain in memory only, until you decide to write them.                                                                                                                                               
Be careful before using the write command.

fdisk: cannot open /dev/dm-0: Device or resource busy
zsh: exit 1     sudo fdisk /dev/dm-0
[user ~]% sudo dmsetup info /dev/dm-0
Name:              luks-1ed83f00-4659-4ef8-812a-3abd18f4d7d9
State:             ACTIVE
Read Ahead:        256
Tables present:    LIVE
Open count:        1
Event number:      0
Major, minor:      254, 0
Number of targets: 1
UUID: CRYPT-LUKS2-1ed83f0046594ef8812a3abd18f4d7d9-luks-1ed83f00-4659-4ef8-812a-3abd18f4d7d9

After more research

[user ~]% sudo lvextend -L +100%FREE /dev/dm-0
  Can't parse size argument.
  Invalid argument for --size: +100%FREE
  Error during parsing of command line.
zsh: exit 3     sudo lvextend -L +100%FREE /dev/dm-0

sudo lvextend -L +30 /dev/dm-0
  Volume group "dm-0" not found
  Cannot process volume group dm-0
zsh: exit 5     sudo lvextend -L +30 /dev/dm-0

Like I said vgs and lvs don’t show a thing.
And to top it all off

[user ~]% sudo lsof /dev/dm-0
lsof: WARNING: can't stat() fuse.portal file system /run/user/1000/doc
      Output information may be incomplete.
zsh: exit 1     sudo lsof /dev/dm-0
[user ~]% sudo fuser -v /dev/dm-0
zsh: exit 1     sudo fuser -v /dev/dm-0
[user ~]% sudo unmount -f /dev/dm-0
sudo: unmount: command not found
zsh: exit 1     sudo unmount -f /dev/dm-0
[user ~]% sudo umount -l /dev/dm-0
_zsh_highlight_main__precmd_hook:4: permission denied: /dev/null 

Any Idea what to do next?

A couple of things:

  • You’re probably running into problems with resizing things because of the kernel parameter bdev_allow_write_mounted=0 in the kernel command line. Try booting without that kernel parameter and see if things start working.
  • Are you sure that /dev/dm-0 is an LVM device? Kicksecure doesn’t support LVM by default, and “plain” LUKS volumes on top of partitions also show up as device-mapper devices, so you may be using the wrong tools (unless this is a distribution-morphed LVM install of Debian).
1 Like

It is a freshly download Kicksecure-LXQt-18.1.4.2.Intel_AMD64.iso. I just got rid of sysmaint but that should’t affect any of the avobe.

No such kernel parameter in /etc/default/grub. I tried to add it with value 1 but that didn’t change the state of things.

Good question.

Yes, I have a feeling it has something to do with LUKS

Still, how do I resize it? Should I remove LUKS, resize it and encrypt it back again?