At a whim, after I got stuck trying to remember what package mount.cifs comes in, I asked chatgpt:
It appears to be correct. Fun. I also learned that there's the credential files option which I never used (hardcoded username/password in fstab).
To mount a CIFS (Common Internet File System) network share on Linux startup using /etc/fstab, you can follow these steps:
Create a mount point: First, create a directory that will serve as a mount point for the network share. For example, you can create a directory called /mnt/nas.
CODE
sudo mkdir /mnt/nas
Find out the network share details: You will need to know the IP address or hostname of the NAS device and the path to the shared folder that you want to mount. For example, let's say the IP address of the NAS device is 192.168.1.100 and the shared folder you want to mount is called share.
Install cifs-utils: You need to have the cifs-utils package installed to mount CIFS network shares. If you don't have it installed, you can install it with the following command:
CODE
sudo apt-get install cifs-utils
Edit /etc/fstab: Open the /etc/fstab file in a text editor. Add the following line at the end of the file to mount the CIFS network share:
CODE
//192.168.1.100/share /mnt/nas cifs credentials=/home/user/.smbcredentials,uid=1000,gid=1000 0 0
Here, replace 192.168.1.100 with the IP address or hostname of your NAS device and share with the name of the shared folder. Also, replace /home/user/.smbcredentials with the path to the credentials file. You can create a credentials file with the username and password to access the network share as follows:
CODE
sudo nano /home/user/.smbcredentials
Add the following lines to the file, replacing username and password with your actual login credentials:
CODE
username=<your_username>
password=<your_password>
Make sure to secure the .smbcredentials file so that only you have read and write access to it. You can do this with the following command:
CODE
sudo chmod 600 /home/user/.smbcredentials
Save and close /etc/fstab: Save the changes to the /etc/fstab file and close the text editor.
Test the mount: You can test the mount by running the following command:
CODE
sudo mount -a
This command will attempt to mount all entries in /etc/fstab. If there are any errors, it will print them to the console.
Reboot your system: After testing, reboot your system to ensure that the network share is mounted on startup.
Once you have completed these steps, the network share will be mounted automatically at startup. You can access it at the mount point you created (in this example, /mnt/nas).