A solution for mounting SMB/NFS share at boot for Alpine Linux in Proxmox

Jul 15, 2023

Update: This is deprecated, a better solution can be found here. I’ll keep this post up in case the better solution is not working for you.

Let me preface this by saying that there is a better official solution for this by just using the regular mounting in /etc/fstab. I don’t know what I did wrong, but this has never worked for me in my Proxmox installation. I tried everything, including multiple reinstalls but nada. What I came up with is more of a bandage than an actual fix, but here we go.

For this to work, you must ensure that your container is privileged. During creation, you need to uncheck this box:

Creating privileged container

Once the Alpine Linux LXC is created, you need to run this command to be able to mount CIFS share:

apk add cifs-utils nano

Now for the next step, instead of editing the /etc/fstab, I created a cronjob to mount the CIFS share at boot.

First, create a script that will mount the CIFS share:

nano mount_cifs.sh

And add the mount command to the file:

mount -t cifs -o username:YOUR_USERNAME,password:YOUR_PASSWORD PATH_TO_SMB_SHARE PATH_TO_MOUNT_FOLDER

Make sure that the PATH_TO_MOUNT_FOLDER exists, then make the script executable:

chmod +x mount_cifs.sh

Then please test the script before adding it to cronjob by running this command:

./mount_cifs.sh

Check the mount folder. If everything works, then we can proceed to add it to cronjob:

crontab -e

Then add the following:

@reboot /your_path_to/mount_cifs.sh

Now the only thing to do is to reboot the LXC and check if the CIFS share is mounted at boot.