[Ubuntu Server] Permanently Mounting Samba Shares
Hey everyone, Although this isn't related to programming, it's still a tech post. I'm writing it mainly because I have forgotten how to do this more than once, had to research it, and I don't want to have to scour the web for the information again in the future.
So, let's get started.
- Log into your Ubuntu Server
- If you don't have cifs-utils already, let's get that installed.
sudo apt-get install cifs-utils
- Create a new directory for the network server you're preparing to mount. I prefer to create them inside the /mnt/ folder. In my current case, the network drive that I'm mounting just has a lot of documents, so I'm going to create a folder: /mnt/documents.
sudo mkdir /mnt/documents
- Change directory to /etc/, where your fstab file is located.
cd /etc/
- Open fstab in an editor, like nano.
sudo nano fstab
Add the appropriate network map to the end of your fstab file. In my case, that will look like:
//192.168.X.X/documents /mnt/documents cifs username=USERNAME,password=PASSWORD,iocharset=utf8
- Replace 192.168.X.X/documents with your network location and share name.
- Replace /mnt/documents with the folder you created in step #3.
- Replace USERNAME and PASSWORD respectively.
Write your changes to fstab from within Nano and exit the program.
- Check your work by running:
If you received no errors, then the network drive should have mapped properly and will automatically mount again each time your server starts.sudo mount -a
Thanks for reading! I hope this helped!
Feel free to follow me on Twitter!