Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

udev and automounting

2 views
Skip to first unread message

Dan H

unread,
Sep 27, 2007, 8:00:25 AM9/27/07
to
Hello,

I'm really having trouble getting my head around udev and udev rules for removeable USB devices. When I plug in my USB stick, it automounts under /media/sda1. What I don't like is that I have to "su" to write to the stick and to unmount it again, so this automounting is pretty useless. I've tried to decipher the files under /etc/udev to find the rule that actually mounts stuff, but grepping for "mount" just shows me some unmounting detail in a file called "hal.rules".

What I'd like is:

1. Automounting USB mass storage devices under some unique name determined
by the label of the partition

2. Write access and unmounting by normal user.

I've seen this work transparently under Gnome and KDE, but I use fvwm or no X at all so that's no option for me.

Thanks
--D.


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Douglas A. Tutty

unread,
Sep 27, 2007, 8:10:06 AM9/27/07
to
On Thu, Sep 27, 2007 at 01:50:11PM +0200, Dan H wrote:
> Hello,
>
> I'm really having trouble getting my head around udev and udev rules
> for removeable USB devices. When I plug in my USB stick, it automounts
> under /media/sda1. What I don't like is that I have to "su" to write
> to the stick and to unmount it again, so this automounting is pretty
> useless. I've tried to decipher the files under /etc/udev to find the
> rule that actually mounts stuff, but grepping for "mount" just shows
> me some unmounting detail in a file called "hal.rules".
>
> What I'd like is:
>
> 1. Automounting USB mass storage devices under some unique name
> determined by the label of the partition
>
> 2. Write access and unmounting by normal user.
>
> I've seen this work transparently under Gnome and KDE, but I use fvwm
> or no X at all so that's no option for me.

I've never had a problem; I've never used automount.

What type of filesystem is on the USB and who created it? If root
created an ext2, then it belongs to root. You would want to create it
as your own user. If its FAT* then use the UID/GID mount options.

Put the mount point in /etc/fstab and use the user option.

You can use the LABEL= instead of a device name and create per-LABEL
mount points and put them all in fstab.

Doug.

Andrei Popescu

unread,
Sep 27, 2007, 11:40:11 AM9/27/07
to
On Thu, Sep 27, 2007 at 01:50:11PM +0200, Dan H wrote:
> Hello,
>
> I'm really having trouble getting my head around udev and udev rules for removeable USB devices. When I plug in my USB stick, it automounts under /media/sda1. What I don't like is that I have to "su" to write to the stick and to unmount it again, so this automounting is pretty useless. I've tried to decipher the files under /etc/udev to find the rule that actually mounts stuff, but grepping for "mount" just shows me some unmounting detail in a file called "hal.rules".
>
> What I'd like is:
>
> 1. Automounting USB mass storage devices under some unique name determined
> by the label of the partition
>
> 2. Write access and unmounting by normal user.
>
> I've seen this work transparently under Gnome and KDE, but I use fvwm or no X at all so that's no option for me.

The package usbmount might be what you need.

Regards,
Andrei
--
If you can't explain it simply, you don't understand it well enough.
(Albert Einstein)

signature.asc

Jesus Arocho

unread,
Sep 28, 2007, 2:30:19 PM9/28/07
to
Try an entry in /etc/udev/10-local.rules; great howtos on the net.

André Berger

unread,
Sep 29, 2007, 4:40:10 AM9/29/07
to
* Jesus Arocho (2007-09-28):

> Try an entry in /etc/udev/10-local.rules; great howtos on the net.
>
> On Thursday 27 September 2007 07:50, Dan H wrote:
[...]

There's also great information on quoting, e.g.
http://www.vranx.de/mail/tofu.html

-André

--
May as well be hung for a sheep as a lamb!
Linkstation/KuroBox/HG/HS/Tera Kernel 2.6/PPC from <http://hvkls.dyndns.org>

Max Hyre

unread,
Sep 29, 2007, 11:30:12 AM9/29/07
to
Andrei Popescu wrote:
> The package usbmount might be what you need.

The description of usbmount says:

This package automatically mounts USB mass
storage devices (typically USB pens) when they
are plugged in, and unmounts them when they are
removed.

Does this limit filesystems to FAT? FAT doesn't care if
you rip it out without doing any cleanup. If you've
formatted your thumbdrive as an ext2 filesystem, how can it
be properly unmounted if you simply unplug it? Won't that
mean you have to run fsck every time you plug it in again?


Best wishes,

Max Hyre

Andrew Sackville-West

unread,
Sep 29, 2007, 12:00:17 PM9/29/07
to
On Sat, Sep 29, 2007 at 11:27:35AM -0400, Max Hyre wrote:
> Andrei Popescu wrote:
>> The package usbmount might be what you need.
>
> The description of usbmount says:
>
> This package automatically mounts USB mass
> storage devices (typically USB pens) when they
> are plugged in, and unmounts them when they are
> removed.
>
> Does this limit filesystems to FAT? FAT doesn't care if you rip it out
> without doing any cleanup. If you've formatted your thumbdrive as an ext2
> filesystem, how can it be properly unmounted if you simply unplug it?
> Won't that mean you have to run fsck every time you plug it in again?

maybe mount with sync instead of async, though mount warns of
life-shortening possibilities with flash stuff. probably a good idea
to go for noatime also to help coutneract that. Both of those would
minimise the risk of damage -- so long as the current process was
done, you could pull it. that just a guess. check man mount.

A

signature.asc

Andrei Popescu

unread,
Sep 29, 2007, 4:40:10 PM9/29/07
to

You could also run 'sync;umount /dev/sda1' before unplugging, just to be
sure.

signature.asc

André Berger

unread,
Sep 29, 2007, 7:30:16 PM9/29/07
to
* Jesus Arocho (2007-09-28):

> Try an entry in /etc/udev/10-local.rules; great howtos on the net.
>
> On Thursday 27 September 2007 07:50, Dan H wrote:
[...]

There's also great information on quoting, e.g.
http://www.vranx.de/mail/tofu.html

-André

--
May as well be hung for a sheep as a lamb!
Linkstation/KuroBox/HG/HS/Tera Kernel 2.6/PPC from <http://hvkls.dyndns.org>

.

Max Hyre

unread,
Sep 29, 2007, 8:30:08 PM9/29/07
to
Andrei Popescu wrote:
> You could also run 'sync;umount /dev/sda1' before unplugging, just to be
> sure.

Umm, OK. But that sort of obviates the point of
usbmount. I guess I'll just continue to umount by hand.

Douglas A. Tutty

unread,
Sep 29, 2007, 10:40:07 PM9/29/07
to
On Sat, Sep 29, 2007 at 08:24:51PM -0400, Max Hyre wrote:
> Andrei Popescu wrote:
> >You could also run 'sync;umount /dev/sda1' before unplugging, just to be
> >sure.
>
> Umm, OK. But that sort of obviates the point of
> usbmount. I guess I'll just continue to umount by hand.

I don't use any sort of automounting or unmounting. I don't have
NFS-homes (the traditional UNIX automounter setup). This is a UNIX-like
OS, although its lookin more and more like a Windows-like OS.

I label the filesystems on anything I want users to mount. I then have
per-label mount points and lines in fstab; users are responsible for
their own mounts and umounts and any damage they do. Then again, I
don't have that many devices.

Doug.

André Berger

unread,
Sep 29, 2007, 11:50:07 PM9/29/07
to
* Jesus Arocho (2007-09-28):

> Try an entry in /etc/udev/10-local.rules; great howtos on the net.
>
> On Thursday 27 September 2007 07:50, Dan H wrote:
[...]

There's also great information on quoting, e.g.
http://www.vranx.de/mail/tofu.html

-André

--
May as well be hung for a sheep as a lamb!
Linkstation/KuroBox/HG/HS/Tera Kernel 2.6/PPC from <http://hvkls.dyndns.org>

..
.

André Berger

unread,
Sep 30, 2007, 1:30:08 AM9/30/07
to
* Jesus Arocho (2007-09-28):

> Try an entry in /etc/udev/10-local.rules; great howtos on the net.
>
> On Thursday 27 September 2007 07:50, Dan H wrote:
[...]

There's also great information on quoting, e.g.
http://www.vranx.de/mail/tofu.html

-André

--
May as well be hung for a sheep as a lamb!
Linkstation/KuroBox/HG/HS/Tera Kernel 2.6/PPC from <http://hvkls.dyndns.org>
...

..
.

Celejar

unread,
Oct 10, 2007, 11:30:20 AM10/10/07
to

>From the usbmount README:


> Vfat Filesystems
> ----------------
>
> Filesystems of type vfat are not considered by default, despite being
> popular for many USB devices, because the Linux kernel does not yet
> fully implement sync-mounting for this filesystem type. This means that
> you risk losing data or even corrupting the filesystem if you remove the
> medium before all data has been written to it. If you include vfat in
> the FILESYSTEMS configuration variable, you *MUST* run the 'sync'
> command before removing the device.

So ext works via sync-mounting, and vfat requires manual syncing.

> A

Celejar
--
mailmin.sourceforge.net - remote access via secure (OpenPGP) email
ssuds.sourceforge.net - A Simple Sudoku Solver and Generator

0 new messages