Linux For Cynics One user's experiences with Linux

10Jan/122

How to Share an External Harddrive in Ubuntu

If you have files you want to share on an external hard drive, and then you try to access them on another machine, you might get an error like this:

"Unable to mount location. Failed to mount windows share"

Here's what went wrong and how to fix it:

Is the external drive formatted in NTFS or FAT32? If so, and it automatically mounts when plugged in, then it will mount with you as owner and with permissions to allow only you to access it. The remote guest is not you so access is denied. The easiest way out of this is to add the following line to your smb.conf file (located in /etc/samba/) on the machine which is sharing:

 force user = yourusername 

Change yourusername to your own local login user name.

Where you put that line depends on what method you used to create the share - there are two:

If you used Nautilus (the file browser) to create the share then add the line to the [global] section of smb.conf. If you used the classical (shares-admin) method then add it to the share definition itself in smb.conf. The share definition is towards the end of the file and looks like this:

[My Book]
path = /media/My Book
available = yes
browsable = yes
public = yes
writable = yes
force user = yourusername

Then restart samba:

 sudo service smbd restart 

EDIT:
Still won't work? Try this.