Using OS : 2012-08-16-wheezy-raspbian
Create Windows Shared Folders using this guide : Windows 7 Network Sharing
Lets say the Windows PC has a host Name as : WindowsPC
And share folder is : share1
So the network share path is : //WindowsPC/share1
Now to Access those on your Rpi
1. Create folder in the /mnt/ folder so that you can mount your network share in that folder
$sudo mkdir mountfoldername
2. Two Ways to access
2.1 Guest Share
sudo mount -t cifs -o guest //WindowsPC/share1 /mnt/mountfoldername
Tip: If your share has space then run the following command, notice the quotes
sudo mount -t cifs -o guest "//WindowsPC/Share 1" /mnt/mountfoldername
2.2 Password Protected Share
sudo mount -t cifs -o username=yourusername,password=yourpassword //WindowsPC/share1 /mnt/mountfoldername
3. Now to check that its mounted , run the following command
$ df -h
Returns something like
Filesystem Size Used Avail Use% Mounted on
rootfs 7.3G 2.0G 5.0G 29% /
/dev/root 7.3G 2.0G 5.0G 29% /
tmpfs 19M 228K 19M 2% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 37M 0 37M 0% /tmp
tmpfs 10M 0 10M 0% /dev
tmpfs 37M 0 37M 0% /run/shm
/dev/mmcblk0p1 56M 36M 21M 64% /boot
//WindowsPC/share1 1.9T 1.5T 390G 80% /mnt/mountfoldername
Notice the last line
4. Now you can access the contents by traversing the following path
$ cd /mnt/mountfoldername
Now if we reboot we need to again mount this network share.
To Automount the network shares everytime on boot follow on
1. We need to edit the /etc/fstab file, Run the following command to edit the /etc/fstab file
$sudo nano /etc/fstab
2. Append the following to the /etc/fstab file
For Guest Login
//WindowsPC/Share1 /mnt/mountfoldername cifs guest 0 0
For Password Protected Login
//WindowsPC/Share1 /mnt/mountfoldername cifs username=yourusername,password=yourpassword 0 0
For Share names with a space
Check the References link
3. Save the File and run the more command to check if the file is updates
$more /etc/fstab
Returns something like
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 0
/dev/mmcblk0p2 / ext4 defaults,noatime 0 0
# a swapfile is not a swap partition, so no using swapon|off from here on, use dphys-swapfile swap[on|off] for that
//WindowsPC/Share1 /mnt/mountfoldername cifs guest 0 0
4. Now Reboot and check that your network share is auto mounted with the following command
$ df -h
Returns
Filesystem Size Used Avail Use% Mounted on
rootfs 7.3G 2.0G 5.0G 29% /
/dev/root 7.3G 2.0G 5.0G 29% /
tmpfs 19M 228K 19M 2% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 37M 0 37M 0% /tmp
tmpfs 10M 0 10M 0% /dev
tmpfs 37M 0 37M 0% /run/shm
/dev/mmcblk0p1 56M 36M 21M 64% /boot
//WindowsPC/Share1 1.9T 1.5T 390G 80% /mnt/mountfoldername
Notice the last line here
To UnMount
$sudo umount
//WindowsPC/Share1
Done 🙂
References
Samba: HowTo Mount a CIFS Network Share [AKA Map Network Drive] in openSUSE 11 plus FAQs
Linux Mount CIFS shares that contain spaces in their share name
samba – Mounting a share with spaces in FreeBSD fstab – Server Fault