Proxmox 4 / LXC: Chroot instead of raw images?

Discussion in 'Proxmox VE: Installation and configuration' started by Tozz, Jul 16, 2015.

  1. Tozz

    Tozz New Member

    Joined:
    Mar 11, 2012
    Messages:
    26
    Likes Received:
    0
    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?
     
  2. Tozz

    Tozz New Member

    Joined:
    Mar 11, 2012
    Messages:
    26
    Likes Received:
    0
    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?
     
    #2 Tozz, Jul 16, 2015
    Last edited: Jul 16, 2015
  3. dietmar

    dietmar Proxmox Staff Member
    Staff Member

    Joined:
    Apr 28, 2005
    Messages:
    16,384
    Likes Received:
    292
    Just set disk size to 0 when you create a CT.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Tozz

    Tozz New Member

    Joined:
    Mar 11, 2012
    Messages:
    26
    Likes Received:
    0
    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.
     
  5. dietmar

    dietmar Proxmox Staff Member
    Staff Member

    Joined:
    Apr 28, 2005
    Messages:
    16,384
    Likes Received:
    292
    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).
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. constalink

    constalink New Member

    Joined:
    Oct 14, 2015
    Messages:
    3
    Likes Received:
    0
    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.
     
  7. ianux

    ianux New Member

    Joined:
    Oct 13, 2015
    Messages:
    19
    Likes Received:
    0
    mount -o loop /your/image.raw /your/mount/point/
     
  8. cronner

    cronner New Member

    Joined:
    Aug 4, 2012
    Messages:
    10
    Likes Received:
    0
    not possible?
    p4.JPG
     
  9. alchemycs

    alchemycs Member

    Joined:
    Dec 6, 2011
    Messages:
    30
    Likes Received:
    6
    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).



     
    alex3137 likes this.
  10. constalink

    constalink New Member

    Joined:
    Oct 14, 2015
    Messages:
    3
    Likes Received:
    0
    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
     
  11. constalink

    constalink New Member

    Joined:
    Oct 14, 2015
    Messages:
    3
    Likes Received:
    0
    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
     
    #11 constalink, Nov 14, 2015
    Last edited: Nov 14, 2015
  12. SamTzu

    SamTzu Member

    Joined:
    Mar 27, 2009
    Messages:
    356
    Likes Received:
    6
    Yoohoo. I was looking for this.
    Thx.
     
  13. SamTzu

    SamTzu Member

    Joined:
    Mar 27, 2009
    Messages:
    356
    Likes Received:
    6
  14. modulistic

    modulistic New Member

    Joined:
    Jan 24, 2016
    Messages:
    1
    Likes Received:
    0
    Hey dietmar, is this setup supported by Proxmox subscriptions? I'd like you to confirm as it seems [by what has been said in this thread] it is not available on the user interface.
     
  15. groemer05

    groemer05 New Member

    Joined:
    Mar 23, 2015
    Messages:
    4
    Likes Received:
    0
    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
     
  16. dietmar

    dietmar Proxmox Staff Member
    Staff Member

    Joined:
    Apr 28, 2005
    Messages:
    16,384
    Likes Received:
    292
    The suggested way is to use ZFS.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  17. Fixweb

    Fixweb New Member

    Joined:
    Mar 10, 2016
    Messages:
    5
    Likes Received:
    2
    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
     

    Attached Files:

  18. dietmar

    dietmar Proxmox Staff Member
    Staff Member

    Joined:
    Apr 28, 2005
    Messages:
    16,384
    Likes Received:
    292
    The 'simfs' module is not available on newer kernels.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  19. Fixweb

    Fixweb New Member

    Joined:
    Mar 10, 2016
    Messages:
    5
    Likes Received:
    2
    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 ....
     
  20. dietmar

    dietmar Proxmox Staff Member
    Staff Member

    Joined:
    Apr 28, 2005
    Messages:
    16,384
    Likes Received:
    292
    No, nobody is working on that. Why not use ZFS?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice