Friday, November 16, 2012

How to attach and configure an external hard-disk to RasPi and share it over network

In the last RasPi tutorial, we configured the device to have an static IP on the network. Now, its time to add an external storage to the Pi - in this tutorial we will be adding an removable 500 GB USB harddisk drive to our mini-computer and share it over network for wireless access using Samba server.
RPI and external HDD
Installing and configuring an external disk drive on Raspberry Pi :
  1. While we can use a variety of file-systems on linux like FAT, FAT32 and NTFS. The best option is to use EXT4 for your disk-driver, to format it to EXT4 file-system using a windows computer we can use excellent, free utility MiniTool Partition Wizard.
  2. Once formatted properly, attach your disk drive to RasPi and boot it, make sure you connect the hard-disk via an externally powered USB hub, as RaspberryPi is not capable of handling too many USB powered devices reliably.
  3. To check whether our disk drive is detected by the operating-system, use the sudo fdisk -l command at the terminal and it should list our drive.
  4. fdisk raspi
  5. Now, we will need to manually mount the disk-drive and configure it to load on every boot.
  6. Create an folder inside our disk so we can mount it. Use sudo mkdir -p /media/ExternalHd and sudo chmod 755 /media/ExternalHd to get this done.
  7. Mount Disk
  8. Use sudo blkid command and copy the UUID of the newly added disk, in my case this would be the /dev/sda1: LABEL="NAS" UUID="f477a7f6-67a5-cd01-2027-a4f667a5cd01" TYPE="ext4" entry as shown below.
  9. Disk UUID
  10. Now, edit the fstab file using sudo nano /etc/fstab and add the UUID and other relevant details as shown below.
  11. fstab editing
  12. Save the fstab file and exit nano, use sudo mount -a to mount the disk.
  13. mounting disk
  14. The disk will now automount on every boot.
Sharing the Raspberry Pi storage over WiFi network using Smaba to create an wireless fileserver (NAS Storage) for cheap :
  1. We will now need to install samaba server on RasPi to make an networked fileserver, use sudo apt-get install samba followed by sudo apt-get install samba-common-bin to do that.
  2. Now, edit the samba config file to enable sharing. use sudo nano /etc/samba/smb.conf and add the following to share our newly added disk driver over network.
    [ExternalHd]
    comment = External USB Disk
    path = /media/ExternalHd
    writeable = Yes
    only guest = Yes
    create mask = 0777
    directory mask = 0777
    browseable = Yes
    public = yes
  3. Samba share on RasPi
  4. Restart samba server to make changes take effect.
  5. samaba service
  6. Now you can access this samba share over the network. Just access //YourPiLanIP/. You can also add this add as an network share for access like any other regular partition.
  7. Raspberry Pi over wifi network

No comments:

Post a Comment