Automatically bind mount NFS/SMB/CIFS share to Proxmox LXC container after reboot with bash script



We will write a bash script and create a cron job that will automatically mount bind our NAS shares (NFS/SMB/CIFS) running on Proxmox VM to unprivileged LXC containers (also on Proxmox) after reboot.
Please also see previous video:

where we configured that share and LXC container connectivity.

***********
mount.sh script:

#!/usr/bin/env bash
qm start 202
until [ “$(qm status 202 | awk ‘{print $2}’)” == “running” ];
do
sleep 2
done
sleep 20
mount -t cifs -o user=smbuser,password=marekpass //192.168.1.202/MiniPC /mnt/minipc
sleep 20
lxc-start -n 203

**********

crontab -e:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
@reboot /usr/bin/bash /opt/scripts/mount.sh

*********

0:00 bind mount that works after reboot
14:00 writing bash script
19:35 creating cron job

Thank you for watching !
marek@automation-avenue.com

==28==

[ad_2]

source

Exit mobile version