Share RaspberryPi Folder over Samba
Setting up a Pi for remote access Samba is pretty straight forward. There are a couple things to do first - like updating your Pi to the latest software, etc., but it's a straight forward process.
1. Update apt-get repositories
pi@apple-pi ~ $ sudo apt-get update
pi@apple-pi ~ $ sudo reboot
2. Attach the disk drive or drives to the Raspberry Pi
pi@apple-pi ~ $ sudo fdisk -l
Disk /dev/mmcblk0: 63.9 GB, 63864569856 bytes
4 heads, 16 sectors/track, 1948992 cylinders, total 124735488 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000b5098
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 8192 122879 57344 c W95 FAT32 (LBA)
/dev/mmcblk0p2 122880 124735487 62306304 83 Linux
WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.
Note: sector size is 4096 (not 512)
Disk /dev/sdb: 3000.6 GB, 3000592977920 bytes
255 heads, 63 sectors/track, 45600 cylinders, total 732566645 sectors
Units = sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdb1 1 732566644 2930266576 ee GPT
In our case, the external drive we plugged in was from a Linux machine, and uses GNU Parted to map its partition table. It doesn't really matter as all we need is the disk ID information highlighted in RED and ORANGE text.
3. Create a local folder to attach the external drive to
pi@apple-pi ~ $ sudo mkdir /mnt/disk1
pi@apple-pi ~ $ sudo nano /etc/fstab
GNU nano 2.2.6 File: /etc/fstab
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 2
/dev/mmcblk0p2 / ext4 defaults,noatime 0 1
# a swapfile is not a swap partition, so no using swapon|off from here on, use dp$
# user added file systems
/dev/sdb1 /mnt/disk1 ext4 defaults 0 0
Added settings are in GREEN in the above /etc/fstab file.
4. Mount your new drive
pi@apple-pi ~ $ sudo mount -a
5. Now test the newly mounted drive
pi@apple-pi ~ $ ls /mnt/disk1
All Projects
composer.phar
distribution-1.6.0-designer-linux64bit.zip
distribution-1.6.0-runtime.zip
Dropbox
Media
6. Install Samba - which allows you to connect to this folder remotely from Windows, Linux and Mac OS X.
pi@apple-pi ~ $ sudo sudo apt-get install samba samba-common-bin
7. Configure Samba
pi@apple-pi ~ $ sudo nano /etc/samba/smb.conf
At the bottom of the /etc/samba/smb.conf file, add the following code:
GNU nano 2.2.6 File: /etc/samba/smb.conf Modified
#
; preexec = /bin/mount /cdrom
; postexec = /bin/umount /cdrom
[jupiter]
comment= Jupiter Media Library
path=/mnt/disk1
browseable=Yes
writeable=Yes
only guest=No
create mask=0777
directory mask=0777
public=Yes
jupiter is the name of the file share that people will see if accessed through Finder in Mac OS X, or Windows Explorer or any of the file managers in Linux.
pi@apple-pi ~ $ sudo service samba restart
Because Samba Username/Passwords are different than the actual system's login credentials, you need to set the pi password for Samba. I recommend you make it the same as your existing pi password.
pi@apple-pi ~ $ sudo smbpasswd -a pi
Provide the new password for Samba, with the username of pi.
8. Setup autofs
pi@apple-pi ~ $ sudo apt-get install autofs
pi@apple-pi ~ $ sudo nano /etc/auto.master
Add the following to the bottom of the /etc/auto.master file
# User added configurations
/media/ /etc/auto.ext-usb --timeout=20,defaults,user,exec,uid=1000
pi@apple-pi ~ $ sudo reboot
No comments:
Post a Comment