Mounting windows shares on Raspberry Pi
from https://raspberrypi.stackexchange.com/questions/40974/access-network-samba-share-from-pi-client
sudo apt-get update
sudo apt-get install samba-common smbclient samba-common-bin smbclient cifs-utils
from https://rasspberrypi.wordpress.com/2012/09/04/mounting-and-automounting-windows-shares-on-raspberry-pi/
Lets say the Windows PC has a host Name as : WindowsPC
And share folder is : share1
So the network share path is : //WindowsPC/share1
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
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
sudo mount -t cifs //19.16.16.6/someDir /mnt/Y -o username=[name],password=[pw],vers=1.0,sec=ntlm
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
$ 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
sudo umount //192.168.1.3/piRW Mount file
sudo mount -t cifs //192.168.16.5/pi /mnt/Code -o uid=pi,username=cim,password=cim
sudo mount -t cifs //192.168.16.5/pi /mnt/Code -o uid=pi,username=cim,password=cim,vers=1.0,sec=ntlm
mount on ubuntu
sudo mount -t cifs //192.168.168.35/pi /mnt/code -o uid=cim,username=cim,password=cim,vers=2.1
sudo umount //192.168.16.35/pi
sudo mount -t cifs -o username=id,password=pw,vers=2.0 //192.16.16.15/share01 /mnt/NAS
留言
張貼留言