View previous topic :: View next topic |
Author |
Message |
vdboor Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/1838866253fd58d8b00e53.gif)
Joined: 03 Dec 2003 Posts: 592 Location: The Netherlands
|
Posted: Thu May 06, 2004 8:56 am Post subject: |
|
|
Today I experienced that this automount script perhaps works a little too well..
I'd attached the new digital camera of by brother to my system, and suddently there was a /mnt/usb/DIMAGE/ folder... Only, I had to unmount that file as root, because the camera was clearly waiting for some kind of disconnect signal.
So I'm wondering, what would be a nice way to automate this? (Or provide some sudo command with "unmount.desktop" file ) _________________ The best way to accelerate a windows server is by 9.81M/S²
Linux user #311670 and Yet Another Perl Programmer
[ screenies | Coding on KMess ] |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
craftyc Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
Joined: 23 May 2002 Posts: 443 Location: Behind You.
|
Posted: Thu May 06, 2004 10:02 am Post subject: |
|
|
vdboor wrote: | Today I experienced that this automount script perhaps works a little too well..
I'd attached the new digital camera of by brother to my system, and suddently there was a /mnt/usb/DIMAGE/ folder... Only, I had to unmount that file as root, because the camera was clearly waiting for some kind of disconnect signal.
So I'm wondering, what would be a nice way to automate this? (Or provide some sudo command with "unmount.desktop" file ) |
I think just disconnecting the device would be safe. If you use supermount, then it "unmounts" the filesystem as soon as you've finished whatever action you needed to do on the filesystem. _________________ Postcount ++ |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
vdboor Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/1838866253fd58d8b00e53.gif)
Joined: 03 Dec 2003 Posts: 592 Location: The Netherlands
|
Posted: Mon May 10, 2004 4:15 pm Post subject: |
|
|
craftyc wrote: | I think just disconnecting the device would be safe. If you use supermount, then it "unmounts" the filesystem as soon as you've finished whatever action you needed to do on the filesystem. |
Just disconnecting sounds a little scary.. (it was the camera of my brother btw). But I think I should look for this supermount thing, it this makes sure the camera unmounts I'm happy. _________________ The best way to accelerate a windows server is by 9.81M/S²
Linux user #311670 and Yet Another Perl Programmer
[ screenies | Coding on KMess ] |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
craftyc Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
Joined: 23 May 2002 Posts: 443 Location: Behind You.
|
Posted: Mon May 10, 2004 4:44 pm Post subject: |
|
|
vdboor wrote: | craftyc wrote: | I think just disconnecting the device would be safe. If you use supermount, then it "unmounts" the filesystem as soon as you've finished whatever action you needed to do on the filesystem. |
Just disconnecting sounds a little scary.. (it was the camera of my brother btw). But I think I should look for this supermount thing, it this makes sure the camera unmounts I'm happy. |
I think I lied a little about the unmounting. What supermount does is make sure that all of the data is copied/deleted as soon as the operation has been performed ie. cp foo /mnt/usb/Generic/ will copy the data while the command is executed.
I think that the camera simply acts as a USB mass storage device anyway. I unplug my USB stick all the time and the filesystem has never been corrupted. I almost 99.99999% sure that your brother's camera won't get fubared if you just unplug it. Even moreso if you use supermount. _________________ Postcount ++ |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
WildCoder n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 08 Apr 2004 Posts: 65
|
Posted: Tue Oct 12, 2004 6:42 pm Post subject: automount.hotplug in user directory? |
|
|
Hello,
I just installed the automount.hotplug script and it works great with my usb stick.
There is only a couple of things that I would suggest (I wish I was good enough at scripting to do it myself but that's not the case):
I noticed in the todo list that creating a desktop icon was planned. I just installed my first Gentoo desktop under KDE (been using Gentoo on servers for years) so I hacked the script to quickly add an icon to make my life easier. Since scripting isn't my forte it's really a hack but it'll work for ma at least until the script is written properly.
In case someone else is interested here's what I changed:
Code: |
if [ "$ACTION" = "remove" ]
then
# Is it ours?
dir=`get_mounted_path $DEVICE`
echo "$dir" | grep -q ^/mnt/usb || exit 0
# Find the name
PRODUCT=`cat /sys/$1/$2/device/model`
if [ -z "$PRODUCT" ]
then
PRODUCT=generic
fi
# Find out who we are going to mount it as
CONSOLEUSER=`stat -c%U /dev/console 2>/dev/null`
if [ -z "$CONSOLEUSER" ]
then
set `ls -l /dev/console`
CONSOLEUSER=$3
fi
# Unmount it
[ -d "$dir" ] || exit 1
umount -lf "$dir"
rmdir "$dir"
# remove the desktop icon
mesg Unmounting $DEVICE, $dir $PRODUCT for user $CONSOLEUSER
rm "/home/$CONSOLEUSER/Desktop/$PRODUCT.desktop"
exit 1
fi
|
The get user and device should probably be in a function to be nice.
Code: |
mount $MOUNTOPTS $DEVICE $MOUNTPATH
# Everything was mounted fine, create a Desktop icon
echo "[Desktop Entry]" > "/home/$CONSOLEUSER/Desktop/$PRODUCT.desktop"
echo "Encoding=UTF-8" >> "/home/$CONSOLEUSER/Desktop/$PRODUCT.desktop"
echo "Icon=usbpendrive_mount" >> "/home/$CONSOLEUSER/Desktop/$PRODUCT.desktop"
echo "Type=Link" >> "/home/$CONSOLEUSER/Desktop/$PRODUCT.desktop"
echo "URL=$MOUNTPATH" >> "/home/$CONSOLEUSER/Desktop/$PRODUCT.desktop"
|
If someone knows how to detect the device type and put a proper icon that would be nice too.
I would like to change the mount point from /mnt/usb/devicename to $home/devicename
changing the absolute path is easy, but I'd like to make it selectable with an option switch to do it either way, that where it gets way over my head as far as scripting go. With this browsing my home directory would let me see my usb devices right away instead of going to /mnt/usb/devicename.
I hope the author can do that, anyway thanks for the great script!
-WildCoder |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
WildCoder n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 08 Apr 2004 Posts: 65
|
Posted: Tue Oct 12, 2004 6:49 pm Post subject: |
|
|
Hello,
Actually with the previous hack I got lucky the first time to get the correct $DEVICE but since I only get generic so it doesn't delete the icon automatically. Script gurus, please help!
-WildCoder |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
WildCoder n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 08 Apr 2004 Posts: 65
|
Posted: Tue Oct 12, 2004 10:22 pm Post subject: automoun.hotplug new script |
|
|
Hello,
well in my rush to get my usb stick to create a desktop icon I failed to add icon for USB devices with more than one partitions. I just noticed after plugging in a USB HD with 2 paritions in it. BTW I noticed this script is a bit old is it even still needed nowadays or is there a better way to do that kind of thing?
-WildCoder |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
insaniac n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 30 Oct 2004 Posts: 2
|
Posted: Tue Nov 23, 2004 10:34 am Post subject: |
|
|
Hi!
I've read many postings and googled a lot, but still found no answer.
I'm using this script in /etc/hotplug.d/block/.
I think the script is executed before the device nodes are created by udev.
The last two lines from debug output:
Code: |
+ mount -s -onoatime,sync,dirsync,nosuid,umask=077,uid=1000,gid=100 /dev/sda1 /mnt/usb/MP0804H
mount: special device /dev/sda1 does not exist
|
Could anyone tell me how I get this script to be executed, after the devices nodes are created?
If you need more information, let me know. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Glorandar n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 15 Jun 2003 Posts: 64 Location: Vancouver, BC, Canada
|
Posted: Mon Dec 06, 2004 9:08 am Post subject: FIXED - failure of automount.hotplug when using UDEV |
|
|
The symptom: Use of the /etc/autoplug.d/block/automount.hotplug script, with UDEV (/conf.d/rc's RC_DEVICE_TARBALL="no"), fails to mount the USB stick on the /mnt/usb/$DEVICE mount point.
However, subsequent manual mounting of the USB stick succeeds.
The cause: UDEV, without persistent /dev state, itself uses the default hotplug scripts (in /etc/hotplug.d/default) to create the necessary /dev block device (e.g. /dev/sdc1) upon which the automount.hotplug script depends.
When you are using UDEV, move the automount.hotplug script from Code: | /etc/hotplug.d/block | to the directory. UDEV invokes the /etc/rule.d scripts after its done managing the /dev directory.
cheers _________________ ----- Glorandar
Last edited by Glorandar on Thu Dec 16, 2004 4:01 am; edited 1 time in total |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
bfkeats Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
Joined: 20 Feb 2004 Posts: 268
|
Posted: Fri Dec 10, 2004 3:30 pm Post subject: |
|
|
I changed the following line in /sbin/hotplug, and now it works.
Code: | -for I in "${DIR}/$1/"*.hotplug "${DIR}/"default/*.hotplug ; do
+for I in "${DIR}/"default/*.hotplug "${DIR}/$1/"*.hotplug ; do |
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
digitalexpl0it n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 05 Dec 2004 Posts: 20
|
Posted: Sat Mar 12, 2005 7:24 am Post subject: |
|
|
this is a great thread, the scripts work great. and the little icons hack needed tweaing but works. Is there anymore updates on this script? anymore imporvments?
I notice that the icon put on the desktop was set for root, is there a way to set it for all users? I have it set for my main user like the following
Code: |
mount $MOUNTOPTS $DEVICE $MOUNTPATH
# Everything was mounted fine, create a Desktop icon
echo "[Desktop Entry]" > "/home/ddrose/Desktop/usbthumbdrive.desktop"
echo "Version=1.0" >> "/home/ddrose/Desktop/usbthumbdrive.desktop"
echo "Name=Thumb Drive" >> "/home/ddrose/Desktop/usbthumbdrive.desktop"
echo "Encoding=UTF-8" >> "/home/ddrose/Desktop/usbthumbdrive.desktop"
echo "Icon=usbpendrive_mount" >> "/home/ddrose/Desktop/usbthumbdrive.desktop"
echo "Type=Link" >> "/home/ddrose/Desktop/usbthumbdrive.desktop"
echo "URL=$MOUNTPATH" >> "/home/ddrose/Desktop/usbthumbdrive.desktop"
echo "Icon=/usr/share/pixmaps/gnome-remote-desktop.png" >> "/home/ddrose/Desktop/usbthumbdrive.desktop"
chmod 777 "/home/ddrose/Desktop/usbthumbdrive.desktop"
chown ddrose "/home/ddrose/Desktop/usbthumbdrive.desktop"
chgrp users "/home/ddrose/Desktop/usbthumbdrive.desktop"
|
also the mount option was only for root, so my users could not access the thumbdrive only root could. So I just did this
Code: | # These options should prevent abuse and make it writeable for the
# console user.
if grep -q supermount /proc/filesystems
then
MOUNTOPTS="-s -t supermount -onoatime,nosuid,umask=077,uid=$3,gid=$4"
else
#MOUNTOPTS="-s -onoatime,sync,dirsync,nosuid,umask=077,uid=$3,gid=$4"
MOUNTOPTS="-s -onoatime,sync,user,exec,umask=0000"
fi |
just a FYI |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
SomniOne n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/4881966534247e47c88fd1.jpg)
Joined: 26 Mar 2005 Posts: 19
|
Posted: Sat Mar 26, 2005 12:15 am Post subject: merged everything together + a few fixes |
|
|
I have assembled everything what I found in this thread and made a few mods, here are the highlights:
# - Multiple partitions are now correctly created as separate icons on the user's desktop
# - use supermount and subfs successfuly.
# - allow a definition for using diffrent icons for diffrent drives
It has been tested with ~5 diffrent usb devices and on 4 diffrent machines.
You can grab it from here (automount.hotplug)
![Smile :)](images/smiles/icon_smile.gif) |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
adrien1977 n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 03 May 2005 Posts: 38 Location: Chicago (US)
|
Posted: Tue May 17, 2005 10:25 pm Post subject: |
|
|
Ok
I did everything that was asked to do to have that thing work but ....
nothing is automounter.
What am i missing?
I created the folder block
I copied the script in /etc/hotplug.d/block
Change the script /sbin/hotplug (like mentioned a couple threads above)
Restarted everything and nothing
I also change the script to point to kde 3.4 instead of 3.3
thnaks |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
elyre_elan n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/gallery/Star Wars/movie_star_wars_emperor.gif)
Joined: 31 May 2003 Posts: 51 Location: Colorado, USA
|
Posted: Tue May 17, 2005 11:03 pm Post subject: |
|
|
Are you using udev? In a previous post it states to not use hotplug.d/block but instead dev.d/block... _________________ SCO has performed an illegal operation error and will be shut down. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
adrien1977 n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 03 May 2005 Posts: 38 Location: Chicago (US)
|
Posted: Tue May 17, 2005 11:25 pm Post subject: |
|
|
The thing is that I do not know.
What I am doing right now is make sure I am using udev, recompile with the last kernel (r9) and cross finger. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
adrien1977 n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 03 May 2005 Posts: 38 Location: Chicago (US)
|
Posted: Wed May 18, 2005 3:04 am Post subject: |
|
|
ok now I am pretty sure I am using only udev
I have gentoo=nodevfs in the boot
and I also unmerge devfsd
I am also using the latest kernel gentoo-sources R9
it took me a while to make all that work.
Anyway, I also did what you said, which is to put the script in the /etc/dev.d/block
I rebooted and after login I inserted my key and....... nothing happens
Do I have to put anything in the fstab file??? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
chebe Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
![](images/avatars/151501399942530619d20a8.png)
Joined: 02 Mar 2004 Posts: 101 Location: New Caledonia
|
Posted: Wed May 18, 2005 3:50 am Post subject: |
|
|
If you want a good automounter, then youshould try ivman with dbus ...
All there is to do to get it done is written here:
http://gentoo-wiki.com/HOWTO_ivman
I'm no expert, and I did it in just a few minutes, you shouldn't have any problems. _________________ Unix is user friendly - it's just selective about who its friends are ! |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
adrien1977 n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 03 May 2005 Posts: 38 Location: Chicago (US)
|
Posted: Wed May 18, 2005 3:59 am Post subject: |
|
|
ok i'll try |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
adrien1977 n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 03 May 2005 Posts: 38 Location: Chicago (US)
|
Posted: Wed May 18, 2005 4:14 am Post subject: |
|
|
Well I gotta be really bad at linux because I cannot make that automounter work. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
cajzell Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
Joined: 07 Jan 2004 Posts: 176 Location: Falkenberg, Sweden
|
Posted: Sat May 21, 2005 3:01 pm Post subject: |
|
|
Great script! Thanks. It works so fine for my USB stick and external disc also.
Do you have a suggestion on how to modify this script to be used with an external HD that is connected at IEEE1394? The line
Code: | # Is it a usb device? Exit if not.
ls -l /sys/$1/$2/device | sed 's/^.* -> //g' | grep -q usb || exit 0 |
makes it to exit the script.
Or, is there some other way you should handle IEEE1394? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
cdjalel n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 20 Sep 2005 Posts: 1
|
Posted: Tue Sep 20, 2005 4:11 pm Post subject: Icon on the "correct" user desktop |
|
|
Great script.
For my self I replaced /dev/console by /dev/pts/0.
Thank you all there. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
SomniOne n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/4881966534247e47c88fd1.jpg)
Joined: 26 Mar 2005 Posts: 19
|
Posted: Tue Apr 18, 2006 4:22 pm Post subject: Re: Icon on the "correct" user desktop |
|
|
cdjalel wrote: |
For my self I replaced /dev/console by /dev/pts/0.
|
Yes, but that's not always applicable, for example on a machine wich starts a pppd connection (adsl), the pppd will take the /dev/pts/0 first, thus making the permissions go wrong.
I had a permission problem on a few machines doing hibernate (the /dev/console would be owned root after the resume), it could be solved by searching the 'w' command for ':0' (xwindows login) and using the current user, but I was lazy and simply changed USER=theusername in the script.
Oh, yes and the script has problems with drives which don't have any partitions. (some usb sticks are delivered that way) |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|