Proxmox bind mount for OpenVZ – mount storage in a container

  • 5

Proxmox bind mount for OpenVZ – mount storage in a container

Category : How-to

Get Social!

proxmox logo gradYou can allocate storage to an OpenVZ container during creation, when the container is offline and even when the container is active. The main problem with this is that it is not shared, and has to be on the same storage which the container was created on.

You can mount any folder which is available to the host operating system in any container. You can also mount the same storage in multiple containers.

Before you begin, make sure the storage is mounted and usable on the host file system. For this example, we are going to use a disk which is mounted on the host at /mnt/binaries.

On the host, locate where your OpenVZ container config files are stored. On a standard Proxmox installation, this is /etc/vz/conf/. 

Create a file with the naming convention [VMID].mount. This will be the file which is executed each time the container is started as part of the boot process. This example will assume the container is using VMID 270.

Add the below content to this file making the two changes; [HOST FOLDER] should be replace with the location on the host to use for storage in the container and [GUEST FOLDER] which will be the folder on the guest container where the storage will be available. The location on both the physical host and virtual guest must exist when the container is started. 

The below example makes /mnt/binaries on the host available at /mnt/vm_binaries on the guest.

To create multiple bind mounts, edit the below example.

If you have many mounts something more elegant could be created however, generally speaking, only a few mount points are required per guest meaning that this brutish script is perfectly adequate.

These settings will require a restart of your container as the scripts are only applied on container start up.


5 Comments

Amrac

3-Apr-2014 at 3:10 pm

Thanks, that was very useful :)

Marcin C.

8-Apr-2015 at 9:03 pm

That’s what I needed. Thanks for that. Very, very useful thing. Cheers!

Paul Mack

17-Jul-2015 at 12:49 am

What about backups? I noticed that these files are not include in the backup of the containers as well as the mount point contents.

    james.coyle

    17-Jul-2015 at 7:09 am

    That’s true – these files are not included in the backup, partly I suspect because they would no longer be portable and self contained as they rely on the underlying target to be available. As for backing up the content, you’d want to do this on whatever service holds the underlying data, rather than inside the container.

BigBen

29-Jan-2016 at 5:07 pm

Im Proxmox Version 4 funktioniert diese Methode leider nicht mehr.

Leave a Reply

Visit our advertisers


Search

Visit our advertisers