FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 09-10-2012, 10:56 PM
Chris Stankevitz
 
Default USB automount

Hello,

Can someone refer me to a source that explains how when I plug in a
USB "thumb drive" it appears on my XFCE4 desktop (or any other WM)?
Ideally the answer will use words like:
daemon
hal
udev
policykit
consolekit
/etc/init.d/*
hotplug
gvfs
mount
automount
pmount
gnome-volume-manager
udisks
fstab
mtab

Also, ideally after I know about it I'd like to be able to
"understand" and derive on my own the answer to this question: "is it
possible for TWM to recognize when I plug in a USB thumbdrive and
display it for me to use."

Thank you!

Chris
 
Old 09-11-2012, 05:03 AM
"Walter Dnes"
 
Default USB automount

On Mon, Sep 10, 2012 at 03:56:20PM -0700, Chris Stankevitz wrote

> Also, ideally after I know about it I'd like to be able to
> "understand" and derive on my own the answer to this question:
> "is it possible for TWM to recognize when I plug in a USB thumbdrive
> and display it for me to use."

A GUI is not necessary. TWM by itself is not only not enough, it's
not relevant. Every time that a USB device is inserted or removed, an
"event" is triggered by the kernel. What's required is an "event
handler" that reacts appropriately to those events. This is usually
udev, but mdev will also work. I've replaced udev with mdev on my
machine ( see https://wiki.gentoo.org/wiki/Mdev ) and I've implemented
USB automounting under mdev, using scripts. It works even in text
console mode. See https://wiki.gentoo.org/wiki/Mdev/Automount_USB

My approach may not be appropriate for a Gentoo newbie. In GNOME/KDE
etc, automounting is one of a ton of extra goodies in "the kitchen sink"
and it "just works". My approach requires doing some manual setting up
before it works. However, if you want an idea of the mechanics involved
my USB automount page provides the background... because I had to ask a
question similar to yours, and spend a few weeks searching for answers
on the web. It helps that I'm retired, and have the necessary time.

--
Walter Dnes <waltdnes@waltdnes.org>
I don't run "desktop environments"; I run useful applications
 
Old 09-11-2012, 08:56 AM
Philip Webb
 
Default USB automount

120911 Walter Dnes wrote:
> On Mon, Sep 10, 2012 Chris Stankevitz asked how to automount a USB stick :
> A GUI is not necessary. Every time a USB device is inserted or removed,
> an "event" is triggered by the kernel. What's required is
> an "event handler" that reacts appropriately to those events.
> This is usually udev, but mdev will also work.
> See https://wiki.gentoo.org/wiki/Mdev/Automount_USB

Why do people want to automount these sticks ?

I goto the root console which is always open on one of my desktops
& enter 'musb', which is a Bash alias for a 'mount' command;
when I've finished, I enter 'uusb' & wait for the prompt to come back,
which shows the stick has been successfully dismounted;
I can check its status via 'df' whenever I want.

I rarely want to use > 1 stick at the same time,
but it wb easy to create several aliases for different dev-mnt pairs.

--
========================,,======================== ====================
SUPPORT ___________//___, Philip Webb
ELECTRIC /] [] [] [] [] []| Cities Centre, University of Toronto
TRANSIT `-O----------O---' purslowatchassdotutorontodotca
 
Old 09-11-2012, 09:41 AM
Neil Bothwick
 
Default USB automount

On Tue, 11 Sep 2012 04:56:21 -0400, Philip Webb wrote:

> Why do people want to automount these sticks ?

Because it is easy and convenient, something computers are supposed to be
good for.

> I goto the root console which is always open on one of my desktops
> & enter 'musb', which is a Bash alias for a 'mount' command;

Leaving aside the implications of leaving open a root console, that
mounts the stick as root. That's fine for a FAT filesystem as you can
specify mount options to make it world-readable, but what about an
external drive formatted with ext? What about an external drive with
multiple partitions?


--
Neil Bothwick

X-Modem- A device on the losing end of an encounter with lightning.
 
Old 09-11-2012, 10:18 AM
Nikos Chantziaras
 
Default USB automount

On 11/09/12 11:56, Philip Webb wrote:

120911 Walter Dnes wrote:

On Mon, Sep 10, 2012 Chris Stankevitz asked how to automount a USB stick :
A GUI is not necessary. Every time a USB device is inserted or removed,
an "event" is triggered by the kernel. What's required is
an "event handler" that reacts appropriately to those events.
This is usually udev, but mdev will also work.
See https://wiki.gentoo.org/wiki/Mdev/Automount_USB


Why do people want to automount these sticks ?


Because 99.9% of the time, the sole reason you plugged them in is to
mount them rather than just watch its LED light up :-P There's no
reason not to mount them.
 
Old 09-11-2012, 03:30 PM
Chris Stankevitz
 
Default USB automount

On Mon, Sep 10, 2012 at 10:03 PM, Walter Dnes <waltdnes@waltdnes.org> wrote:
> Every time that a USB device is inserted or removed, an
> "event" is triggered by the kernel. What's required is an "event
> handler" that reacts appropriately to those events. This is usually
> udev, but mdev will also work. I've replaced udev with mdev on my
> machine ( see https://wiki.gentoo.org/wiki/Mdev ) and I've implemented
> USB automounting under mdev, using scripts. It works even in text
> console mode. See https://wiki.gentoo.org/wiki/Mdev/Automount_USB

Walter,

Thank you. What I'm hearing is:

1. There are many ways to get USB automount

2. One way is to install udev and fabricate the correct scripting to
cause the automount to take place

3. By some magic a GUI system such as GNOME, XFCE, TWM, etc will
recognize when (2) happens and show an icon on the desktop [I'm
talking somewhat tongue in cheek WRT TWM]

If this is correct, I'd like to know:

a) what is the scripting I need to fabricate to get (2) to work correctly.

b) what is the magic by which (3) happens.

Thank you,

Chris
 
Old 09-11-2012, 04:43 PM
Canek Peláez Valdés
 
Default USB automount

On Tue, Sep 11, 2012 at 10:30 AM, Chris Stankevitz
<chrisstankevitz@gmail.com> wrote:
> On Mon, Sep 10, 2012 at 10:03 PM, Walter Dnes <waltdnes@waltdnes.org> wrote:
>> Every time that a USB device is inserted or removed, an
>> "event" is triggered by the kernel. What's required is an "event
>> handler" that reacts appropriately to those events. This is usually
>> udev, but mdev will also work. I've replaced udev with mdev on my
>> machine ( see https://wiki.gentoo.org/wiki/Mdev ) and I've implemented
>> USB automounting under mdev, using scripts. It works even in text
>> console mode. See https://wiki.gentoo.org/wiki/Mdev/Automount_USB
>
> Walter,
>
> Thank you. What I'm hearing is:
>
> 1. There are many ways to get USB automount

Correct.

> 2. One way is to install udev and fabricate the correct scripting to
> cause the automount to take place

That it's the "I want to do it by hand" way.

> 3. By some magic a GUI system such as GNOME, XFCE, TWM, etc will
> recognize when (2) happens and show an icon on the desktop [I'm
> talking somewhat tongue in cheek WRT TWM]

That is the automagical™ way.

> If this is correct, I'd like to know:
>
> a) what is the scripting I need to fabricate to get (2) to work correctly.

I you want to do it by hand (which is as useful as trying to drive a
car as the Flinstones, i.e., with your own feet), you need to create
an udev rule. An old tutorial on that is:

http://www.reactivated.net/writing_udev_rules.html

It's a little outdated, since from some years ago it has been working
"out-of-the-box" in almost all Linux distros, specially if they
install and configure udev as intended by its upstream. So the need
for users to handle udev rules has been greatly reduced.

> b) what is the magic by which (3) happens.

It's not magic; just the modern desktop environments install a program
(or programs) that installs udev rules, and that handle things like
the pretty icons (or notifications, or whatever). In GNOME 3 case, the
program is udisks (version 2), which installs:

/usr/lib/udev/rules.d/80-udisks2.rules

Then it handles everything for you. Please also note that USB stick
mounting is just *ONE* of the gazillion things udev (and other parts
of the stack) takes care of. For example, in this screenshot:

https://plus.google.com/115256116066287398549/posts/JX6kRciZ9zA

I'm configuring Skype to use my bluetooth head set for input/output of
sound, while the rest of my system keeps using the desktop sound card.
The whole shebang is powered by udev (for detecting the headset as
source/sink for audio), bluez (for pairing it), pulseaudio (for
switching sound streams on the fly), etc. You can (of course) do all
of this by hand, but it gets pretty convoluted after a while.

Mounting USB sticks is easy; as Philip said, you can do it with
"mount" in a terminal as root (for example). It could be argued about
how smart is to do it, but it's easy alright.

I care more about stuff like the above screenshot; I could argue that
it's easier (or at least not as difficult) to set up a BT headset for
use with Skype on the fly on Linux than on Mac OS X or Windows. For
that level of easiness and automagicality™, you need the whole stack
working correctly.

It is nice to learn how to do all of that by hand; if you have the
time (and the interest) is a nice thing to do. For doing real work,
it's not very useful.

Regards.
--
Canek Peláez Valdés
Posgrado en Ciencia e Ingenier*a de la Computación
Universidad Nacional Autónoma de México
 
Old 09-11-2012, 09:55 PM
"Walter Dnes"
 
Default USB automount

On Tue, Sep 11, 2012 at 10:41:22AM +0100, Neil Bothwick wrote

> > I goto the root console which is always open on one of my desktops
> > & enter 'musb', which is a Bash alias for a 'mount' command;
>
> Leaving aside the implications of leaving open a root console,

My scripts use pmount and pumount, which are hard-coded to only
mount/unmount devices in directory /media.

> that mounts the stick as root. That's fine for a FAT filesystem as
> you can specify mount options to make it world-readable, but what
> about an external drive formatted with ext? What about an external
> drive with multiple partitions?

pmount/pumount to the rescue. See...
http://manpages.ubuntu.com/manpages/natty/man1/pmount.1.html

--
Walter Dnes <waltdnes@waltdnes.org>
I don't run "desktop environments"; I run useful applications
 
Old 09-11-2012, 10:42 PM
Michael Mol
 
Default USB automount

On Tue, Sep 11, 2012 at 5:55 PM, Walter Dnes <waltdnes@waltdnes.org> wrote:

On Tue, Sep 11, 2012 at 10:41:22AM +0100, Neil Bothwick wrote



> > I goto the root console which is always open on one of my desktops

> > & enter 'musb', which is a Bash alias for a 'mount' command;

>

> Leaving aside the implications of leaving open a root console,



* My scripts use pmount and pumount, which are hard-coded to only

mount/unmount devices in directory /media.



> that mounts the stick as root. That's fine for a FAT filesystem as

> you can specify mount options to make it world-readable, but what

> about an external drive formatted with ext? What about an external

> drive with multiple partitions?



* pmount/pumount to the rescue. *See...

http://manpages.ubuntu.com/manpages/natty/man1/pmount.1.html



I didn't know about that. That's...awesome. And it'll save me trouble.
This is why I like this list; I learn stuff just by listening in.

--
:wq
 
Old 09-11-2012, 10:51 PM
Neil Bothwick
 
Default USB automount

On Tue, 11 Sep 2012 17:55:41 -0400, Walter Dnes wrote:

> > > I goto the root console which is always open on one of my desktops
> > > & enter 'musb', which is a Bash alias for a 'mount' command;
> >
> > Leaving aside the implications of leaving open a root console,
>
> My scripts use pmount and pumount, which are hard-coded to only
> mount/unmount devices in directory /media.

It's the idea of leaving a root console open for all to access that is
the issue, not the commands you run in it.

> > that mounts the stick as root. That's fine for a FAT filesystem as
> > you can specify mount options to make it world-readable, but what
> > about an external drive formatted with ext? What about an external
> > drive with multiple partitions?
>
> pmount/pumount to the rescue. See...
> http://manpages.ubuntu.com/manpages/natty/man1/pmount.1.html

I know about pmount, I use it myself. It mounts as the user running it,
which is fine from a (non-root) terminal, but udevd is running as root,
as are any programs it runs.


--
Neil Bothwick

Top Oxymorons Number 40: Same difference
 

Thread Tools




All times are GMT. The time now is 03:37 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org