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

Jul 19, 2023

I finally managed to get a network mount to work in Alpine Linux running in a Proxmox LXC container! This guide is a better solution than the previous post. Let’s start!

Creating the mount point

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 we need to add our mount point to /etc/fstab:

nano /etc/fstab

Then add the following:

PATH_TO_SMB_SHARE PATH_TO_MOUNT_FOLDER cifs username:YOUR_USERNAME,password:YOUR_PASSWORD,_netdev 0 0

You can then check if the mounting works by running this command and checking the folder to see the files:

mount -a

Mounting at boot

If everything works well with no error, we can mount this at boot. In Alpine, network boot is handled by netmount so we will need to run this at boot too. To do this, run this command:

rc-update add netmount boot

We will also need to edit the netmount file for this to work:

nano /etc/init.d/netmount

This file contains the following line in the depend() section:

keyword -docker -lxc -jail -prefix -systemd-nspawn -vserver

You will need to remove the -lxc so it looks like the following:

keyword -docker -jail -prefix -systemd-nspawn -vserver

Save the file and test this by rebooting your LXC. That’s it!