How to automatically mount shared filesystem after VM starts?

xokia

Member
Apr 8, 2023
95
8
8
I am running TrueNAS in a VM that I used to create a SMB share.

I also have a container with ubuntu that I want to give access to that share.

I can edit /etc/fstab to point to that share but if the machine restarts that share will not be available until TrueNAS VM starts so It will no mount on startup.

I can create the mount point in the container and delay the startup of the container until after the TrueNAS VM boots. But I still run into the same problem I have to manually type mount -a. Looking for a way to automate this.
 
You can set the start order and start delay for each guest. When after booting PVE will start the VMs in order from lowest to highest start order and when shutting down the node it will shut down the guests in the reverse order (from highest to lowest start order).
So you could set the start order = 1 for your TrueNAS VM, then start order = 2 for the LXC and set some start delay for the LXC so the TrueNAS VM got some time to boot up.
 
  • Like
Reactions: andre.lackmann
You can set the start order and start delay for each guest. When after booting PVE will start the VMs in order from lowest to highest start order and when shutting down the node it will shut down the guests in the reverse order (from highest to lowest start order).
So you could set the start order = 1 for your TrueNAS VM, then start order = 2 for the LXC and set some start delay for the LXC so the TrueNAS VM got some time to boot up.
Yea I tried that already. The problem is that the drive needs to be mounted after trueNAS boots. Proxmox will try and mount the drive while proxmox is booting. But at this time True NAS is not up yet. I need to delay the mnt -a until after TrueNAS is up but I do not know how to do this. The mount command needs to somehow be part of the TrueNAS VM bringup and issue the cmd back to proxmox terminal.
 
Last edited:
If your client servers had been in containers, not a VM each, then you could bind mount disk space from the Proxmox host directly into both TrueNAS and the Ubuntu container, in which case the boot order of the client OS's would be irrelevant, as each client would be accessing the disks via the host.

As you are using VMs, this is almost like running your two servers as separate physical machines on a network, except Proxmox can give you a bit of help with the boot order and delayed start of the second machine, but other than that the Proxmox host isn't involved, it doesn't need to mount the Samba disk, your Ubuntu client does.

If you ignore the "hosted on Proxmox" angle, I assume there will be help out there in Google land on how best to have a client machine mount disk shares from a server that (as is always the case on a network) might not be there for some reason. I believe cifs does soft mounting by default, so failed mounts will return an error. A robust solution might involve having the Ubuntu machine pinging/polling the status of the Samba host on a regular basis and remounting the Samba shares if the server goes away (or is still booting) and then comes back online.
 

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!