pct set: correct syntax for mounting on cli

Aug 19, 2019
57
7
13
I dont understand the correct syntax for pct set to mount la local loop device from a raw file.

I have a *.raw file which was converted from a kvm VM (qcow2 converted to raw). It contains mass data and shall be attached into a lxc container. As far as I understand https://pve.proxmox.com/wiki/Linux_Container#pct_container_storage , the correct syntax would be

Code:
pct set 116 mp1:volume=data:116/vm-116-disk-2.raw,mp=/mnt/data2,backup=1,size=98G

But for this I only get

Code:
400 too many arguments

??

And I also see no way to handle an already existing *.raw volume. In the WEB UI "Create Mount Point" only allows to create a moint point and the underlying raw file, but not to attach an already existing file.
 
Last edited:
I played a bit and the correct syntax seems to be

pct set 116 -mp1 volume=data:116/vm-116-disk-2.raw,mp=/mnt/data2,backup=1

But still I get errors when I try to start the container with the new mountpoint:

run_buffer: 321 Script exited with status 255 lxc_init: 846 Failed to run lxc.hook.pre-start for container "116" __lxc_start: 2002 Failed to initialize container "116" TASK ERROR: startup for container '116' failed

The same raw file can be mounted manually without problems:

root@tokoeka /mnt/data/images/116 # losetup /dev/loop19 vm-116-disk-2.raw root@tokoeka /mnt/data/images/116 # partx -v --add /dev/loop19 partition: none, disk: /dev/loop19, lower: 0, upper: 0 /dev/loop19: partition table type 'gpt' detected range recount: max partno=1, lower=0, upper=0 /dev/loop19: partition #1 added root@tokoeka /mnt/data/images/116 # losetup -l | grep 116 /dev/loop19 0 0 0 0 /mnt/data/images/116/vm-116-disk-2.raw 0 512 /dev/loop8 0 0 1 0 /mnt/data/images/116/vm-116-disk-0.raw 0 512 /dev/loop18 0 0 1 0 /mnt/data/images/116/vm-116-disk-1.raw 0 512 mount /dev/loop19p1 /mnt/loop/19p1/ root@tokoeka /mnt/loop/19p1 # df | grep loop /dev/loop19p1 100265032 38147784 56980968 41% /mnt/loop/19p1

I guess some option is still missing, maybe because of the "partno=1"....
 
pve expects lxc images to be directly mountable as ext4, so a disk image with a partition layout will not work directly

you could try to export only the partition data into an extra file and use that
 
I managed to mount the converted storage. But inside the container, the new mount point is mounted with wrong permissions (nobody:nogroup instead of root:root). And there is no way to change these permissions, chown -R doesnt work:

Code:
drwxr-xr-x  4 root   root    4096 Feb 24 13:35 .
drwxr-xr-x 22 root   root    4096 Feb 24 13:46 ..
drwxr-xr-x 6 root root 4096 Feb 21 21:03 data
drwxrwx--- 39 nobody nogroup 4096 Feb 1 11:00 data2

config:

Code:
application server
arch: amd64
cores: 4
features: nesting=1
hostname: app3
memory: 4096
mp0: data:116/vm-116-disk-1.raw,mp=/mnt/data,backup=1,size=32G
mp1: data:116/vm-116-disk-2.raw,mp=/mnt/data2,backup=1,size=1000G
net0: name=eth1,bridge=vmbr1,gw=10.10.10.1,hwaddr=4E:8A:AD:1A:6F:C4,ip=10.10.10.26/24,type=veth
onboot: 1
ostype: ubuntu
rootfs: data:116/vm-116-disk-0.raw,size=16G
startup: order=2
swap: 2048
unprivileged: 1
 
i assume the only way is to mount it on the host (or an privileged container) and manually chown'ing it to the correct uid so AFAIR 100000 + whatever www-data in your container has
 
I got this working but I kinda think that I fluked it. I looked at this page https://www.itsembedded.com/sysadmin/proxmox_bind_unprivileged_lxc/

and eventually discovered that the syntax of the mount point command has changed and it's not exactly clear in the documentation. Here's what worked for me (the way I read the documentation, host and container were swapped). The /container/directory must exist. I created a user with ID 1000 in the container, which is why the CHOWN is for 101000.

Code:
# pct set 999 -mp0 volume=/host/directory,mp=/container/directory

Noting that 999 represents the container ID. On the host, I had previously issued the following:

Code:
# chown 101000:101000 /host/directory -R

I'm not clear on why, when the thing's not set up properly, I couldn't find any error logging to help out with debug, but there you go. Only four hours spent resolving this one. The other 12 hours of today's debug was on my own sundry hardware problems. So many different ways to fail!
 
Last edited:

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!