Auto mount folders with CIFS at startup
Introduction
Section titled “ Introduction”Setup shared folders with CIFS and mount automatically at startup. This worked for me within Ubuntu. For example, the shared folder can be on a NAS or a file server.
Setup with fstab
Section titled “ Setup with fstab”-
Install
Section titled “Install CIFS Utils”CIFS UtilsRun the following command:
# Open your terminal applicationsudo apt-get updatesudo apt-get install cifs-utils -
Create the folder to which you want to point the mount
Section titled “Create the folder to which you want to point the mount”This can be a shared folder from your NAS of fileserver. Run the following commands:
# Open your terminal applicationcd /mntsudo mkdir -p fileserver/archivecd /home # Go to home where in step 4 .smbcred will be saved# IMPORTANT: Please read the instructions belowInstructions:
- Required Replace
fileserver/archivewith your own folder
- Required Replace
-
Add to
Section titled “Add to /etc/fstab”/etc/fstab/etc/fstab # To edit use your text editor application, for example Nano//fileserver/archive /mnt/fileserver/archive/ cifs vers=3.0,credentials=/home/.smbcred,file_mode=0777,dir_mode=0777,iocharset=utf8,nofail 0 0# IMPORTANT: Please read the instructions belowInstructions:
- Required Replace
//fileserver/archivewith your shared folder, for example the folder on your NAS or fileserver - Required Replace
/mnt/fileserver/archive/with the local folder you created earlier to point the mount to
- Required Replace
-
Save the credentials to a separate
Section titled “Save the credentials to a separate .smbcred file”.smbcredfile/home/.smbcred # To create this script use your text editor application, for example Nanousername=<username>password=<password># IMPORTANT: Please read the instructions belowInstructions:
- Required Replace
<username>with your username of the shared folder (on the file server or NAS) - Required Replace
<password>with your password of the shared folder (on the file server or NAS)
- Required Replace
-
Test if it works
Section titled “Test if it works”Run the following command:
# Open your terminal applicationsudo mount -a
No comments found for this note.
Join the discussion for this note on Github. Comments appear on this page instantly.