Thursday, 13 December 2012

External Drive Network Share on Linux

If you have a home server or just a box that is left on most of the time, you may want to add an external drive and share the contents over the network.

This post is written for Lubuntu using an attached memory stick, but you should be able to follow this procedure for other Linux distros.

Lubuntu is a light-weight Linux distro, so you may find there are packages missing which are required for proper network operation. Consequently, I suggest you set your Lubuntu box for networking using the method I've detailed here.

On the "server" (the one with the locally attached external drive) we first need to find device details.

Open a terminal and type:-
sudo blkid

Somewhere in the output should be a line with your external device.

In my case I have a single internal hard drive (sda) and my attached memory stick ("stumpy") is sdb1.

If you are not absolutely sure, disconnect the external device and then repeat the test.

Now open /etc/fstab as root. In Lubuntu we do this via the file manager (PCManFM). Navigate to /etc and then select "Open current folder as root" from the Tools menu.

You can now right click the fstab file and select your text editor (LeafPad) which will open the file with root privileges.

Add a new line at the end of this file:-

...only use your drive details, not mine. I've also added a comment to remind me (12 months from now) why this line is here!

Now save fstab.

Open Samba gui (start > System Tools > Samba) and add a Samba share.

Also open the Access tab and set: Allow access to everyone.

Note: if the device is not mounted to /media but appears under /media/{user account}/ simply re-boot the computer with the device still attached. It should then be correctly mounted to the /media directory.

Open PCManFM file manager > Tools > Open current folder as root

Navigate to /media

Right click on folder > Properties > Permissions

Set Access Control: Other: Read Only

You should now be able to access the drive remotely.

Note: at the time of writing, Lubuntu 12.10 still has a few quirks. Running as a client, I can copy files to the shared drive on a server. I can also open text files, but as soon as I try to type in text, the editor hangs.

No comments:

Post a Comment