Try   HackMD

Automatically Mount NAS SMB Folders at Boot on Linux

This tutorial is based on Debian systems.
The NAS is using OpenMediaVault.
中文版

NAS Setup

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

There are three SMB folders on the NAS:

  • sdb
  • sdc
  • sdd

Configure NAS SMB Folders

git clone https://github.com/frakw/nas_smb_mounter.git

Edit nas.conf to store the basic information of the NAS:

NAS_IP=NAS_IP_address
MOUNT_POINT=/mnt
NAS_NAME=NAS_name
NAS_SMB_1=Name_of_the_first_NAS_SMB_folder
NAS_SMB_2=Name_of_the_second_NAS_SMB_folder
NAS_SMB_3=Name_of_the_third_NAS_SMB_folder

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Edit .smbcredentials to store the NAS account credentials:

username=NAS_username
password=NAS_password

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Test the Mounting Process

cd nas_smb_mounter

Set the permissions for .smbcredentials:

sudo chmod 600 .smbcredentials

Install necessary packages:

sudo apt install cifs-utils

Make the scripts executable:

sudo chmod +x mount.sh
sudo chmod +x unmount.sh

Run the mounting script:

./mount.sh

Successfully view the folder contents:

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Unmount the folders:

./unmount.sh

Automatically Mount at Boot

sudo crontab -e

Add the following line at the bottom:

@reboot sleep 30 && /path/to/mount.sh

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

The sleep 30 is added because I connect to the NAS via Tailscale, so it waits for Tailscale to start before executing the script.