Showing posts with label Samba. Show all posts
Showing posts with label Samba. Show all posts

Saturday, December 26, 2009

Permissions, Samba Sharing an External NTFS drive, and fstab

For my first post on this blog I wrote about setting up samba shares for my printer and external hard drive.  When I wrote that entry, I thought I finally succeeded in sharing both devices.  I was disappointed to learn that my solution was temporary, and my external USB hard drive was still unable to be shared with my wife's Windows XP machine.

After hours and hours of pursuing the solution to this problem like Captain Ahab come to life, I started to realize that my problem wasn't anything to do with Samba itself, but the permissions that were automatically assigned to my external hard drive upon its mounting.  Every time I looked at the extended information given by the ls -l command in my /media directory, I saw the following:

drwx------ 1 inkhorn inkhorn 4096 2009-12-06 18:24 backup

In other words, my external hard drive was mounted so that I personally would have read, write and execute access to the drive, that I could mount and unmount it, but nobody else could access my drive in any way at all.

From googling my problem, I learned that if you modify the fstab (file system table) file in the /etc directory, you can change the permissions linux assigns to your hard drive when mounting it.  I found numerous message board postings with examples of how to set up an entry for your hard drive in the fstab file, but none of them helped for very long.  Finally I found a web page that described a program available to Ubuntu users called pysdm (Python Storage Device Manager) that provides a GUI allowing the user to set permissions for any attached storage devices.





As you can see above, it displays all connected partitions and provides an Assistant button that allows you to choose your mounting options intelligently.  In my case, without having a USB stick connected first, my external hard drive shows up as partition sdb1, or /dev/sdb1. 





When you click on the Assistant button, you're brought to the above Select options window.  Most of these options were already set as enabled when this window popped up.  I think the only option here that I changed was to enable Allow a user to mount and unmount the file system.





I then found an option I thought might be important in the Miscellaneous tab.  I enabled the option above labelled This file system requires network.  So, I pressed OK, then at the main window I pressed the Apply button.  There was one catch however: the line that it automatically entered into my /etc/fstab file linked the partition to the mounting point, not the device itself.  See the fstab entry below:

/dev/sdb1    /media/backup    ntfs    nls=iso8859-1,_netdev,umask=000,user,owner  0  0

In other words, what this entry in my fstab file says is that any time partition /dev/sdb1 comes online, mount it to /media/backup; even if /dev/sdb1 is my USB stick, and not my external hard drive!  You see what I mean?

This is where what's called the UUID comes in handy.  The UUID is an alphanumeric sequence that uniquely identifies each connected storage device independently of the partition assigned to that device.  After all, if I connect my USB stick and then my external hard drive, it's my USB stick that would show up as partition sdb1, while my
external hard drive would show up as partition sdc1.  In order to make sure that it's my external hard drive that gets mounted as /media/backup and not my USB stick, I had to replace /dev/sdb1 with the UUID.  To find out the UUID of a connected device, go to the terminal and type in sudo blkid.  Here's the output on my terminal:

inkhorn@inkhorn-laptop:/media$ sudo blkid
/dev/sda1: UUID="2fb4ca03-eca7-41f8-9767-bbfaf88a1890" TYPE="swap"
/dev/sda2: UUID="34B836C6B8368700" LABEL="S3A6134D002" TYPE="ntfs"
/dev/sda5: UUID="ece79ff2-c123-4a72-80a9-c187b2cfd785" TYPE="ext4"
/dev/sdb1: UUID="010C7CC23301CA6C" LABEL="backup" TYPE="ntfs"

So, I opened up the fstab file again and replaced /dev/sdb1 with UUID=010C7CC23301CA6C.  I then saved the fstab file, restarted, and VOILA!!!  My Samba share for my external hard drive is finally accessible from my Wife's Windows XP machine!




If you want to install pysdm on your Ubuntu system, type the following in your terminal:

sudo apt-get install pysdm

Then you can access it through the following menu items: System > Administration > Storage Device Manager.

Sunday, December 6, 2009

Setting up file sharing in Ubuntu Linux

I made a BIG switch from Windows Vista to Ubuntu Linux a while ago.  I have been able to figure out how to do nearly all of my computing tasks in Ubuntu that I need on a regular basis.  The one thing I had a lot of difficulty with for some reason was file sharing.

My linux machine is wirelessly networked with my wife's Windows XP desktop and my own Windows XP netbook.  I wanted to share my external backup hard drive over the network so that she could just copy-paste stuff right into the drive over the network.

For some reason I found that the simplest method just didn't work:
  • Right-click on the icon for my backup drive in Nautilus
  • Click on 'Sharing Options'
  • Click on 'Share this folder'
  • Click on 'Allow others to create and delete files in this folder'
It kept giving me error messages!  Argh!  I kept finding a bunch of how-to's telling me how to modify my samba configuration file.  That was promising but I kept messing stuff up:
  • My printer share stopped working
  • All my shares stopped working
  • I could only view shares from her computer
Finally I found an answer.  Today I looked up "easy samba configuration" on google and found this page that gives a simple samba configuration file that only needs a few tweaks to work.  First I modified the [global] section:

  • I put my computer name, "inkhorn-laptop", next to "netbios name = "
  • I put my workgroup name, "MSHOME", next to "workgroup = "
Then I modified the [network-share] section:
  • I changed [network-share] to read [backup-drive]
  • Put the path to my backup drive, "/media/backup" next to "path = "
  • I deleted the "force group" line, as that didn't seem to help
  • I put the username I set up for my wife next to "force user = "
 Just make sure to follow the directions in the page I linked to above to create a samba username and password for the person you want to access your share.

Finally file sharing and printer sharing are working at the same time :)

--------------- EDIT: Dec. 27, 2009----------------------

The above seems to work just fine for sharing folders on my main hard drive.  To share my external drive it turns out I needed to jump through some hoops to change its permissions so that other people can read, write and execute files on it.  See my latest blog post on the topic here.