how to increase the size of proxmox LXC container???

josh.greyz

Member
Mar 8, 2022
7
3
8
44
I have searched the forum, and have found a very similar post for reducing the size of LXC containers on Proxmox, but I want to do the opposite & increase the LXC container size. I will explain what I have done so far and explain the issue I'm having here.

I'm trying to increase the size of a 170GB LXC container to be 200GB in size. I have done the following so far:

List the containers:
pct list

Stop the particular container you want to increase:
pct stop 999

Find out it's path on the node:
lvdisplay | grep "LV Path\|LV Size"

For good measure one can run a file system check:
e2fsck -fy /dev/pve/vm-999-disk-0

Increase the file system:
resize2fs /dev/pve/vm-999-disk-0 200G

Increase the local volume using lvresize
lvresize --size 200G volume_group/logical_volume

Edit the container's conf, look for the rootfs line and change accordingly:
nano /etc/pve/lxc/999.conf
rootfs: local-lvm:vm-999-disk-0,size=170G >> rootfs: local-lvm:vm-999-disk-0,size=200G

Start it:
pct start 999

Enter it and check the new size:
pct enter 999
df -h

Unfortunately, I still do not see the new size reflected within the actual LXC. The commands lvdisplay, lvs, and lsblk all show this LXC container to now be 200GB in size. What do I need to run inside the container or on the proxmox-VE shell to expand it to the 200GB space which was allocated? Thanks for any help with this as I'm stumped what else needs to be done.
 
Hello,

the order of your steps is wrong. First increase the size of the logical volume, then resize the filesystem. Otherwise, resize2fs fails with the following message for me:

Code:
resize2fs 1.46.5 (30-Dec-2021)
The containing partition (or device) is only 2097152 (4k) blocks.
You requested a new size of 52428800 blocks.
 
  • Like
Reactions: josh.greyz
because you already resized it ;) pct resize does both the volume/image file and, if necessary, file system resize in one action, you just need to specify either the amount of growth or the new (bigger) size.
 
For everyone, this is output from resize a CT online.

Bash:
root@pve1:~# pct resize 109 rootfs 3G
  Size of logical volume pve/vm-109-disk-0 changed from 2.00 GiB (512 extents) to 3.00 GiB (768 extents).
  Logical volume pve/vm-109-disk-0 successfully resized.
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/pve/vm-109-disk-0 is mounted on /tmp; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/pve/vm-109-disk-0 is now 786432 (4k) blocks long.
 
The pct resize command seemed to work for me with similar output (I increased an LXC from 8 to 15G), but in the summary view of the container it still displays the old size (8G), even after several restarts of the LXC and the host itself.

1731083950246.png

That is confusing, to say the least...
 
I figured out that this only works via the GUI, not in the shell. So only "Resources->Root Disk->Volume Action->Resize" does the trick for me.

However, now that I played around a bit with increasing, it is at 32G now but that's not what I intended and I cannot descrease it using "Resources->Root Disk->Volume Action->Resize". The GUI only allows to increase, not shrink it again :-(

Command line also refuses to shrink:
Code:
pct resize 101 rootfs 15G
unable to shrink disk size

What can I do?
 
I ended up making a backup of the container, pct destroy it and afterwards pct restore it using the backup, giving 15G as size. Seems to be the only way (at least that I could find).
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!