How to add samba entry in /etc/fstab

How to add samba entry in /etc/fstab

Configure Samba On Ubuntu

1. install necessary tools

1sudo apt install cifs-utils

2. prepare credentials

1sudo mkdir /mnt/samba
2sudo vi /root/.smb_credentials

3. put next 2 lines into /root/.smb_credentials

1username=<your user name>
2password=<your password>

4. change credential file permission for security reason

1chmod 600 /root/.smb_credentials

5. configure /etc/fstab

1sudo vi /etc/fstab

6. put next line into /etc/fstab. add noauto to options if you don’t want to let Ubuntu auto mount this path

1#<shared path>       <mount point> <type>  <options>
2//192.168.0.3/share  /mnt/samba    cifs    credentials=/root/.smb_credentials,gid=1000,uid=1000,file_mode=0755,dir_mode=0755 0 0

7. mount it

1umount /mnt/samba -lv
2mount /mnt/samba

本文基于 Ubuntu 22.04 LTS 编写。