Yet Another mounting a USB3 hard drive for guest use question.

ltgcc

New Member
Dec 28, 2021
5
1
3
62
I am having conceptual trouble with mounting a usb hard drive for use with
an LXC guest.

Version is:

~$ pveversion
pve-manager/7.1-8/5b267f33 (running kernel: 5.13.19-2-pve)

The main references I'm using are:

https://forum.proxmox.com/threads/mount-external-hdd-in-lxc-container.50897/
https://pve.proxmox.com/wiki/Linux_Container#_bind_mount_points
https://pve.proxmox.com/wiki/Unprivileged_LXC_containers

I have installed userbindmount (no one ever actually said to, I just guessed it was necessary)

~$ apt search bindmount
Sorting... Done
Full Text Search... Done
libuserbindmount-dev/stable,now 0.1-2+b1 amd64 [installed]
bind-mount in user namespaces (devel)

libuserbindmount0/stable,now 0.1-2+b1 amd64 [installed,automatic]
bind-mount in user namespaces (library)

userbindmount/stable,now 0.1-2+b1 amd64 [installed]
bind-mount in user namespaces (command)

My first set of questions:

* Is the host-side location /mnt/bindmounts/shared that is
always referred to in the pages above a 'magic' location that
has special properties or otherwise must have that name? or
is it simply a normal directory structure and everyone has
agreed to use that name?

* Is the host-side location /mnt/bindmounts/shared created
automagically some way? Maybe by simply installing
userbindmount (I'm guessing 'no')? Or calling something? Or by enabling and starting
some systemctl something? or...what? Or does the admin have to create it
and manually do the permissions and acls?

* Do I (manually or fstab) mount the usb drive directly to /mnt/bindmounts/shared? e.g.
something like

# mount LABEL=USB2TB /mnt/bindmounts/shared

or do I (manually) mount it to 'somewhere else' say /media/camthingy/USB32 and then bind mount it
to /mnt/bindmounts/shared, e.g.

# mount -o bind /media/camthingy/USB32 /mnt/bindmounts/shared

I think that's enough questions to start with 8).

Thanks very much in advance.
 

oguz

Proxmox Retired Staff
Retired Staff
Nov 19, 2018
5,207
680
118
hi,

* Is the host-side location /mnt/bindmounts/shared that is
always referred to in the pages above a 'magic' location that
has special properties or otherwise must have that name? or
is it simply a normal directory structure and everyone has
agreed to use that name?
it's just an example :) you can pick any path you like.

* Is the host-side location /mnt/bindmounts/shared created
automagically some way? Maybe by simply installing
userbindmount (I'm guessing 'no')? Or calling something? Or by enabling and starting
some systemctl something? or...what? Or does the admin have to create it
and manually do the permissions and acls?
no. you create the path manually. the container doesn't know anything about it.

I have installed userbindmount (no one ever actually said to, I just guessed it was necessary)
no need for it.

* Do I (manually or fstab) mount the usb drive directly to /mnt/bindmounts/shared? e.g.
something like

# mount LABEL=USB2TB /mnt/bindmounts/shared

or do I (manually) mount it to 'somewhere else' say /media/camthingy/USB32 and then bind mount it
to /mnt/bindmounts/shared, e.g.

# mount -o bind /media/camthingy/USB32 /mnt/bindmounts/shared

I think that's enough questions to start with 8).
mounting the USB on your host should be enough, then you need to edit your container config to point to the mounted directory.

to make it clear, an example.
let's say you want to bindmount the USB stick from your host to your container.
Code:
mkdir -p /mnt/myusb # create directory for the usb mount on host
mount /dev/sdc /mnt/myusb # replace /dev/sdc with the partition you want to mount
pct set 100 -mp0 /mnt/myusb,mp=/myusb
pct reboot 100

that will create the /myusb folder inside the container, which contains the usb device contents.

hopefully this clears some doubts/questions!
 

ltgcc

New Member
Dec 28, 2021
5
1
3
62
Thank you. this clarifies a lot. I will play with it this weekend.

Best,
 
  • Like
Reactions: oguz

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 your own in 60 seconds.

Buy now!