External USB drive and Raspberry Pi - connection

External USB hard drive and Raspberry Pi

- connect as a network drive WE


The Raspberry Pi can be used as a server to connect to the hard drive. Because of this, we were able to share music, video or documents for all users of our local network. Example shows how to connect a hard drive to the Raspberry Pi (this is due to a change in the current of the USB output), and then use it as a network drive.


In this example we used the following elements:


Software installation

In our case, the service RaspberryPi during the entire configuration process will be carried out remotely from a PC.

At the beginning connect your null modem Raspberry to the same network, which is our computer. Then we need to know the IP address that was assigned to our unit. To do this, enter the Raspbiana. Default login: pi, password: raspberry. Then use the command ifconfig readable IP:



In my case


Then on the computer from which we will support Raspberry install SSH client, PuTTY. After running in the" Host Name (or IP address) enter the IP previously read. As connection type select SSH. We can also save the session so you don't have to enter the address.



Click "Open" to the RaspberryPi.


To start to make the software update. To do this, enter the command:


  • sudo apt-get update

  • sudo apt-get upgrade


We can now proceed to install Samba. Thanks to her, we will be able to share files in local network.


  • sudo apt-get install samba samba-common-bin

    - install Samba


  • sudo smbpasswd-a pi

    add user (at the point pi, we give its own name) with a password required to log on to a network drive


  • sthigh nano /etc/samba/smb.conf

    looking for # security = user, and then remove the # sign at the beginning of the line.



  • if we want to save information to the hard drive, not just to read, in the section [homes] change read only = yes, read only = no



The connect a hard drive

More likely to connect the drive via USB with the RaspberryPi, we will have to increase the current on the USB port. Default is 600 mA, which may be insufficient to drive. However, you can modify them at 1200 mA. To do this, open the file /boot/config.txt


  • sudo nano /boot/config.txt


At the end add two lines:




Then you should restart the Raspberry and check whether our disk was discovered:


  • sudo fdisk-l



To mount the disk image we need to create the appropriate directory and mount it external hard drive:


  • sudo mkdir /media/dysk_zew

    - creates a directory dysk_zew in the directory /media


  • sudo mount-t auto /dev/sda1 /media/dysk_zew

    - mount the disk in the directory dysk_zew. In the place of /dev/sda1 enter the path to the disk open earlier


If the drive comes with some files we check whether the system sees the CD command


  • ls /media/dysk_zew



Now after each reboot of the device should be mounted disk manually. For this to occur automatically changing the /etc/fstab


  • sudo nano /etc/fstab


In the end add the following line:

/dev/sda1 /media/dysk_zew auto defaults 0 2


In order to verify everything works correctly, you should restart the Raspberry


  • sudo reboot


Then use the command" ls /media/dysk_zew we check whether the disc can be seen.


Parameter visibility disk over the network

To do this go back to the file /etc/samba/smb.conf

  • sthigh nano /etc/samba/smb.conf

in the end add the following section:


comment=Disk udostepniony
path = /media/dysk_zew
valid users = @users
force group = users
create mask = 0660
directory mask = 0771
read only = no


Now restart the Samba server.


  • sudo /etc/init.d/samba restart


At this point our Raspberry became visible in network neighborhood Windows


Now we can log on a shared disk, putting the user and password for Samba (not Raspbiana)