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

josh.greyz

New Member
Mar 8, 2022
7
0
1
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
Thank you @l.wagner for that as after I reversed the order it all worked fine.

Also thank you @fabian as I'm not familiar with pct. I will try that tool next time, as running it since I already started the other operations gave me the following:

# pct resize 999 rootfs 200G
disk is already at specified size
 
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.
 

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!