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.
Saturday, December 26, 2009
Subscribe to:
Post Comments (Atom)
Hi Inkhorn,
ReplyDeleteAwesome. Yeah, I should of thought of that (a permissions issue). I'm glad you found an answer. Now, no more smirks from your wife. Thanks for the how to above. I know where to go to if I should encounter a problem like it.
Thanks,
J.
Cool pysdm ! And tutorial !
ReplyDeleteBy the way, I can not still see the files from WXP, as I get a " You do not have permissions to view this location" in WXP, though the permissions are set to umask = 000 in fstab and a ls -l confirms it ...
Do me a favour and post the following 3 pieces of info for me:
ReplyDelete- The line in your fstab file for your external drive
- The output from 'ls -l /media'
- The output from 'blkid'
Cheers,
Inkhorn
Here you go :
ReplyDeletefstab (i tried the UUID thing, but made no difference, I also tried umask 000 but didnt do the trick either):
/dev/sdb1 /media/sdb1 ntfs nls=iso8859-1,ro,_netdev,umask=072,user,uid=atreyu 0 0
ls -l /media
drwxr-xr-x 2 root root 4096 2008-01-16 22:01 cdrom0
drwx---r-x 6 atreyu root 16384 1970-01-01 01:00 disk
drwx---r-x 5 atreyu root 16384 1970-01-01 01:00 disk-1
drwx---r-x 7 atreyu root 16384 1970-01-01 01:00 disk-2
drwxr-xr-x 2 root root 4096 2009-01-13 20:04 isomount
drwxr-xr-x 2 root root 4096 2009-12-02 23:54 isomount2
drwx---r-x 1 atreyu root 4096 2010-01-15 23:21 sdb1
drwx------ 5 atreyu atreyu 472 2009-11-14 01:32 WD SmartWare
blkid
/dev/sda1: LABEL="" UUID="4ACB-941A" TYPE="vfat"
/dev/sda2: LABEL="" UUID="478E-6C0A" TYPE="vfat"
/dev/sda3: LABEL="" UUID="478E-6C0C" TYPE="vfat"
/dev/sda5: UUID="15036c82-8bce-47eb-9f73-9c289286dd76" TYPE="ext3"
/dev/sda6: UUID="649f75bb-b2d4-4432-9b4e-aa0d09356797" TYPE="swap"
/dev/sdb1: UUID="325220A852207331" LABEL="My Passport" TYPE="ntfs"
I am unable to thank you enough.. instead of being a smart ass teacher as the people do in some forums u hit the nail on the head.
ReplyDeleteI have no problem learning the causes of why those settings should work or those shouldnt work.. but its really better when someone tells you what to read first to have your problem solved... again Thank you
Hey Guys, I messed things up and now my hard drive is accessible only for the root user and I'm unable to change it.
ReplyDeleteWell this is very Good Information for linux learners We Are Also Providing Linux Online Training.Linux Online Training is One of The Best Training Center
ReplyDeleteyour article and found it very informative. I remember how hard it was for me to find the right type of external hard drive for my needs. Well, if someone is looking to buy an external hard drive then I'd love to recommend this list of external hard drives where you will find the best one for your specific needs.
ReplyDeleteI always replied to this blog post and its been a long time since I came into knowledge of this blog. One of my friend’s suggestion worked for me and I am still regular to read every post of this blog.HPE OfficeConnect 1910
ReplyDeleteI and my partners have totally taken pleasure in this blog.
ReplyDeletebest-external-storages-for-iphone
Goood post
ReplyDelete