How to add hard drive attached to host to an LXC

Smoochii

New Member
Jun 2, 2024
7
0
1
Hello,

I have a hard drive that is attached to the host that I've been using for backups. I mounted it with fstab to be at /home/backups on the host. I then created a Directory on the node to be able to store backups in. Now I created an LXC with turnkey to add an SMB share and what I want to do now is give this hard drive to the LXC so that I can use it for file share. I want to be able to create directories for specific things (documents, videos, etc...) but I also want to have a folder for backups since this directory will now be gone for proxmox to use. Is it possible for the LXC to use the drive and then proxmox load it is a samba share to use for backups? Is this advised?

Basically I just want to allow the drive to be accessible to both the host and the LXC (the LXC is really for my iPad and laptop to access) if possible.

The file structure will probably be something like

drive
|-- Storage
|-- Backups
|-- Documents
|-- Videos
 
You can mount the /home/backups directory from the host into the container with a bind mount.
Code:
pct set <container_id> -mp0 /home/backup,mp=/path/in/container

However, if you are using an unprivileged container, you will run into the problem that all files show up as being owned by nobody in the container. To fix this, you need to configure UID/GID mapping as explained here:
https://pve.proxmox.com/wiki/Unprivileged_LXC_containers#Using_local_directory_bind_mount_points
 
Last edited:
Hi Filip -- I am trying to do something similar, but instead of a separate hard drive or a network share, I want to store database files from influxdb in my /mnt/glusterfs filesystem on the host, to take advantage of the zfs raid + HA. I'd rather not size the LXC to how large the database might grow, so just using a directory under /mnt/glusterfs seemed like a way to go. I've tried suggestions from a number of sources, and in each case I'm not able to get permission to do anything in the mount within the LXC. I'd like to try the approach in the thread you linked above, but frankly the way it jumps into the UID mapping is extremely hard for me to comprehend. Could I ask for an example of how to do that for my (I think) simple case where I want the user influxdb with UID 999 and GID 996 in the LXC to be able to read and write into a glusterfs directory on the host? (Sorry to hijack this thread, but regardless of whether the mount is a network share, a hard disk, or an existing file store, the confusion seems to be with the UID mapping, so maybe this can help.) Thanks, Johh
 

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!