Resize LXC DISK on Proxmox

Drthrax74

New Member
Apr 22, 2019
16
0
1
31
Hello,
I have an 8 GB container which was created under LXC but I cannot resize it so that it is smaller. I want it to be 5 GB.

I also install Proxmox in EXT4 without ZFS support.






1587744507368.png


Code:
root@Proxmox:~# pct resize 105 rootfs 3G
unable to shrink disk size
 

Attachments

  • 1587744479653.png
    1587744479653.png
    116.9 KB · Views: 7

wolfgang

Proxmox Staff Member
Staff member
Oct 1, 2014
6,497
463
103
Hi,

shrinking a disk must be done manually.
You can loose your data so I recommand you to make a backup before.
first, shrink the fs in your container.
resize2fs will help you.
The next step would be to shrink the lv.
 

adrian_vg

Member
Mar 8, 2020
46
5
8
Sweden
Hi,

shrinking a disk must be done manually.
You can loose your data so I recommand you to make a backup before.
first, shrink the fs in your container.
resize2fs will help you.
The next step would be to shrink the lv.

Could you please elaborate on this, or better yet - point to some pve-documentation on decreasing disk size?
 

adrian_vg

Member
Mar 8, 2020
46
5
8
Sweden
Nevermind, found out how.
Documenting it here for posterity. :)

On your proxmox node, do this.

List the containers:
pct list

Stop the particular container you want to resize:
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

Resize the file system:
resize2fs /dev/pve/vm-999-disk-0 10G

Resize the local volume
lvreduce -L 10G /dev/pve/vm-999-disk-0

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=32G >> rootfs: local-lvm:vm-999-disk-0,size=10G

Start it:
pct start 999

Enter it and check the new size:
pct enter 999
df -h
 
  • Like
Reactions: oguz

Drthrax74

New Member
Apr 22, 2019
16
0
1
31
Hello,

First of all thank you for your good advice, It would be worth making scripts to do the actions in an automated way.
 
Last edited:

adrian_vg

Member
Mar 8, 2020
46
5
8
Sweden
Hello,

First of all thank you for your good advice, It would be worth making scripts to do the actions in an automated way.

From my personal point of view scripted disk reductions are iffy, as things may go wrong.
I prefer to do this manually and reviewing each step before I continue to the next step.

This is Dangerous Stuff(tm). :)
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE 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 your own in 60 seconds.

Buy now!