Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tech:linux:mount_samba_windows_share [2015/01/02 06:56]
tech:linux:mount_samba_windows_share [2015/01/02 06:56] (current)
Line 1: Line 1:
 +====== Mounting Windows Shares in Linux (Ubuntu) ======
 +===== List what fstab has for reference later =====
 +<​code>​
 +# cat /etc/fstab
 +# /etc/fstab: static file system information.
 +#
 +# Use 'blkid -o value -s UUID' to print the universally unique identifier
 +# for a device; this may be used with UUID= as a more robust way to name
 +# devices that works even if disks are added and removed. See fstab(5).
 +#
 +# <file system> <mount point> ​  <​type> ​ <​options> ​      <​dump> ​ <​pass>​
 +proc            /proc           ​proc ​   nodev,​noexec,​nosuid 0       0
 +# / was on /dev/sda1 during installation
 +UUID=7709d75b-9467-40c8-8e39-1d0c52178e90 /               ​ext4 ​   errors=remount-ro 0       1
 +# /bak was on /dev/sdb1 during installation
 +UUID=c85d21a5-68c4-4ec4-9ce0-695d5e44bae8 /bak            ext4    defaults ​       0       2
 +# swap was on /dev/sda5 during installation
 +UUID=4e564935-9c47-47ea-941e-08f5f73d2175 none            swap    sw              0       0
 +</​code>​
 +
 +===== Commands to mount =====
 +Note
 +  * hello_pc is the name of the Windows Machine
 +  * Using the same name for the mount point name as well
 +  * First do a ls -l /​mnt/​hello_pc (or whatever is the name of the mount point you want to create). This is to make sure you don't already have one. 
 +  * If you do and don't want to use it anymore do an "​umount /​mnt/​hello_pc"​ (anything else might result in data loss!!!)
 +
 +<code bash>
 +aptitude install cifs-utils
 +mkdir -p /​mnt/​hello_pc
 +mount -t cifs -o username=hello,​password=somepassword //​hello_pc/​c$ /​mnt/​hello_pc
 +cd /​mnt/​hello_pc/​
 +ls
 +</​code>​
 +
 +===== Making the changes permanent (available on reboot) =====
 +Add this to /etc/fstab
 +<​code>​
 +# Adding Windows Share - hello_pc
 +//​hello_pc/​c$ /​mnt/​hello_pc smbfs auto,​gid=users,​fmask=0664,​dmask=0775,​iocharset=iso8859-15,​ credentials=/​etc/​sambapasswords 0 0
 +</​code>​
 +
 +Create the password file /​etc/​sambapasswords with the following lines. No spaces before or after '​='​ on both lines.
 +<​code>​
 +username=hello
 +password=mypassword
 +</​code>​
 +
 +Secure the sambapasswords file
 +<​code>​
 +# chown 0.0 /​etc/​sambapasswords
 +# chmod 600 /​etc/​sambapasswords
 +</​code>​
 +
 +
 +===== Command line connection (not using established shares) =====
 +
 +Command to connect to windows share with samba client
 +<​code>​
 +smbclient //​senthil_lt/​C$ -U senthil
 +</​code>​
 +Output
 +<​code>​
 +Enter senthil'​s password:
 +Domain=[SENTHIL_LT] OS=[Windows 7 Home Premium 7601 Service Pack 1] Server=[Windows 7 Home Premium 6.1]
 +smb: \>
 +</​code>​
 +
 +===== Listing Windows shares =====
 +
 +<​code>​
 +
 +root@ub4:/​etc/​backuppc#​ smbclient -L senthil_lt -U senthil
 +Enter senthil'​s password:
 +Domain=[SENTHIL_LT] OS=[Windows 7 Home Premium 7601 Service Pack 1] Server=[Windows 7 Home Premium 6.1]
 +
 +        Sharename ​      ​Type ​     Comment
 +        --------- ​      ​---- ​     -------
 +        ADMIN$ ​         Disk      Remote Admin
 +        C$              Disk      Default share
 +        IPC$            IPC       ​Remote IPC
 +        Users           Disk
 +Domain=[SENTHIL_LT] OS=[Windows 7 Home Premium 7601 Service Pack 1] Server=[Windows 7 Home Premium 6.1]
 +
 +        Server ​              ​Comment
 +        --------- ​           -------
 +
 +        Workgroup ​           Master
 +        --------- ​           -------
 +
 +</​code>​
  

QR Code
QR Code tech:linux:mount_samba_windows_share (generated for current page)