Proxmox + Nextcloud Turnkey on a USB External Hard Drive

vpnobrega

Member
Jan 17, 2021
17
3
8
36
Hello guys, i trying to get proxmox + nextcloud container (from Turnkey image) to host my nextcloud files on USB hard drive.

Let's begin:
1. I create a user id, a group id with value 2000 and add the new user to new group on pve host.
2. I do the samething on nextcloud container, so user id and group id will match.
3. I create a mount in /etc/fstab from my usb external drive (NTFS format) to a folder on my pve host.
UUID="XXXXXXXXXX" /mnt/nextcloud/ ntfs nls-utf8,umask-0222,uid-2000,gid-2000,rw 0 0

After reboot, at this point i already have the mount from USB External Hard Drive in pve host.

To mount the previous mount on container, i edited /etc/pve/lxc/XXXX.conf and added:
Code:
mp0: /mnt/nextcloud,mp=/mnt/nextcloud
lxc.idmap = u 0 100000 2000
lxc.idmap = g 0 100000 2000
lxc.idmap = u 2000 2000 1
lxc.idmap = g 2000 2000 1
lxc.idmap = u 2001 102001 63535
lxc.idmap = g 2001 102001 63535
So, in my container, i will have the new mount.

On files /etc/subuid and /etc/subgid i added this line:
root:2000:1

Without this mapping, the mount folder in container will have read only access.
After i restart my container, i can create files in mount folder, so i have write access,

The problem it's with Nextcloud configuration, i changed /var/www/nextcloud/config/config.php to edit datadirectory to /mnt/nextcloud/data and run the command to copy nextcloud installation files to my folder cp -rp /var/www/nextcloud/data /mnt/nextcloud/
I try to open NextCloud in browser and i get this error message:
Code:
Error
Your data directory is readable by other users
Please change the permissions to 0770 so that the directory cannot be listed by other users.

This is my permissions at folder. How i can solve this problem?
I think is the way the container create mount. I have to remove the other users permissions in folder to this works!
Code:
root@nextcloud ~# ls -l /mnt/nextcloud/data/
total 108
drwxrwxrwx 1 nobody nogroup      0 Apr 30  2020 admin
drwxrwxrwx 1 nobody nogroup      0 Jan 20 17:28 appdata_446b5fb8e2a4b
drwxrwxrwx 1 nobody nogroup      0 Jan 20 03:10 appdata_oculads50ykc
-rwxrwxrwx 1 nobody nogroup      0 Jan 20 17:37 index.html
-rwxrwxrwx 1 nobody nogroup 108371 Jan 21 18:01 nextcloud.log
 
Last edited:
Hi,
I can't say I have much experience with this myself, but I believe you may just need to change the uid:gid of the shared directory to the user it was mapped to. This would be done with chown 2000:2000 /mnt/nextcloud/data. Then change the permissions as requested by nextcloud with chmod 0770 /mnt/nextcloud/data.
Let me know if there are issues after that, and I'll have a deeper look.
 
I also have this issue (and I saw others here asking similar questions as well).
I think this user mapping config is a hard to understand problem of LXC, and sadly Proxmox wiki is not doing too much to uncover the big picture.

How I intend to solve this: mount the data directory as a bind mount directly as /var/www/nextcloud/data.
The goal is to keep the ownership of the folder within the container the default (www-data) and on the host the default 65534 unprivileged user (below this is 1005 for simplicity, should be 65534?).

Most posts here describe this:

/etc/pve/lxc/123.conf
Code:
lxc.idmap: u 0 100000 32
lxc.idmap: g 0 100000 32
lxc.idmap: u 33 1005 1
lxc.idmap: g 33 1005 1
lxc.idmap: u 34 100034 65435
lxc.idmap: g 34 100034 65435

/etc/sub{g,u}id
Code:
root:1005:1


In the container, this makes the /data folder appear owned by 1005 on host and 33 in container - but everything previously owned by 33 is now owned by 65534/nobody, being unaccessible. Why? Does the above map not make the mappings on the HOST?
 
Last edited:
I create an external storage device on NextCloud and mount my usb Hard drive. This solved my problem.
 
I create an external storage device on NextCloud and mount my usb Hard drive. This solved my problem.
i'd love to know more about this set up. been struggling with creating / adding an external usb drive to any lxc or vm with write access.
 
i'd love to know more about this set up. been struggling with creating / adding an external usb drive to any lxc or vm with write access.
You need to mount your external Hard drive on pve main host and mount it in lxc container (edit lxc config file).
In the nextcloud, login with Admin and enable "external storage".
In the UI to configure external storage, Select "local" and choose the folder mounted. Now the disk will be present on NextCloud root directory.
 
  • Like
Reactions: GankUnlo
You need to mount your external Hard drive on pve main host and mount it in lxc container (edit lxc config file).
In the nextcloud, login with Admin and enable "external storage".
In the UI to configure external storage, Select "local" and choose the folder mounted. Now the disk will be present on NextCloud root directory.
thanks for trying, but that vague response isn't getting me any further.
I have a whole thread devoted to my issue which has been following me across LXC and now VM.
I can see my mounted disk in the OpenMediaVault webmin dashboard
1612483998521.png
not at all visible under file systems
1612484195526.png
unable to share anything..

1612484325334.png

I realize openmediavault and nextcloud /owncloud aren't the same thing. but I just can't believe this could be this difficult
 
thanks for trying, but that vague response isn't getting me any further.
I have a whole thread devoted to my issue which has been following me across LXC and now VM.
I can see my mounted disk in the OpenMediaVault webmin dashboard
View attachment 23304
not at all visible under file systems
View attachment 23305
unable to share anything..

View attachment 23306

I realize openmediavault and nextcloud /owncloud aren't the same thing. but I just can't believe this could be this difficult
My friend, i think you dont have mount folder in your second print screen. Only first row have mounted.

Can you share the code of your lxc id configuration? You need do create 2 mount. One on main node, from Hard drive path to a folder in your system. But in the container config file, you need to add a new mount from new mounted folder in main node to a new folder inside container. After restart container, you should ser the mounted folder.
 
  • Like
Reactions: GankUnlo
My friend, i think you dont have mount folder in your second print screen. Only first row have mounted.

Can you share the code of your lxc id configuration? You need do create 2 mount. One on main node, from Hard drive path to a folder in your system. But in the container config file, you need to add a new mount from new mounted folder in main node to a new folder inside container. After restart container, you should ser the mounted folder.
this OpenMediaVault instance is a VM, not LXC, I'd tried using LXC file server and was stuck with a read only drive. decided on trying open media vault.
I realize the external HDD file system isn't mounted in the VM -isn't select-able in the GUI (second print screen shows this)
here is the conf for the vm
Code:
root@xkey:/etc/pve/qemu-server# cat 410.conf
bootdisk: scsi0
cores: 2
ide2: local:iso/openmediavault_5.5.11-amd64.iso,media=cdrom
memory: 4096
name: E-OMV
net0: virtio=76:13:88:A1:EB:DF,bridge=vmbr0,firewall=1
numa: 0
onboot: 1
ostype: l26
scsi0: RAIDZ0:vm-410-disk-0,size=16G
scsi2: /dev/disk/by-id/ata-ST4000DM000-1F2168_Z30091R1-part1,size=3815432M
scsihw: virtio-scsi-pci
smbios1: uuid=571e0ff4-1288-4039-9f12-c0fc911cfa2e
sockets: 1
vga: qxl2
vmgenid: 015c332e-bfa4-43c1-8e98-f9d5a3e291ba

from the VM
1612498554861.png
and the mount point on the VM
1612498976546.png

still can't see it in the GUI

I hear what you are saying, mount to host, then mount to vm from host mount point. but i'll need to figure out how to un-do what i've done so far. or wipe it and start over.
not sure which will be faster at this point
 
Last edited:
this OpenMediaVault instance is a VM, not LXC, I'd tried using LXC file server and was stuck with a read only drive. decided on trying open media vault.
I realize the external HDD file system isn't mounted in the VM -isn't select-able in the GUI (second print screen shows this)
here is the conf for the vm
Code:
root@xkey:/etc/pve/qemu-server# cat 410.conf
bootdisk: scsi0
cores: 2
ide2: local:iso/openmediavault_5.5.11-amd64.iso,media=cdrom
memory: 4096
name: E-OMV
net0: virtio=76:13:88:A1:EB:DF,bridge=vmbr0,firewall=1
numa: 0
onboot: 1
ostype: l26
scsi0: RAIDZ0:vm-410-disk-0,size=16G
scsi2: /dev/disk/by-id/ata-ST4000DM000-1F2168_Z30091R1-part1,size=3815432M
scsihw: virtio-scsi-pci
smbios1: uuid=571e0ff4-1288-4039-9f12-c0fc911cfa2e
sockets: 1
vga: qxl2
vmgenid: 015c332e-bfa4-43c1-8e98-f9d5a3e291ba
Replace the folders name and Add this :
Code:
mp0: /storage/library,mp=/data/library

TThe second mp its folder in your VM. Restart VM and check if this folder its created...
 
Replace the folders name and Add this :
Code:
mp0: /storage/library,mp=/data/library

TThe second mp its folder in your VM. Restart VM and check if this folder its created...
I really wish I could follow what you are saying, but again, " replace folders name" what folder are you talking about?
then "add this " where is this added? the .conf on the host?
I'm not sure about this last line either "the second mp its folder in your VM" what folder?
sorry for inability to pick up what you are putting down.
 
I really wish I could follow what you are saying, but again, " replace folders name" what folder are you talking about?
then "add this " where is this added? the .conf on the host?
I'm not sure about this last line either "the second mp its folder in your VM" what folder?
sorry for inability to pick up what you are putting down.
Add that code on your vm config file, on main host.

Replace the folders name by name of your mount folder
 
  • Like
Reactions: GankUnlo
so after thinking about it, you are saying add this to my 410.conf?

Code:
mp0:      /mnt/HDD,mp=/mnt/HDD
 
so for ref, here is output from my host showing mount point
1612500829895.png
based on previous message I inserted into 410.conf
1612500902800.png

And rebooted VM
however, it doesn't look like my previous attempt to mount on the VM was persistent
anything wrong with how i'm mounting here?
1612501198115.png
I don't see the option in the GUI for this mounted file system still..
i tried another reboot, and drive mount gone again after reboot, so I must not be doing things correctly here
 

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!