Mount A loop Device In An OpenVZ Container

  • 0

Mount A loop Device In An OpenVZ Container

Category : How-to

Get Social!

You can pass a loop device through to an OpenVZ container with the vzctl command. You’ll need to mount the loop device on your host, as there is no support within an OpenVZ container to mount the device within the container. This means that the source of the loop device will also need to be available on the guest.

Note: This has been disabled in the latest versions of vzctl.

The device will then be passed through to the container so that it can be used by the container.

Run the vzctl command with the Container ID and loop device name that you’d like to use.

For example, to pass loop0 through to Container ID 100 use:

  • 0

Bash Command to Check Container Disk Space in Proxmox/ OpenVZ

Get Social!

proxmox logo gradKeeping an eye on all of your containers disk space can be time consuming if done one by one. Luckily, the vzlist command gives us access to many of the data and counters associated with each container.

Running vzlist on it’s own will give a list of the currently running containers and a few extra columns of information such as IP address and hostname.

You might be thinking that the above command doesn’t show anything about containers which are currently turned off, or about disk space. You’d be right!

Adding the –all switch will include all containers, regardless of their running state.

To add the disk space information we add the –output switch followed by the column names we want to display. For disk space, the column name is helpfully named diskspace so the command will look like this:

We now see the disk space of all of our containers, but with a problem. We have no idea (although in this example we do because we only have one container) which container the disk space output is for. We need to add a few more columns to the –output switch such as ctid and hostname.  (see below for a complete list of output columns)

The last trick here is to add a sort using the –sort switch and the column name

Let’s put all that together, plus a spot of awk magic to get a nice disk full percentage that we can work with:


Complete list of vzlist column headings

You can get a complete list of vzlist column headings with the following command:


  • 1

Proxmox Error: (warning) Incorrect quota shutdown for id xxx recalculating disk usage

Category : How-to

Get Social!

openvz-logo-150px_new_3I came across this error today when trying to manually backup the container to create an OpenVZ container template.

It occurred, in my case, when trying to start the container VMID 600 after been playing around within it’s root folder from the host’s terminal. The following error was presented:

To fix the issue, we need to turn off the quota for the VMID and then back on again.

The output should look like below:

You then need to turn the quota back on, to ensure your container’s disks are restricted to the size you have set for it.

You should now be able to successfully start the container, error free!

  • 10

Move Proxmox Container to Different Storage

Get Social!

2015-03-05 00_18_04-Proxmox Virtual Environment storageA task often required when new storage is added or removed, and containers grow over time is to move a container onto another storage device.

The  Proxmox  Web GUI does not give us the ability to migrate a container from one storage device to another directly. To move a container onto different storage we have to take a backup of the container and restore it to the same ID with a different storage device specified. This can be time laborious when working with several containers.

The below script allows you to move an OpenVZ container from one storage device to another. The process requires that the container be stopped, which the script will handle.

Save the below script into a file called migrate.

Set execution permissions on the script:

The script has several parameters which are detailed below:

  • -d is specified if you would like the script to delete the temporary backup after the process has completed. Leave this out if you would like the backup tar file to be kept, just in case anything goes wrong.
  • -s is required to specify the name of the target storage. You can find this from the Proxmox Web GUI.
  • -c is required for the container ID to migrate.

In addition, the script contains the variable TMP. This will be the location of the backup tar created as part of the migration process and must contain enough space to store the content of the container being migrated. You can change this to suit your environment.

Example command:


  • 1

OpenVZ USB Passthrough in Proxmox

Get Social!

usb-logoUSB Passthrough is the concept of passing a USB device that is plugged into the host server to a guest. This post will detail how to make the USB device available in an OpenVZ container.

The first step is usually the easiest; take your USB device and plug it into your Proxmox host. Wait a few moments for it to be recognised and then run the below command to identify which bus the device is plugged into.

The below shows an example output of the command.

The device I’m after for this example is on Bus 002 Device 003 which I identified from the name. Yours will more than likely be different

Often the names of the devices mean little and you’ll then need to compare the  output of lsusb before and after plugging the device in. For example, run the below command with the device unplugged.

Then plug the device in and run the following command:

Finally compare the two command outputs and identify the difference:

Once you had identified the row in the output of lsusb it’s  time to make a note of the usb bus it’s attached to. As above, mine is 002:003, which are the details I’ll need in a moment.

The way Linux accesses most IO devices is through the /dev/ mounts, and USB devices are no different. You can navigate to the USB bus in /dev/bus/ by following the bus address.

As you can see, the above path starts with /dev/bus/usb/ and follows with the bus address in the lsusb command. We’ll need this to pass to our OpenVZ container in just a moment so make a note of it.

One final check we can do to make sure we have the correct bus address is to use the above path with lsusb -D to get a more detailed output of the device. This will usually contain a manufacture ID and other information that may help us identify the device we need. I’ll spare you the output, but an example is below:

The next step is to tell the OpenVZ container all about the USB devices bus location. Using vzctl set we can specify the OpenVZ container ID, USB device and access level.

Before continuing, make sure that the container is turned off.

The command to run on the turned off container is below. Make sure to substitute the bracketed values as follows:

  • [VMID] is the ID of the openVZ container that the USB device will be passed to.
  • [BUS_PATH] is the path to the USB device that we discovered earlier. Be sure to drop the /dev/ prefix.

For example:

And there it is, turn on the container and point your application to /dev/bus/usb/002/003 and you should be up and running.

  • 10

Create a Ubuntu 14.04 OpenVZ Template for Proxmox

Get Social!

proxmox logo gradThe latest Ubuntu long term support is now available, called Ubuntu 14.04.

There isn’t currently a template available over on OpenVZ however I’m sure that will be shortly rectified. In the meantime, however, you can use the below steps to create a 14.04 Ubuntu template for OpenVZ/ Proxmox. This template has only been lightly tested so please report any errors as you find them.

This template is BETA, please report any problems in the comments.

Vistit Downloads Page


You can download a pre-created VM from here directly, or you can create your own using the below notes.


Before continuing, this guide assumes that you already have an installation of Ubuntu up and running which you can SSH to. This could be either a KVM or physical machine.

We will use debootstrap to create the template so make sure it’s installed and install it if you haven’t already.

Use debootstrap to download and configure all the required packages to a temporary directory. For this example, we’ll use /tmp/deb.

Copy the below script into the tmp directory of the template root which has just been created. For this example you’ll need to copy the text into this path:

Make the script runnable which chmod.

Run the above script using the chroot command to set up the template.

The script will now run and set up the template using /tmp/deb/ as the templates root.

Once completed, create an archive of the template root device and install it on your OpenVZ/ Proxmox server.

Copy the /tmp/ubuntu-14.04-x86_64-initial1.tar.gz file to your cache directory of your Proxmox install and create your first Ubuntu 14.04 container!


Visit our advertisers


Visit our advertisers