Skip to content

Commit c88308c

Browse files
committed
feat: add fstab
1 parent 8b04d06 commit c88308c

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
layout: post
3+
title: "Mounting a remote share using fstab"
4+
date: 2023-06-16 00:00:00 -0500
5+
category: "Service Setup"
6+
tags: ['linux', 'fstab', 'smb']
7+
---
8+
9+
Very frequently I need to mount SMB2 or SMB3 shares inside of my linux devices. To do so I usually use `fstab`.
10+
11+
## `fstab`
12+
13+
The first thing to do is create a mounting point. This is a directory on the filesystem that will eventually become the share. It's important to never put files in this directory as they will be overwritten when the share is eventually mounted. In this example I will be adding a backup share, so I will add the following directory:
14+
15+
```bash
16+
cd /mnt/
17+
mkdir backup
18+
```
19+
20+
Then I'll need to edit the `fstab` file so that my share is mounted at boot.
21+
22+
```bash
23+
sudo nano /etc/fstab
24+
```
25+
26+
```conf
27+
//<server>/<share> /mnt/backup cifs vers=3.0,credentials=/root/.mnt_backup_creds,uid=1000,gid=1000 0 0
28+
```
29+
30+
## Credentials
31+
32+
Notice I do not specify the credentials in `fstab`. Instead I designate a credentials file in the root directory. This is for an added layer of credential security.
33+
34+
```bash
35+
sudo nano /root/.mnt_backup_creds
36+
```
37+
38+
```conf
39+
username=<username>
40+
password=<password>
41+
```
42+
43+
## Mounting
44+
45+
Now the share should be ready for mounting. Use the `mount` command to test the share.
46+
47+
```bash
48+
mount /mnt/backup
49+
```
50+
51+
## Future Endeavors
52+
53+
I'd like to eventually explore using `systemd` but that may be another post someday.

0 commit comments

Comments
 (0)