Thursday, 22 November 2018

Mounting and accessing a Windows drive from Linux

I copied some of the following suggestion from: https://superuser.com/questions/145191/how-do-i-map-a-drive-network-share-using-the-linux-terminal

I did this because the information may vanish one day and the whole point of this blog is so I don't have to search for the same answers later (My memory is too full after 25 years in IT, lol).

Create a directory on your machine to use as a mount point for the share:
 
sudo mkdir /media/yoursharename

Then use the mount command to map a Windows share to the mount point you just created:

sudo mount -t cifs -o username=<your username> //server/sharename /media/yoursharename
You should now be to access the share from your /media/yoursharename mount point.

Update:
Get Partition Info: Use sudo blkid to get the UUID (e.g., UUID="1234-ABCD") and TYPE="ntfs". Create Mount Point: sudo mkdir /mnt/windows. Edit /etc/fstab: sudo nano /etc/fstab. Add a Line: Add this line, replacing the UUID and mount point as needed: UUID=1234-ABCD /mnt/windows ntfs-3g defaults,uid=1000,gid=1000,dmask=002,fmask=111 0 0. To mount the drive at boot, edit /etc/fstab
sudo xed /etc/fstab

Add the following line modified to suit your system of course
//source/share /mnt/folder cifs credentials=/home/user/.smbcredentials,uid=1000,gid=1000,_netdev,vers=3.0

To enhance security store credentials in a separate file (.smbcredentials) with restricted permissions (e.g.chmod 600 ~/.smbcredentials). The syntax for .smbcredentials is:
username=user
password=pass

After editing /etc/fstab, test the configuration using sudo mount -a to verify that the share mounts correctly without errors.

No comments:

Post a Comment