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 > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 12-05-2009, 12:54 AM
Tom H
 
Default execute script after (auto)mounting external device

>> I have been looking for a GUI for devicekit-disks but no luck.
>> At the cli, there is devkit-disks.

> Neat (I've saved the bookmark!), but not what I'm looking for (I think).

> devkit-disks is concerned with hardware.

> I am looking for a "hook" *after* a specific device has been mounted.
>
> My use-case: The specific device is an encrypted partition on a prtable
> usb-stick. Once I mount and decrypt that volume, I would like to sync
> certain parts of that partition using a script. Can I do that using
> devkit-disks? From scanning the devkit man page I have the impression,
> that devkit has a different focus...

I thought that you would be able to grep for your removable's uuid or
label and then run whatever script you wanted. The script would have
to be run manually though; not quite what I understand that you want.
The only other option that I can think of is to write a udev rule for
your device to run a script.

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-05-2009, 01:02 AM
Patrick Drechsler
 
Default execute script after (auto)mounting external device

Tom H wrote:
> I thought that you would be able to grep for your removable's uuid or
> label and then run whatever script you wanted. The script would have
> to be run manually though; not quite what I understand that you want.
> The only other option that I can think of is to write a udev rule for
> your device to run a script.

We are getting closer to a solution (thanks for your patience so far!):
Do you have a pointer on how to write a udev rule?

Regards,

Patrick




--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-05-2009, 01:11 AM
Tom H
 
Default execute script after (auto)mounting external device

>> I thought that you would be able to grep for your removable's uuid or
>> label and then run whatever script you wanted. The script would have
>> to be run manually though; not quite what I understand that you want.
>> The only other option that I can think of is to write a udev rule for
>> your device to run a script.

> We are getting closer to a solution (thanks for your patience so far!):
> Do you have a pointer on how to write a udev rule?

Possibly "SUBSYSTEM=="block", ATTR{address}=="uuid", RUN+="/path/to/script".

You can get the correct susbsystem and attr entries with udevadm info
/dev/<...>.

This is my last email tonight. My shift is ending in 2o minutes and I
have to focus on work before I leave.

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-05-2009, 03:24 AM
Patrick Drechsler
 
Default execute script after (auto)mounting external device

Tom H wrote:
> Possibly "SUBSYSTEM=="block", ATTR{address}=="uuid", RUN+="/path/to/script".
>
> You can get the correct susbsystem and attr entries with udevadm info
> /dev/<...>.

I will give this a try!

> This is my last email tonight. My shift is ending in 2o minutes and I
> have to focus on work before I leave.

Thanks for your help and have a nice weekend,

Patrick



--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-05-2009, 05:07 AM
Fred Roller
 
Default execute script after (auto)mounting external device

Patrick Drechsler wrote:
> Hi,
>
> I would like to execute a script after a certain external device has
> been (auto)mounted.
>
> What would be the best way to do this?
>
> Thankful for any pointers,
>
> Patrick
>
> $ uname -a
> Linux golem2 2.6.31-15-generic #50-Ubuntu SMP Tue Nov 10 14:53:52 UTC
> 2009 x86_64 GNU/Linux
>
>
>
http://ubuntuforums.org/showthread.php?t=502864

I used this method for a client to use a specific usb hdd's for backups
when they plugged them in. Think this is what you are shooting for,
good luck.

--
Fred
www.fwrgallery.com

"Life is like linux, simple. If you are fighting it you are doing something wrong."


--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-05-2009, 08:04 AM
Tom H
 
Default execute script after (auto)mounting external device

>> Possibly "SUBSYSTEM=="block", ATTR{address}=="uuid", RUN+="/path/to/script".
>>
>> You can get the correct susbsystem and attr entries with udevadm info
>> /dev/<...>.

> I will give this a try!

>> This is my last email tonight. My shift is ending in 2o minutes and I
>> have to focus on work before I leave.

> Thanks for your help and have a nice weekend,

You're welcome. Thanks and you too.

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-05-2009, 08:19 AM
Tom H
 
Default execute script after (auto)mounting external device

>> I would like to execute a script after a certain external device has
>> been (auto)mounted.

> http://ubuntuforums.org/showthread.php?t=502864

> I used this method for a client to use a specific usb hdd's for backups
> when they plugged them in. Think this is what you are shooting for,
> good luck.

Good thread thanks. Although I would try to create a rule without
"ACTION=="add"" first and not prepend "ACTION=="add"" if it is not
needed.

It shows that my earlier suggestion of ""SUBSYSTEM=="block"" was
incorrect. Sorry (I was at the end of an 18.5-hour shift after all!).

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-05-2009, 04:00 PM
Fred Roller
 
Default execute script after (auto)mounting external device

Tom H wrote:

[snip]
> Good thread thanks. Although I would try to create a rule without
> "ACTION=="add"" first and not prepend "ACTION=="add"" if it is not
> needed.
>
> It shows that my earlier suggestion of ""SUBSYSTEM=="block"" was
> incorrect. Sorry (I was at the end of an 18.5-hour shift after all!).
>
>
No need to apologize, been there ;-). Careful with removing the
"ACTION=="add"", I think this is letting the system know what to wait
and look for... ok kernel, when something is added from the
usb_subsystem that looks like this and made by these guys, then go ahead
and execute this. So unless the system defaults to watching for an
"add" action it may kill a critical link. This is part of the stuff I
am still learning so hopefully someone else can explain why or why not
better than I. Let us know how it works.

--
Fred
www.fwrgallery.com

"Life is like linux, simple. If you are fighting it you are doing something wrong."


--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-07-2009, 08:11 AM
Tom H
 
Default execute script after (auto)mounting external device

>> Good thread thanks. Although I would try to create a rule without
>> "ACTION=="add"" first and not prepend "ACTION=="add"" if it is not
>> needed.

>> It shows that my earlier suggestion of ""SUBSYSTEM=="block"" was
>> incorrect. Sorry (I was at the end of an 18.5-hour shift after all!).

> No need to apologize, been there ;-). Careful with removing the
> "ACTION=="add"", I think this is letting the system know what to wait
> and look for... ok kernel, when something is added from the
> usb_subsystem that looks like this and made by these guys, then go ahead
> and execute this. So unless the system defaults to watching for an
> "add" action it may kill a critical link. This is part of the stuff I
> am still learning so hopefully someone else can explain why or why not
> better than I. Let us know how it works.

I have written rules without "ACTION=="add"". AFAIK "ACTION=="add"" is
to add a device so unless the falsh drive is not auto-detected through
the default udev rules, the OP should not need to prepend
"ACTION=="add"" to his script running rule.

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 12-07-2009, 06:01 PM
Patrick Drechsler
 
Default execute script after (auto)mounting external device

Tom H wrote:

> I have written rules without "ACTION=="add"". AFAIK "ACTION=="add"" is
> to add a device so unless the falsh drive is not auto-detected through
> the default udev rules, the OP should not need to prepend
> "ACTION=="add"" to his script running rule.
>

ACTION=="add" (as opposed to ACTION=="remove") means that the action is
only performed while adding the device. If no action is specified, the
action will be performed while adding _and_ while removing the device.

From http://reactivated.net/writing_udev_rules.html:
===============
You can also use the ACTION environment variable to detect whether the
device is being connected or disconnected - ACTION will be either "add"
or "remove" respectively.
===============


With all the help I received here I managed to run a script after
plugging in my usb drive. So I'm halfway there. I just have to figure
out how to detect if the encrypted partition is mounted. Currently I'm
looking into mounttruecrypt
(https://launchpad.net/~andreas-boettger/+archive/ppa).

Thanks, Patrick


--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 

Thread Tools




All times are GMT. The time now is 10:39 AM.

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