Over this past weekend, I finally setup a network share via Samba on my Raspberry Pi with an old external USB hard drive I had laying around. My RetroPie installation already serves up a Samba share - so my goal was to throw an additional folder in there that mounts to an external drive. After a bit of trial and error, here's how I pulled it off.
Step one was to format my drive to the ext4 filesystem. I ready varying opinions on which filesystem is recommended for this procedure, and ext4 seemed to be a good choice in the end. While there are ways to format your drive directly via the CLI - I decided to use a trial of ExtFS for Mac and it was very easy.
Next, I plugged my external drive into the RPi and connected over SSH. Once you're connected, run the following command:
sudo fdisk -l
Now, look towards the bottom and assuming this is the only additional drive you have plugged in, you should see something like this:
Device Boot Start End Sectors Size Id Type **/dev/sda1** * 2 975400959 975400958 465.1G 83 Linu
Take note of the part in bold. This is the name of the partition on our external drive.
Next we're going to create a directory to mount our drive into, and also another directory within that one. The reason for the second is that I want to avoid seeing the lost+found folder on the ext4 partition we created. You can change the parts in bold to be whatever you'd like.
sudo mkdir /media/**USBHDD **sudo mkdir /media/USBHDD/**share**
After that, we want to ensure that we have the proper access to write to the directory.
sudo chmod -R 777 /media/USBHDD/share
Next, we want to mount our external drive into that new directory.
sudo mount -t auto /dev/sda1 /media/USBHDD
Now we'll need to update our Samba config. If you're already running RetroPie, you've already got Samba installed. If not, you may need to run the following command.
sudo apt-get install samba samba-common-bin
Before you edit your Samba config, make a quick backup copy of the current file.
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old
Now, jump into the config file.
sudo nano /etc/samba/smb.conf
We're going to want to jump straight to the bottom of this file - so if you're on a Mac just hit fn and the down arrow a few times.
Once you get to the bottom, you should see a list of familiar folders that RetroPie already shares (roms, bios, configs, and splashscreens). Create another sections just below the last that looks like this:
[**share**] comment = **Share** path = "/media/USBHDD/share" writeable = yes guest ok = yes create mask = 0660 directory mask = 0771 force user = pi
Feel free to customize the parts in bold, and make sure your path matches the one you created earlier.
And finally, you'll want to restart your Samba daemons.
sudo /etc/init.d/samba restart
At this point you should be able to read and write to your Samba share via Finder by clicking on retropie under the Shared heading and then accessing your new folder called share.
The final step we'll want to do is edit our fstab configuration so that our drive will properly mount whenever our Raspberry Pi reboots.
sudo nano /etc/fstab
Add the following line to the bottom of the config file (making sure to match the values you've used previously).
/dev/sda1 /media/USBHDD auto noatime 0 0
And now we're done. Enjoy your new network share drive. Personally I've hooked mine into every device on my network that can run Kodi for a personal media library accessible throughout the home.