Proxmox LXC preboot host script

So I’ve followed the instruction in the link:
https://steamforge.net/wiki/index.php/How_to_mount_a_Network_Share_in_a_Linux_Container_under_Proxmox

and got it working… until the host reboots, at which point I have to run mount -a after my NAS vm boots then start the LXC.

How would I automate that to run before the LXC starts but after my NAS vm boots?

crontab
@reboot root /bin/bash -c ‘sleep 240 && /bin/mount -a’

did not work, I’m guessing because the NAS vm still hasn’t booted.

Any ideas would be great,

Thanks,

I have my network share added as a storage location in proxmox. I then edit the config file for LXC, so /etc/pve/lxc/ID.conf and add a mount point:
mp0: /mnt/pve/share,mp=/mnt/share

I also have my NAS VM boot priority set to boot first with the LXCs set to boot like 2 minutes later. My LXC disks are also stored on a different network share from the NAS VM but that part is optional.

This is what I have:
mp0: /mnt/netfolder/Plex,mp=/mnt/extfolder/Plex

So, mount the smb share via proxmox webui, not via fstab/linux. Then it should work in the LXC after my vm boots?

I thought maybe, but I didn’t want to start there. I’ll probably mount via NFS then, I have that going on another instance just fine pointing to an onboard VM’s NAS.

I’ll give it a shot and report back,

Thanks for your response,
I am grateful,

Yeah, if it’s mounted via the web interface on the Proxmox host it will be in /mnt/pve on the host and you can map that to whatever you want in the container. I only did it that way because it’s less of headache for me, but you could just set boot priority in your vm/lxc options so that the NAS boots first and then wait a few minutes before starting the LXC.

Alright, so far so good,

I kept it cifs, didn’t feel like dealing with NFS. updated the LXC mp’s to the folder. Very cool.

Updated the boot order and added a delay of 120 seconds.

Rebooted the host twice, each time the LXC container failed to auto start. It had been booting fine. very weird.

Any ideas why it would no longer auto boot?
I can start it manually no problem.

The Start all VM’s task log says successful:

Is there a start event under the task history for 102? If so what does it say?

pfft, may have been typing before googling:

I doubled the boot delay of the NAS and it worked. Guess 120 was too short

GOOD ENOUGH! lol

Thanks again for the guidance!

2 Likes