Mount network share after VM is started up

ffiala268

New Member
Mar 24, 2023
3
1
3
Hello,
I'm looking into some way of mounting network shares to LXCs after VM boot up.
I have an Unraid VM on which all my data is stored. Then I have multiple unprivileged LXCs that are accessing those data by mount point - so they can remain unprivileged. So that means, the VM must be fully booted up and array started (takes approx 3 minutes) and then I need to mount network shares to the Proxmox host first (currently done in "/etc/fstab" via cifs). To do so, I need to manually connect to the Proxmox shell each time just to run "mount -a" for Proxmox host to attach the network shares. Then the containers can be started.
Is there any workaround so it can be automated without me doing anything if I need to restart / turn off and on the Proxmox or something like that? I looked through pages of google and didn't find anything easy enough for person inexperienced with linux commands and setup via shell...
Thanks!
 
Try mountpoints

Code:
pct set 100 --mp[n] [volume=]<volume> ,mp=<Path> [,acl=<1|0>] [,backup=<1|0>] [,mountoptions=<opt[;opt...]>] [,quota=<1|0>] [,replicate=<1|0>] [,ro=<1|0>] [,shared=<1|0>] [,size=<DiskSize>]
 
You can use systemd automount to mount the shares when accessed.

Activate systemd.automount and mount the share in /etc/fstab like:

Code:
//pve-xpenology/Backup/kbackup /mnt/pve/kbackup cifs rw,relatime,cache=strict,credentials=/home/user/.smb-credentials,uid=1000,noforceuid,gid=1000,noforcegid,addr=192.168.1.999,file_mode=0755,dir_mode=0755,soft,unix,serverino,mapposix,noauto,x-systemd.automount,x-systemd.idle-timeout=300  0  0

the x-systemd.idle-timeout=300 will unmount the share after the idle period has passed!
 
Last edited:
Hello guys,

First of thank you for all responses, didn't have much time to thinker with it in the past days unfortunatelly...
I tried intraxes automount method as it's closest to my setup using cifs mount and it works like a charm. Added only one of the commands though - "x-systemd.automount" - as I don't really know what the few other ones do and I don't want it to be automatically unmounted after a timeout period.

Many thanks for help, really apprechiate it! :)

Wish everyone a nice day!
 
  • Like
Reactions: intrax

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!