USB passthrough to openvz container

deranjer

Active Member
Dec 28, 2010
50
1
28
How do I passthrough a usb HDD (ntfs) to a container?
I manage to get it to show up in the container under fdisk using the following command:

Code:
#vzctl set 1000 --devnode /dev/sdc1:rw --save

However, I can't mount it:

Code:
#ntfsmount /dev/sdc1 /mnt/Media -o force
fuse: failed to open /dev/fuse: Operation not permitted
fuse_mount failed.
Unmounting /dev/sdc1 (Media)

Code:
#modprobe fuse
WARNING: All config files need .conf: /etc/modprobe.d/00local, it will be ignored in a future release.
FATAL: Could not load /lib/modules/2.6.32-4-pve/modules.dep: No such file or directory

Code:
#ls /lib/modules
2.6.26-2-686  2.6.32-3-686

If I copy (I know.. it won't work lol.. I was trying anything) it...
Code:
#cp -r 2.6.32-3-686 2.6.32-4-pve

Code:
#modprobe fuse
FATAL: Error inserting fuse (/lib/modules/2.6.32-4-pve/kernel/fs/fuse/fuse.ko): Invalid module format

How do I get USB passthrough working?
 
It is a very simple solution to mount it on the Container.
Step 1. on the proxmox server check where is /dev/sdc1 is mounted. For example is it mounted on /test1
Get in to the directory
cd /test1

Create another directory, say test2
So now the directory structure is /test1/test2 on Proxmox server (Where /dev/sda1 is mounted on /test1)

Now create the same directory (test2) at /var/lib/vz/root/1000/test2

Once this is done. Issue this command

mount --bind /sdc1/test2 /var/lib/vz/root/1000/test2

That is it. Now it will show up in the container by running df -h. However, during the container stop vzctl unmounts that bind mount, so you have to mount it again when you start the container for the next time.

To make the mount point persistent you need to do the following (Though, I have not tested persistant mount)
Put a mount script in OpenVZ configuration directory (/etc/vz/conf/) with the name CTID.mount (where CTID is container ID, like 777). This script will be executed every time you run vzctl mount or vzctl start for a particular container. If you need to the same for all containers, use the global mount script named vps.mount.
From any mount script you can use the following environment variables:

  • ${VEID} -- container ID (like 777).
  • ${VE_CONFFILE} -- container configuration file (like /etc/vz/conf/777.conf)
Now, in order to get the value of VE_ROOT you need to source both the global OpenVZ configuration file, and then the container configuration file, in that particular order. This is the same way vzctl uses to determine VE_ROOT.
Check this link:
http://wiki.openvz.org/Bind_mounts
 
Last edited:
Thank you for the reply, I did end up using this method. It works well for the most part, but sometimes (no apparent reason) it suddenly becomes unmounted. The only way I have found to fix this is an entire server reboot, which brings all of my containers down, but at least it does work for the most part.
 

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!