Ubuntu - Setup CIFS Auto Mount at Startup
I use shared folders for a number of Docker containers. For example, the shared folder can be on a NAS or a file server. Below I describe how I added the shared folders to my Ubuntu VM. The shared folders are created automatically on every reboot.
Setup with fstab
- Install the
CIFS Utils
:sudo apt-get install cifs-utils
- Create the folder (for example the archive folder within the fileserver) to which you want to point the mount:
cd /mnt sudo mkdir -p fileserver/archive
- I use the Nano text editor to get to the
fstab
:sudo nano /etc/fstab
- Add to
fstab
://fileserver/archive /mnt/fileserver/archive/ cifs vers=3.0,credentials=/home/.smbcred,file_mode=0777,dir_mode=0777,iocharset=utf8,nofail 0 0
If necessary, adjust the following:
//fileserver/archive
This is the folder you want to create a mount for
/mnt/fileserver/archive/
This is the directory on the Ubuntu VM (in my case) you want to point the mount to
Exit Nano (CTRL-X) and save the changes.
- Put the credentials in a separate file. Do the following:
cd /home sudo nano .smbcred
- Add to
.smbcred
:username=<user> password=<pass>
Adjust the following:
username and password
Enter the username and password of the shared folder (on the file server or NAS)
Exit Nano (CTRL-X) and save the changes.
- Test if it works with:
sudo mount -a
If everything went well you should now see the shared folder in /mnt
Read other notes
Tags
Notes mentioning this note
- Docker - Jekyll Container Setup
Here I describe my setup of the Jekyll container.
- Docker - Syncthing Container Setup
Syncthing is a great piece of software that lets you safely sychronize your files between different devices and operating systems....
- Docker - Hop Server Container Setup
Here I describe my setup of the Docker Apache Hop Server container. Apache Hop is an open source data integration...
Comments
No comments found for this note.
Join the discussion for this note on this ticket. Comments appear on this page instantly.