Proxmox 4 / LXC: Chroot instead of raw images?

Tozz

Active Member
Mar 11, 2012
31
0
26
We recently installed a machine with Proxmox 4 to try the new LXC system. I have a question regarding storage.

With OpenVZ the filesystem of a container would be in /var/lib/vz/templates/<vmid>/. This was ideal for quick maintenance and backups. We could just backup the proxmox host instead of all the separate VMs.
With LXC there are raw disk images in /var/lib/vz/images/<vmid>/. Besides not being able to properly backup those images it also adds additional overhead (a filesystem on a filesystem).

Is it possible to use the OpenVZ chroot style storage instead of separate disk images with LXC? If so, how?
 
I did some additional research, and apparantly the default backingstore for LXC is "dir", what is basically the OpenVZ way instead of disk images. Proxmox seems to prefer "loop" type devices.
I would like to change this behaviour but did not find a way to do this yet.

I did try to update the storage ID 'local' and remove the flag 'Disk images' from this storage, but new containers are still created as disk images on storage ID 'local'. Perhaps this is a bug?
 
Last edited:
Just set disk size to 0 when you create a CT.

Thanks. That works like a charm. Only issue now is that the container doesn't have quota/diskspace limits.
Can this be fixed? I see a patch from 2009 for disk cgroups, but as far as I can tell that patch hasn't been merged into the kernel.

I dont think regular quota's can be used because the /var/lib/vz/private/<vmid> isn't mounted with bind as it does with OpenVZ.
 
Thanks. That works like a charm. Only issue now is that the container doesn't have quota/diskspace limits.
Can this be fixed?

AFAIK there is nothing like simfs for LXC, and that is one reason why we use raw images by default.

But you can easily make backups even with raw images (see vzdump code).
 
AFAIK there is nothing like simfs for LXC, and that is one reason why we use raw images by default.

But you can easily make backups even with raw images (see vzdump code).

Is there any way to access the file system in or mount the raw image?
I looked at the vzdump code and could't find anything along those lines.
 
From what I've seen, when you use ZFS as a backing store for the containers, the machine's image is mounted from the pool, and you can access it from the host node, as well as provide a fixed size. Here is df from my test host node:

Code:
[SIZE=2][FONT=lucida console][FONT=courier new]root@pm4zfs:~# df -h
Filesystem               Size  Used Avail Use% Mounted on
udev                      10M     0   10M   0% /dev
tmpfs                    1.5G  153M  1.4G  11% /run
rpool/ROOT/pve-1          58G  745M   57G   2% /
tmpfs                    3.2G   43M  3.1G   2% /dev/shm
tmpfs                    5.0M     0  5.0M   0% /run/lock
tmpfs                    3.2G     0  3.2G   0% /sys/fs/cgroup
rpool                     57G  128K   57G   1% /rpool
rpool/ROOT                57G  128K   57G   1% /rpool/ROOT
/dev/fuse                 30M   16K   30M   1% /etc/pve
cgmfs                    100K     0  100K   0% /run/cgmanager/fs
rpool/subvol-100-disk-1  8.0G  230M  7.8G   3% /rpool/subvol-100-disk-1[/FONT][/FONT][/SIZE]

The / filesystem from within the container looks like this:

Code:
[FONT=courier new][root@[FONT=courier new]cntr100[/FONT] ~]# df
[FONT=courier new] Filesystem               Size  Used Avail Use% Mounted on
rpool/subvol-100-disk-1  8.0G  230M  7.8G   3% /[/FONT][/FONT]

For me, it is important to be able to easily change the size of the container while it is running - that is do-able with zfs set refquota:

Code:
[FONT=courier new]zfs set refquota=16G rpool/subvol-100-disk-1[/FONT]

Now, from inside the container:
Code:
[FONT=courier new][root@cntr100 ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
rpool/subvol-100-disk-1   16G  230M   16G   2% /[/FONT]

You can lower it as well.
I'm excited about ZFS, but I've had some problems when I try it on some production hardware (but I'm sure that will get fixed).



 
  • Like
Reactions: alex3137
not possible?

The GUI doesn't allow 0 disk size. You have to create it using pct on the command line:

Grr... It won't let me post the code.... I get
Code:
You are not allowed to post any kinds of links, images or videos until you post a few times.

Guess I'll have to make a few more posts before I post the code.
Or perhaps someone is kind enough to post an example pct command
 
Example:
Code:
pct create 110 /var/lib/vz/template/cache/ubuntu-14.04-standard_14.04-1_amd64.tar.gz -hostname servername -password 'p@ssw0rd' [COLOR=#ff0000][B]-rootfs local:0[/B][/COLOR]

For all available options you can type:
Code:
man pct

But beware... I've already come across some major issues with creating containers this way.
For some reason, you can't su while inside the container.

Code:
pct start 110
pct enter 110
# Now inside the container
adduser test_user
# The new user has been added
su test_user
# Cannot execute /bin/bash: Permission denied
ls -l /bin/bash
# -rwxr-xr-x 1 root root 1021112 Oct  7  2014 /bin/bash

MySQL for example won't run properly because the system can't switch to the mysql user.
This is probably true with many different packages that need to run as a user other than root
 
Last edited:
Hello guys,

Same question:
I would like to use dir instead of the raw image as well. Is this possible in the webinterface with the subscription?

best regards Thomas
 
Hello everybody,

I know the suggested way is to use ZFS, but I would like to still use SIMFS (chroot directory) for my LXC containers.
Is there a way to do this ?

I read here to put "0" in disk size when we want to use SIMFS instead of raw file but its not working...

Last thing, If this functionnality is only available in command line, this will be implemented in the panel ?

thanks in advance
 

Attachments

  • Capture d’écran 2016-12-15 à 21.03.53.png
    Capture d’écran 2016-12-15 à 21.03.53.png
    31.3 KB · Views: 16
thank you dietmar for your quick response. Do you think it will be added in the future ? is there an equivalent ?
I know LVM is better, but from what I know, the only way to reduce a container space is to use the "lvreduce" command ....
 

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!