Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mount directory into proxmox_lxc #1228

Open
tofkamp opened this issue Jan 18, 2025 · 1 comment
Open

mount directory into proxmox_lxc #1228

tofkamp opened this issue Jan 18, 2025 · 1 comment

Comments

@tofkamp
Copy link

tofkamp commented Jan 18, 2025

I want to make an unprivileged container with a directory binding to the host. I use the proxmox_lxc resource.
In this resource there is a option for a mountpoint. I think it should go like this:

mountpoint {
    slot    = "0"
#    key=0
    storage = "/mnt/shared/dock1601proxy"
    mp      = "/docker"
#    size= "0K"
  }

But it complains about it needs a key and a size, but it is a directory, so those parameters are not needed. If I give it some info, it complains that there must be a TGM or K in the size, which I did (when uncommented the line).
Size is irrelevant because it is a directory binding. Nor the key has any purpose.

To get the desired state, you could do the following commands in the proxmox host shell:

chown 100000:100000 /mnt/shared -R
pct set 1601 -mp0 /mnt/shared/dock1601proxy,mp=/docker

If I do an import: "tofu import proxmox_lxc.dock1601proxy node/lxc/1601" ,it imports the state, but there is no mountpoint in the state, nor any network config.

Is it possible to do a directory binding with the API (storage type = dir?) ? If so, would it be possible to add it to the proxmox-provider ?

@tofkamp
Copy link
Author

tofkamp commented Jan 18, 2025

I installed the powershell module to manage pve from windows..
https://github.com/Corsinvest/cv4pve-api-powershell
Connected the pve node from my PC:

Connect-PveCluster  -HostsAndPorts node:8006 -Credentials root@pam  -SkipCertificateCheck
$ret = Get-PveNodesLxcConfig -node node -vmid 1601
$ret.Response.data
...some data...
mp0          : /mnt/shared/dock1601proxy,mp=/docker
...more data....
Set-PveNodesLxcConfig -Node node  -Vmid 1601 -MpN @{1 = "/mnt/shared/dock1601proxy,mp=/docker2"}

Response            : @{data=}
StatusCode          : 200
ReasonPhrase        :
IsSuccessStatusCode : True
RequestResource     : /nodes/node/lxc/1601/config
Parameters          : {[mp1, /mnt/shared/dock1601proxy,mp=/docker2]}
Method              : Put
ResponseType        : json

And the LXC container now has two mount points ! Conclusion: Yes it is possible to do a directory mount through the API.
I rather manage the resources by terraform/tofu, than some powershell script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant