LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 06-30-2007, 09:07 AM   #1
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,012

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
USB ext3 HDD permissions problem


I just bought a nice little 120MB USB External 2.5" HDD. It came formatted as NTFS, so I repartitioned it and formatted it as ext3.
When I plug it in, it spins up, is recognised and mounted, and I can open it as /media/sda1
The problem is that o:g and permissions for /media/sda1 are root:root and 755, so I cannot write to it unless I change the permissions (every time I mount it).

When I plug in my usb memory stick (which is currently formatted as vfat), it is mounted as /media/sdb1, but its o:g and permissions are tredegar:tredegar 700, so I can do as I please with it.

I thought that all this was managed by udev but grep 755 /etc/udev/rules.d/* returns nothing.

So my question is: Why is the HDD getting different permissions and where should I look to change this?

I'm running kubuntu 6.06.1, kernel 2.6.15-28-386.

Any ideas?
 
Old 06-30-2007, 09:48 AM   #2
dracolich
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 1,173

Rep: Reputation: 47
The difference in permissions is due to the fs more than the device. Look in /etc/fstab for the line that defines it and set the permissions there with gid and umask options. You can also use chown and chmod if you want to change only certain files/directories.
 
Old 06-30-2007, 09:55 AM   #3
rednuht
Member
 
Registered: Aug 2005
Posts: 239
Blog Entries: 1

Rep: Reputation: 30
/etc/fstab
add user i.e.
Code:
/dev/sda1               /media/sda1       auto            noauto,user     0 0
 
Old 06-30-2007, 10:21 AM   #4
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,012

Original Poster
Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
Thanks for the suggestions, but /etc/fstab has nothing referring to /dev/sd?? (yes, I did plug it in, and it was mounted when I checked fstab) and I do not want to make an entry there as the USB HDD will not always be /dev/sda1 - this depends on what else I have plugged in.

The USB HDD is being mounted dynamically by some script somewhere (called by udev or hal I suspect), but I cannot find it.

Once the HDD is mounted, I can change the permissions for /media/whateveritis, but this is a pain, and the memory stick is mounted with the correct permissions, and I am puzzled by why these two devices are being treated differently.
 
Old 06-30-2007, 11:24 AM   #5
dracolich
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 1,173

Rep: Reputation: 47
Memory sticks and other flash memory cards use a FAT filesystem. FAT didn't have a permissions system like NTFS and EXT. Since your using EXT3 your best option will probably be to change file/directory ownership and permissions with chown and chmod. Something like

sudo /sbin/chown -R tredegar:users /dev/sda1/*
sudo /sbin/chmod -R 755 /dev/sda1/*

You only have to do this once, or whenever you need to change some permissions because the changes will remain between mounts as they're part of the filesystem. The editing of fstab and using umask options is better suited for when mounting FAT devices.
 
Old 06-30-2007, 12:02 PM   #6
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,012

Original Poster
Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
Quote:
sudo /sbin/chown -R tredegar:users /dev/sda1/*
sudo /sbin/chmod -R 755 /dev/sda1/*
No, sorry, but this does not help.
The device nodes /dev/sda and /dev/sda1 are created on-the-fly when the HDD is plugged in. They are given o:g of root:plugdev and permissions of 660. These nodes disappear when the HDD is unplugged. This is all well & good & proper.

Something is creating the mountpoint /media/sda1 and is giving it o:g of root:root and permissions of 755. /dev/sda1 is then mounted at /media/sda1. Something is deleting this mountpoint when the HDD is unplugged. Again, all well and good & proper.

But I cannot, as a regular user, write to the disk at all, without changing the permissions on /media/sda1 because they are wrong (only root can write to the drive).

What I need to find out is what is allocating ownership and permissions to the mountpoint /media/sda1. It is the mountpoint that is being given the wrong permissions. As I said in my OP, I thought that this was handled by udev, but it seems it is not. So what is handling this, and why is the USB flash stick handled differently?
 
Old 06-30-2007, 02:57 PM   #7
dracolich
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 1,173

Rep: Reputation: 47
Quote:
sudo /sbin/chown -R tredegar:users /dev/sda1/*
sudo /sbin/chmod -R 755 /dev/sda1/*
Fingers faster than the brain. That's supposed to be /mnt/sda1/* or /media/sda1/*

Quote:
It is the mountpoint that is being given the wrong permissions. As I said in my OP, I thought that this was handled by udev, but it seems it is not.
It's the HAL and DBUS stuff that creates the /media directories and automounts the device. udev determines the names and permissions of the device nodes, not the mountpoints. It's correct for the /media/sda1 directory to be root:root with 755 permissions. In your OP you mentioned your external disk is formatted as EXT3. Unlike vfat, it doesn't inherit the permissions of the mountpoint because each individual file and directory can have it's own ownership and permissions. As the above-corrected commands indicate, /media/sda1/* will tell the command to change the ownership or permissions of everything under the /media/sda1 directory, which means everything that's on the mounted disk.

Last edited by dracolich; 06-30-2007 at 02:58 PM.
 
Old 07-01-2007, 06:35 AM   #8
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,012

Original Poster
Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
Thanks for your suggestions.
To complicate matters, today (after a reboot) it is working properly:
I plugged in the USB HDD, and it was mounted at /media/sda1 with o:g of root:root and permissions of 777 (yesterday it was 700), so I can use it.
I wish I understood how all this is being handled, as I have not changed any udev.rules, only read through them.

At some stage yesterday, I did chmod 777 /media/sda1, which enabled me to access the drive, but I did not expect this to survive a reboot or unplugging of the device, as /media/sda1 is created only when the HDD is plugged in, and removed when it is unplugged. Curioser & curioser, but now it is working.
 
Old 07-01-2007, 07:09 AM   #9
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,012

Original Poster
Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
An update: Maybe I am just being too impatient
If I monitor the directory /media/ when I plug in the HDD it first appears as /media/sda1 o:g root:root perms 755. A few seconds later, if I refresh my file browser view, it has changed to perms of 777. So I just have to wait a little longer for HAL, dbus and udev sort themselves all out, which thet do, eventually.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SuSE 10.1 USB HDD Problem Mr.Gosh Linux - Hardware 9 12-27-2007 01:21 PM
Problem with external USB HDD kolme Linux - Hardware 1 04-10-2007 06:07 AM
Problem with Booting after creating ext3 partition on External USB ynyus75 Suse/Novell 1 11-13-2005 02:23 PM
problem getting USB HDD to work haimat Linux - Hardware 8 04-25-2005 10:01 AM
Mounting an ext3 HDD (?) AndrewZorn Linux - General 11 04-12-2005 12:04 PM


All times are GMT -5. The time now is 07:59 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration