Reduce lxc hdd size

BJ78945

Well-Known Member
Apr 15, 2015
75
16
48
Hello,

as I used openvz I had no problems with hdd space. I gave the vms more space than the host have but on the vms there were only a few files. After updating to lxc, the used space on the host is growing and growing but the vms are the same, no more data. I thing it could be the raw files. Logfiles from the vm were deleted but the raw files didn't shrink. So what can I do to shrink the raw files?
 
Yes, the approach in the serverfault article works, yet there could be simpler solutions:

Do not use RAW as container backend. I suppose you didn't use it on OpenVT either, so there is the change from your old to your new environment. only file storage uses the space that it really needs (in the long run), so maybe this is more suitable for you.
 
Hello,

as I used openvz I had no problems with hdd space. I gave the vms more space than the host have but on the vms there were only a few files. After updating to lxc, the used space on the host is growing and growing but the vms are the same, no more data. I thing it could be the raw files. Logfiles from the vm were deleted but the raw files didn't shrink. So what can I do to shrink the raw files?
It is so easy, but with downtime.

I have a mistake in my mind, so, correct size, step by step:
  • shutdown a CT.
  • edit /etc/pve/lxc/xxx.conf - with a new correct size.
  • Backup CT by gui
  • Delete CT
  • Restore CT from backup.
  • Profit!
before:
root@pve-mtce01:~# lvs
....
vm-5001-disk-1 pve Vwi-a-tz-- 105.00g lxc 2.30​

after:
root@pve-mtce01:~# lvs
....
vm-5001-disk-1 pve Vwi-aotz-- 4.00g lxc 3.43
 
thanks. I did it like VGusev2007 described. But I had a problem because I had an version installed were the /var/log directory wasn't saved in backup. But this is solved now and I also use another backup software so I could restore this directory.

At the moment I haven't used ZFS. I read that ECC RAM is recommend and I don't use ECC RAM. Another part is the high RAM usage.

Is it possible to switch to the openvz style without raw files? Will this be implementen in future?
 
At the moment I haven't used ZFS. I read that ECC RAM is recommend and I don't use ECC RAM. Another part is the high RAM usage.

That's an old myth. You should use ECC for everything, not only ZFS. Yet if you do not have ECC, then using ZFS is still better than using any other filesystem.

Is it possible to switch to the openvz style without raw files? Will this be implementen in future?

The only way I know is ZFS.
 
  • Like
Reactions: Tmanok
At the moment I haven't used ZFS. I read that ECC RAM is recommend and I don't use ECC RAM. Another part is the high RAM usage.
Just don't use ZFS. ZFS is still a technical preview. You need high RAM, and you can have a lot of problem with zfs.
 
ZFS has superior code quality than btrfs, and btrfs is already used in SuSE. You have to learn a lot of new things with ZFS, but it's worth it.
 
  • Like
Reactions: Tmanok
ZFS has superior code quality than btrfs, and btrfs is already used in SuSE. You have to learn a lot of new things with ZFS, but it's worth it.
I have used zfs, it still has many bug. It still uses a separate ARC cache on linux and so on. lvm can reduce/extend too. lvm has a lvmcache. lvm doesn't use a lot of ram.
 
We used LVM for over 10 years and switched completely to ZFS for all datastores: Real snapshots, send/receive (saves us days of backup transfers), transparent compression, deduplication and real error detection.
 
  • Like
Reactions: Tmanok
I will gladly confirm that solution
by VGusev2007, post: 142540
worked for me flawlessly.
(Proxmox 5.4-8, tested on 2 LXC on different storage solution - local-lvm and mounted RAID card)
 
Hey not to wake up a dead thread, but has there been any movement on shrinking disks via the GUI? Asking for convenience with large number of LXCs. Also the Wiki doesn't mention much about resizing for lxc, wondering if that will expand in the future.

Also in 2021 for anyone else reading this, ZFS is very mature on Linux now and highly recommended at least for the install (mirror array for local and local-zfs).
 

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!