linux:misc:cifs_part_fstab

Action disabled: index

Adding a partition and cifs share to fstab on Ubuntu

Let's assume you already know how to create partitions on a Linux system. The partition does you no good, if you don't mount it. If you don't want to mount it by hand every time you log in Here is how to use fstab file to to automount it at boot time.

After you created the partition, run:

tplecko@bhrzg501u:~$ sudo blkid
/dev/sda1: UUID="2c6859ee-9fe6-4f23-bb78-dec6c01d60c3" TYPE="ext4" 
/dev/sda2: UUID="5e3dbbc9-f15b-4195-8487-94519c891040" TYPE="ext4" 
/dev/sda3: UUID="316acb95-f85d-4cfa-86ea-c678e889cd81" TYPE="ext4" 
/dev/sda4: UUID="201f6527-4167-42ee-a7ee-7b5b9cda683a" TYPE="swap" 
tplecko@bhrzg501u:~$ 

sda3 is the partition I want to add. Copy UUID of sda3, and open the fstab file in VIM. Add the line:

UUID=316acb95-f85d-4cfa-86ea-c678e889cd81 /newpart               ext4    errors=remount-ro 0       1

Reboot, and you should see it mounted on /newpart

To ass CIFS share, append the following into fstab file:

//10.0.0.250/share   /mnt/share  cifs    username=winuser,password=winpwd,iocharset=utf8,sec=ntlm     0       0

Assuming that the share is located at \\10.0.0.250\share, username is 'winuser' and password is 'winpwd'. Note that the password entered is in plain text, and anyone can read it.

A better way to do it would be to use a password file (but you have to create it for each user.

tplecko@bhrzg501u:~$ touch ~/.smbcredentials
tplecko@bhrzg501u:~$ echo username=winuser >> ~/.smbcredentials
tplecko@bhrzg501u:~$ echo password=winpwd >> ~/.smbcredentials

Change the permissions of the file to prevent unwanted access to your credentials:

chmod 600 ~/.smbcredentials

And in fstab, append the line:

//10.0.0.250/share /mnt/share cifs credentials=/home/ubuntuusername/.smbcredentials,iocharset=utf8,sec=ntlm 0 0

If you get an error, install cifs-utils

Enter your comment:
38 -11 = 
 
  • linux/misc/cifs_part_fstab.txt
  • Last modified: 2019/10/31 09:05
  • by 127.0.0.1