LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-30-2007, 04:47 AM   #1
greengrocer
Member
 
Registered: Aug 2005
Distribution: Ubuntu Intrepid and Meerkat, formerly used Debian 3.1 (Sarge) with Gnome Desktop
Posts: 353

Rep: Reputation: 37
help required with fstab


Hello all,

I have a USB hard disk which has two partitions (an ext3 partition and a Fat32 partition).

I am trying to configure my computer so that when I plug in the USB hard disk, both partitions appear with the permissions so that user can write to either partition without worrying about root permissions.

So what I did is create two entries in /etc/fstab which look like this:

Code:
/dev/sdb1       /media/usbdisk  auto   rw,user,auto,umask=000,gid=1000     0   0
/dev/sdb2       /media/usbdisk-1 auto   rw,user,auto,umask=000,gid=1000     0   0
when I run
Code:
sudo mount -a
Only the Fat32 partition mounts. The ext3 partition gets an error like this:

Code:
wrong fs type, bad option, bad superblock on /dev/sdb2
NOw assuming that ext3 can be auto-detected, I imagine that one of my options is incorrect.

But the options look OK to me.


Does anyboday have any advice for me? any help with save me some stress.

Thanks
 
Old 06-30-2007, 05:11 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
Hi,

I don't think that umask= and gid= are legal options for an ext3 fs. Try removing them.

Hope this helps.
 
Old 06-30-2007, 05:13 AM   #3
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
Curious, why are all those options selected? Normally, "defaults" should be used? Why are you mounting with sudo, and have "user" in the options list?

Anyways, both "umast" and "gid" are invalid options for a ext3 filesystem, but not for FAT. Try removing them, and see what happens.
 
Old 06-30-2007, 05:20 AM   #4
greengrocer
Member
 
Registered: Aug 2005
Distribution: Ubuntu Intrepid and Meerkat, formerly used Debian 3.1 (Sarge) with Gnome Desktop
Posts: 353

Original Poster
Rep: Reputation: 37
Hi guys,

Interesting, I did a
Code:
dmesg | tail
and I saw errors there relating to the use of 'gid' and 'umask'

so you guys are correct, gid and umask are invalid options for mounting an ext3 filesystem and thus will cause an ext3 not to mount when 'gid' and 'umask' are used in fstab for an ext3 filesystem.


So now I can get the ext3 partition to mount, but it always mounts with root permissions, so users can only view and not write to the partition.

How do I make it so that users can write to the ext3 parition without having to 'sudo' everytime or without having to 'chmod' or 'chown' everytime the USB hard disk is plugged in?


I am really hoping there is a way that an ext3 filesystem on a removable device can be automounted with users being able to write to it.

Regards,
Greenie
 
Old 06-30-2007, 05:26 AM   #5
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
What do you mean? Once you change the permissions, they should stay changed. Are you saying that when you reset the permissions, umount, the re mount the drive, they all change from what you set them to?
 
Old 06-30-2007, 05:34 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
Hi,

I use the following line for usb disks, which allows user to mount/umount the disk and have read/write access:

Code:
/dev/sdc1      /mnt/usb_01    auto   noauto,rw,user  0     0
Only difference with your line being the auto vs noauto option.
 
Old 06-30-2007, 06:03 AM   #7
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
For the ext3 partition, after mounting it as root, use the chown and chgrp commands to change the permissions.

Also, read through the manpage for the mount command. It lists the generic options and the options unique for each filesystem.
 
Old 06-30-2007, 06:26 AM   #8
greengrocer
Member
 
Registered: Aug 2005
Distribution: Ubuntu Intrepid and Meerkat, formerly used Debian 3.1 (Sarge) with Gnome Desktop
Posts: 353

Original Poster
Rep: Reputation: 37
Hey guys,

OK cool,

So the correct method is to:


1) Create mount points to which the filesystems on the USB drives will mount to:
Code:
sudo mkdir /media/usbdisk
sudo mkdir /media/usbdisk-1
2) Add entries into /etc/fstab for the ext3 filesystem that you want fstab to mount:
Code:
/dev/sdb1       /media/usbdisk   auto   rw,user            0   0
/dev/sdb2       /media/usbdisk-1 auto   rw,user            0   0
The above method is good because if you have more than one USB device and those devices are a mixture of EXT3 and FAT32, they will all automatically mount to the specified mount points above and they will easily eject without needing to be root or a sudo

/dev/sdb2 /media/usbdisk-1 auto default 0 0 would only work well for ext2 or ext3 filestystems.

3) Test how well the fstab works by doing:
Code:
sudo mount -a
4) ensure the filesystems mounted to the correct mount points and that all is OK

5) Change the permissions of the mount points:

Code:
chmod 777 /media/usbdisk
chmod 777 /media/usbdisk-1
6) Change the owner and group of the mount points:

Code:
sudo chown user:users /media/usbdisk
sudo chown user:users /media/usbdisk-1

The only trouble now is, after a reboot, the EXT3 partition does not mount automatically. I have to do a "sudo mount -a" for it to mount. The impact of this is that i have to "sudo umount <mount point>" in order to unmount it, I cannot just right click its icon on the desktop and click "eject"


any ideas?

Last edited by greengrocer; 06-30-2007 at 07:00 AM.
 
Old 06-30-2007, 06:46 AM   #9
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
You need a mount point for each partition.

For an external drive, you don't want it to automatically boot. If you did, the boot process would fail if the disk were ejected. Also, the next time you insert the disk, it might be assigned to a different device.

The "user" option will allow you to mount and umount the partition without having to be root.
Just enter "mount <mountpoint>" as a regular user.

For the vfat partition, use the uid,gid,fmask,dmask options to change the user, group, file permissions, and directory permissions respectively. The fat32 filesystem doesn't retain these values, so they are created by using mount options.

Here is the fstab entry I use for a usb external drive:
Code:
LABEL=FIRELITE /media/FIRELITE vfat user,noauto,uid=jschiwal,dmask=0007,fmask=0117
I use "LABEL=FIRELITE" instead of a device. You can also use "UUID=<UUID #>".

If the device is /dev/sdb1, you can determine the UUID number this way:
Code:
udevinfo -q env -n /dev/sdb1
ID_SERIAL=0090a99200000270:1:1
ID_BUS=ieee1394
ID_PATH=pci-0000:02:00.0-ieee1394-0x0090a99200000270:1:1
ID_FS_USAGE=filesystem
ID_FS_TYPE=ntfs
ID_FS_VERSION=3.1
ID_FS_UUID=24B452EDB452C14A
ID_FS_LABEL=My
ID_FS_LABEL_SAFE=My_Book
Here, I could use "UUID=24B452EDB452C14A" in an fstab entry.

Last edited by jschiwal; 06-30-2007 at 06:51 AM.
 
Old 06-30-2007, 07:03 AM   #10
greengrocer
Member
 
Registered: Aug 2005
Distribution: Ubuntu Intrepid and Meerkat, formerly used Debian 3.1 (Sarge) with Gnome Desktop
Posts: 353

Original Poster
Rep: Reputation: 37
@ jschiwal,

But your line in fstab would be no good if your USB device was formatted to EXT3, wouldnt it?
 
Old 06-30-2007, 04:33 PM   #11
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
That's right. Then change the filetype, and don't use the uid, gid, umask, fmask or dmask options. Instead, initially mount the device as root. If it is a newly created filesystem, it will be owned by root. In that case, use the chown and chmod commands.

The "user" option will still allow you to mount the device as a normal user.

For an external device with a linux native filesystem, still use "noauto" and either UUID= or LABEL= in the device field. If your distro has a partitioner program, use it. That way you won't miss options like "acl,user_xattr" for ext3 if they were formatted to support them.
If it is a flash drive, use the noatime as well.

Of course if your HAL system is functioning properly, you wouldn't need an entry in /etc/fstab.

Here was an experiment I performed when answering another post:
Code:
UUID=3B69-1AFD /mnt/cr256 vfat rw,nosuid,nodev,noatime,noauto,flush,user,uid=jschiwal,utf8,shortname=lower,fmask=177,dmask=077
The shortname=lower, and flush options I wasn't familiar with. What I did was:
  • Automounted the device
  • used "udevinfo -q env -n /dev/sdb1" to get the UUID number
  • Entered "mount" by itself and used the same options.
  • Added the options: user,noauto and the fmask and dmask values.

I'll let the system or a partitioner program figure out the font encoding and other special options. I'm not about to waste brain cells memorizing the various encoding schemes. Did you ever read the Sherlock Holmes book "A Study in Scarlet"? This is the book where Watson and Holmes met. Holmes explained that he will remember how many steps are in a landing, but wouldn't have the foggiest idea how far Mars is from Earth. That would waste precious brain cells.

At my age, I don't have any to spare. We can't grow new ones and some die all the time. That does make a good excuse for a bad memory. "Just recycling brain cells, because I'm maxed out".

Last edited by jschiwal; 06-30-2007 at 04:34 PM.
 
  


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 won't boot after fstab changes - fstab not editable baking-a-77 Linux - Newbie 10 06-02-2007 11:51 AM
fstab problem: mount: can't find dvd in /etc/fstab or /etc/mtab Nikon01 Slackware 5 11-17-2006 07:15 AM
newbie vs fstab. fstab wins :( blop Linux - Newbie 3 01-07-2005 06:54 AM
(version 5.1 chapter 08 fstab) vs (man fstab) rgiggs Linux From Scratch 2 06-03-2004 06:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:40 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration