Megaleecher.Net

Making technology work for you...

Get Your Free Subscription By Email:

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

Comments

From Hopeless,

Can Pi be linked to a transmitter that will trigger a remote receiver over a distance of 1 mile. I need a low cost solution for a experiment often used in schools.

Thx

Your best bet would be to use two RPi's connected to each other via internet if possible, another solution could be usage of an High Gain wifi network for sending and receiving of communication. Chinese options like these can help bring cost down :

High Power Signal King 2000mW 48DBI USB Wireless Adaptor

Latest 2000mW 13dBi usb wifi kasens G6000 High Power USB WiFi

Hey, this is great, I didn't try yet, but this is so use full for a office and as well as home use.. :)

Thanks,
Chethiya.

Hey, this is great, I didn't try yet, but this is so use full for a office and as well as home use.. :)

Thanks,
Chethiya.

Well, I've tried this multiple times and even after using both Adafruit's Occidentalis and Raspbian “wheezy” distros, I can see the drive but can't write to it (both from a Win7 and Linux Mint machine). I always get "There was an error creating the directory in smb://raspberrypi/externalhd/." with the reason as Permission Denied. I believe I confirmed both the /etc/samba/smb.conf entries and the chmod 755 /media/ExternalHd one earlier in the process. The only thing I altered in the whole process was to substitute "ExternalHD" for every "ExternalHd" as for some reason caps for HD seems more correct to me.

I've tried formatting the external drive as both NTFS and EXT4. It's EXT4 now.

Actually I just checked and even using SSH to remote into the Pi, I can't "mkdir" a folder unless I sudo the command.

Must be something simple but I'm overlooking it.

Ideas??

Hi,

I am no Linux expert but this seems a "Permission" issue, you should try logging as root and changing permission as 0777 for the directory.

Thanks

I followed the directions above and also had the permission issue... I rebooted my Pi and every is working fine...

"Your best bet would be to use two RPi's connected to each other via internet if possible, another solution could be usage of an High Gain wifi network for sending and receiving of communication. Chinese options like these can help bring cost down."

What hardware do I need, two RPi, two antennas, Remote control to activate, transmission and receiving hardware.

Seventy not much time left.

thx

it works fine a did as said and it works thanks for the post very helpful.

I've looked at several of these howtos, and yours is the first that actually recommends adding the UUID to fstab instead of a partition/device entry. I really like this as one of the hard drives will always be attached to the Pi (sda) but the other is a 2TB drive I use for multiple machines. Being able to have it come back and mount in a predictable location is a must for a Pi-NAS.

Add new comment

This is just one of the many helpful tips we have posted, You can find more stories here,
Do subscribe to updates using your favorite RSS feed reader or using the secure FeedBurner email update form on top of this post.