====== Mounting Windows Shares in Linux (Ubuntu) ======
===== List what fstab has for reference later =====
# 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).
#
#
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
===== 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!!!)
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
===== Making the changes permanent (available on reboot) =====
Add this to /etc/fstab
# 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
Create the password file /etc/sambapasswords with the following lines. No spaces before or after '=' on both lines.
username=hello
password=mypassword
Secure the sambapasswords file
# chown 0.0 /etc/sambapasswords
# chmod 600 /etc/sambapasswords
===== Command line connection (not using established shares) =====
Command to connect to windows share with samba client
smbclient //senthil_lt/C$ -U senthil
Output
Enter senthil's password:
Domain=[SENTHIL_LT] OS=[Windows 7 Home Premium 7601 Service Pack 1] Server=[Windows 7 Home Premium 6.1]
smb: \>
===== Listing Windows shares =====
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
--------- -------