[SOLVED] Mount external HDD in LXC container

Florius

Well-Known Member
Jul 2, 2017
35
9
48
57
Hi,

I have an external HDD which I need to mount to a LXC container.
Simple question, how do I do this without losing data?

In the proxmox web interface I can add it as storage, but I'm afraid it will format the data..

Please let me know, thank you!
 
This is working easy with bindmount. First mount your Disk manual or in the fstab. After that you can add some bind.

Sorry to bother you, but it seems it was mounted as read-only somehow.
If I check the newly added disk in the container, it's owned by nobody:nogroup, and I am unable to make any changes.
The disk itself is fine, on the host I can see it as root:root and make/edit files.
I already tried setting the ro=0 option, but no luck...

Any idea what I did wrong?

EDIT: It was an unprivileged container. I made a backup, and created a new one which was privileged, and was able to read and write.
Not sure if this is the way it's supposed to, but it works.
 
Last edited:
  • Like
Reactions: fireon
If you have an unprivileged container. You must map the ID's. https://pve.proxmox.com/wiki/Unprivileged_LXC_containers

I'm also struggling with this... I've mounted internal host drives into my LXC containers for years with a simple pct set command, but this is the first time I've tried to mount an external USB drive and I've encountered the nobody:nogroup issue. So I'm trying to map the ID's but I'm having a hard time following the documentation...

First I add the bind mount to my external drive: pct set 1234 -mp0 /mnt/Lacie,mp=/mnt/Lacie,backup=0

But I'm scratching my head with the ID mapping part... My user inside the LXC container is root. When I edit my /etc/pve/lxc/1234.conf file, I'm not quite sure what to add there. The documentation's example is this:
lxc.idmap = u 0 100000 1005
lxc.idmap = g 0 100000 1005

And then on the host(?), adding root:1005:1 to both /etc/subuid and /etc/subgid

I've tried several permutations of IDs to try to make it work, but can't quite seem to figure it out. I know that the host adds 100000 to the container's UID/GID for separation/safety. But I guess I'm not quite grasping everything... The user on the host that owns the external drive and all files is root.

Any help would be appreciated! I may be crossing some safety issue here, trying to get the container to write to the drive as host's root... Many thanks in advance!

-John
 
I have the same understanding problem of the documentation. Could somebody give a working example? Something like I mount a HDD on the host in /mnt/myAwesomeHdd as user root (or is it better to mount it as a "lower" user?), and want to make it available for a user "hdduser" with the id 1000 in the container.
 
hai,

I have a question here, cause My ntfs hdd already mp on the CT but inside the CT , I cannot copy any file inside the hdd cause of FS problem. Is there any possibility I can copy any file?
Thankyou
 
hai,

I have a question here, cause My ntfs hdd already mp on the CT but inside the CT , I cannot copy any file inside the hdd cause of FS problem. Is there any possibility I can copy any file?
Thankyou
Hello @chocosabrinax2017 this thread is solved, please open a new thread with your question.

Thanks
 

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!