# umounting usb, yet again.

## afabco

Ok, the tension mounts, the frustration level is high, the sky is darkening, the apocalypse is nigh....

Still can't figure out this &*(^%^& user removable media thing.

I use the console.  Not into these newfangled gee-yew-eye thingies.

plug in a usb stick.  It mounts. Can read/write/delete all sorts of things you'd think you'd be able to do.

```

thomson@leeamlp ~ $ touch /media/LexarUSB/test

thomson@leeamlp ~ $ rm /media/LexarUSB/test

thomson@leeamlp ~ $ ls -ld /media/LexarUSB

drwxrwx--- 8 ivman plugdev 4608 May  2 10:34 /media/LexarUSB
```

ok.  Want to remove the usbstick.

```
thomson@leeamlp ~ $ pumount /media/LexarUSB/

Error: device /dev/sda was not mounted by you

thomson@leeamlp ~ $ umount /media/LexarUSB/

umount: /media/LexarUSB is not in the fstab (and you are not root)

thomson@leeamlp ~ $ fusermount -u /media/LexarUSB/

fusermount: entry for /media/LexarUSB not found in /etc/mtab

```

What's the proper way for a non-root user to remove this?  Am I just supposed to yank the damn thing out???  That can't be right.

Thanks in advance.

info:

```
thomson@leeamlp ~ $ emerge --info

Portage 2203-svn (default-linux/x86/2005.1, gcc-3.4.5-hardened, glibc-2.3.6-r3, 2.6.16-gentoo-r3 i686)

=================================================================

System uname: 2.6.16-gentoo-r3 i686 Intel(R) Pentium(R) 4 CPU 2.53GHz

Gentoo Base System version 1.6.14

ccache version 2.3 [disabled]

dev-lang/python:     2.3.5-r2, 2.4.2

dev-util/ccache:     2.3

dev-util/confcache:  [Not Present]

sys-apps/sandbox:    1.2.12

sys-devel/autoconf:  2.13, 2.59-r7

sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r1

sys-devel/binutils:  2.16.1

sys-devel/libtool:   1.5.22

virtual/os-headers:  2.6.11-r2

ACCEPT_KEYWORDS="x86"

AUTOCLEAN="yes"

CBUILD="i686-pc-linux-gnu"

CFLAGS="-march=pentium4 -mtune=pentium4 -pipe -O3 -msse2 -fweb -frename-registers -fforce-addr -momit-leaf-frame-pointer -fomit-frame-pointer -ftracer -mno-tls-direct-seg-refs "

CHOST="i686-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/NX/etc /usr/NX/home /usr/kde/2/share/config /usr/kde/3.3/env /usr/kde/3.3/share/config /usr/kde/3.3/shutdown /usr/kde/3.4/env /usr/kde/3.4/share/config /usr/kde/3.4/shutdown /usr/kde/3/share/config /usr/lib/X11/xkb /usr/lib/mozilla/defaults/pref /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/control"

CONFIG_PROTECT_MASK="/etc/eselect/compiler /etc/gconf /etc/terminfo /etc/env.d"

CXXFLAGS="-march=pentium4 -mtune=pentium4 -pipe -O3 -msse2 -fweb -frename-registers -fforce-addr -momit-leaf-frame-pointer -fomit-frame-pointer -ftracer -mno-tls-direct-seg-refs  -fvisibility-inlines-hidden"

DISTDIR="/usr/portage/distfiles"

FEATURES="autoconfig distlocks sandbox sfperms strict userpriv usersandbox"

GENTOO_MIRRORS="http://ftp.ucsb.edu/pub/mirrors/linux/gentoo/ http://gentoo.seren.com/gentoo http://gentoo.chem.wisc.edu/gentoo/"

LDFLAGS="-W1"

MAKEOPTS="-j3"

PKGDIR="/usr/portage/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/usr/local/portage /usr/local/gentoo-de"

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

USE="x86 X alsa apache2 apm audiofile avi bash-completion berkdb bitmap-fonts bzip2 bzlib cdparanoia cdr cli crypt cups curl directfb dri dvd dvdr eds emboss esd ethereal exif expat fam fbcon ffmpeg flac foomaticdb gd gdbm gif glut gphoto2 gpm gstreamer gt gtk2 guile hal idn imap imlib ipv6 isdnlog java jpeg junit lcms ldap libg++ libwww lm_sensors mad maildir mhash mikmod mime mmx mng motif mozilla mp3 mpeg mysql ncurses nls nptl nptlonly nvidia ogg oggvorbis opengl pcre pda pdflib perl php pic pie pnc png posix ppds pppd prelude python qt quicktime readline real reflection samba sasl sdl session slang smartcard smime snmp socks5 spell spl sse sse2 ssl svga tcltk tcpd tetex tiff truetype truetype-fonts type1-fonts udev unicode usb userlocales v4l v4l2 vhosts vorbis win32codecs wma xml xml2 xorg xpm xv xvid zlib video_cards_nvidia userland_GNU kernel_linux elibc_glibc"

Unset:  ASFLAGS, CTARGET, INSTALL_MASK, LANG, LC_ALL, LINGUAS

```

```
thomson@leeamlp ~ $ id

uid=1010(thomson) gid=1010(thomson) groups=4(adm),5(tty),10(wheel),14(uucp),18(audio),19(cdrom),35(games),80(cdrw),100(users),250(portage),501(mount),502(scada),1001(pub),1010(thomson),1015(vmware),1016(plugdev),1018(webadmin)

thomson@leeamlp ~ $ emerge -pv udev hal dbus ivman pmount hotplug coldplug

These are the packages that I would merge, in order:

Calculating dependencies ...done!

[ebuild   R   ] sys-fs/udev-087  (-selinux) 0 kB

[ebuild   R   ] sys-apps/hal-0.5.5.1-r3  -acpi -debug -doc -pam_console -pcmcia (-selinux) 0 kB

[ebuild   R   ] sys-apps/dbus-0.60-r4  +X -debug -doc -gcj -gtk -mono +python +qt (-selinux) +xml* 0 kB

[ebuild   R   ] sys-apps/ivman-0.6.8  -debug 0 kB

[ebuild   R   ] sys-apps/pmount-0.9.6  +crypt 0 kB

[ebuild   R   ] sys-apps/hotplug-20040923-r2  0 kB

[ebuild   R   ] sys-apps/coldplug-20040920  43 kB

Total size of downloads: 43 kB

thomson@leeamlp ~ $   
```

 *Quote:*   

> thomson@leeamlp ~ $ mount
> 
> /dev/hda2 on / type ext3 (rw,noatime)
> 
> proc on /proc type proc (rw)
> ...

 

----------

## erik258

you wonder *Quote:*   

> am i just supposed to yank it out? 

 

that is what I always to, of course making sure I ain't accessing it when I do so.  

I suggest your add the device in your fstab and for options, make sure to add user.  then find out the usergroup of which you must be a part if you are to mount and unmount as that user.  

then you should be able to unmount/mount it as any user, not just root.

----------

## afabco

yeah, I could do that (I'd use 'users' rather than 'user'), but why should we have to?  The whole point of this ivman/pmount stuff is to make it so we -don't- have to do anything in fstab.  Or as root.  

If we end up still having to still having to muck around in fstab just use removable media, then what's the whole point of ivman/pmount and why waste the time?

I'm not -even- going to get started on trying to do dvd-ram.  What a fsckin mess.  I got up and walked away on that one.  Deal with it tomorrow.  or next week.  Or...

----------

## erik258

good point.

yeah, removable media is kind of a pain.  First of all, you have to physically put it in or attach it to the computer!  Talk about old-school.  then with all the adding to filesystem... I try to avoid non-wire transfers, partly because it's such a pain.  Especially for me, because as you probably guessed i do lots by hand.  Put in the thumbdrive; (re)discover the right modules.  modprobe them.  find the device file.  mount it. then copy something.  then unmount, change places, and do it all again ... and so much worse for discs, stupid WORM devices.  

of course the utility of such things is undenyable, nor is it gonna dissapear.  so maybe I should look into this stuff myself.  course, it was a much bigger deal before I had highspeed. Ah, the internet  the cause of --and solution to-- so many of life's computer-related (and not so computer-related) problems.

----------

## afabco

Is that what's called 'sarcasm'?   :Wink: 

----------

## wuzzerd

 *afabco wrote:*   

> 
> 
> I use the console.  Not into these newfangled gee-yew-eye thingies.
> 
> 

 

A man after my own heart, as they say.  Altho I  cheat and use new fangled BIG fonted terminals in gooey so I can see em.

So I get the new udev 087 and kde 3.5.2 allofasudden starts mounting these things.  Aha I say lets see what happens in a good ole cli terminal.

Nothing, I have to mount the usb things by hand.  

What does kde know that we don't.

I have placed the following entries in my fstab to cover the unlikely case that I plug in all three of my usb toys at once:

```

/dev/sdb1       /media/usb1     auto auto,users,noatime 0       0

/dev/sdc1       /media/usb2     auto auto,users,noatime 0       0

/dev/sdd1       /media/usb3     auto auto,users,noatime 0       0

```

At some point if motivation hits, I'll try to figure out what ubuntoo is doing with gnome and stuff in my laptop.

----------

## urcindalo

Oops! I posted a new thread and didn't notice this was here.

Anyway, I reproduce here what I've posted in it, so any moderator is free to remove the other  :Rolling Eyes: 

Notice I say that I've been able to install a Gentoo box where the user can unmount in KDE the removable devices he plugs in through HAL+DBUS+UDEV. Unfortunately I don't know how to solve this issue for my own  :Confused: 

----------

Thanks for reading this. I know this has been asked and answered a zillion times in these forums, but I'm really confused. I don't know either if this is the best forum to place this question.

Over the weekend I've installed Gentoo 2006.0 x86 on my brother's Pentium4. Everything was working fine, and under KDE 3.4.3 he was able to umount as user the devices he mounted. I set up his box with HAL + DBUS + UDEV.

The thing is that, with the same set up, I can't umount devices as a regular user in my AMD64 box (Gentoo installed more that a year ago and kept up-to-date on a daily basis). My fstab has no reference whatsoever to removable devices, and I can confirm they mount under /media with myname:users ownership when they are plugged in. However, if I try to umount them, I get a message from kio_media_mounthelper telling me /dev/hdc (for instance) is not in fstab and I'm not the root user.

I use:

* dbus 0.60-r4

* hal 0.5.5.1-r3

* udev 087

I tried downgrading udev to 079-r1, and also updating it to 090, to no avail.

I wonder if this has something to do with dates. Take a look at this sequence when inserting a USB pendrive:

1) Before inserting

```
/media $ ll

total 0

-rw-r--r-- 1 root root 0 may  2 12:21 .keep
```

2) After mounting - LOOK AT THE DATE

```
/media $ ll

total 10

-rw-r--r-- 1 root   root      0 may  2 12:21 .keep

drwx------ 3 myname users 10240 ene  1  1970 sda1
```

3) root umount (as my user I can't). The date changes to present

```

/media $ sudo umount /dev/sda1

/media $ ll

total 0

-rw-r--r-- 1 root root  0 may  2 12:21 .keep

drwxr-xr-x 2 root root 88 may  3 11:33 sda1
```

4) My regular user can now safely eject the drive from KDE, but the directory persists

```

/media $ ll

total 0

-rw-r--r-- 1 root root  0 may  2 12:21 .keep

drwxr-xr-x 2 root root 88 may  3 11:33 sda1
```

5) I have to manually delete the directory

```
/media $ sudo rm -rf sda1

/media $ ll

total 0

-rw-r--r-- 1 root root 0 may  2 12:21 .keep

/media $
```

I wonder if what is happening is (I'm no programmer, so I'm guessing): the drive is first mounted by a root daemon, which then allows my user to mount it. But, since during the process the user's permissions date is much older that root's, user can't unmount the device because root also mounted it at a later date.

Is this scenario possible, or I'm totally nuts?

If I'm not, how can I correct the user's mount date?

----------

## urcindalo

Nobody knows how to solve this regular-user-can't-unmount issue?

----------

## afabco

regarding gnome-volume-manager and kde-volume-manager (etc), since I don't use them, I can't really provide a definitive answer as to how they do it.  My guess is that they run as a user (or group) that is allowed to mount and umount, probably the user ivman, at a guess.

So since the user that actually mounts a device is, say, ivman, the user needed to umount is ivman.

Now, since the logged in user is in group 'plugdev' (per pmount's instructions), well, I would think that would allow the pmount and pumount to work, but apparently not.

So, to answer the question 'has the regular-user-can't-unmount been resolved', I have to say the answer is 'no, not without serious system compromise or ugly hack'.  

I would be thrilled to be shown to be wrong.

----------

## UberLord

Try eject-2.1.4-r1

----------

## afabco

thomson@green ~ $ emerge -pv eject

These are the packages that I would merge, in order:

Calculating dependencies ...done!

[ebuild   R   ] sys-apps/eject-2.1.4-r1  +nls 0 kB

Total size of downloads: 0 kB

thomson@green ~ $ eject /media/LexarUSB/

Error: device /dev/sda was not mounted by you

eject: unmount of `/media/LexarUSB' failed

thomson@green ~ $ ls -ld /media/LexarUSB/

drwxrwx--- 8 ivman plugdev 4608 Dec 31  1969 /media/LexarUSB/

thomson@green ~ $ id

uid=1010(thomson) gid=1010(thomson) groups=4(adm),5(tty),10(wheel),14(uucp),18(audio),19(cdrom),35(games),80(cdrw),100(users),250(portage),501(mount),1001(pub),1010(thomson),1015(vmware),1016(plugdev),1018(webadmin),1200(scada)

----------

## urcindalo

 *afabco wrote:*   

> So, to answer the question 'has the regular-user-can't-unmount been resolved', I have to say the answer is 'no, not without serious system compromise or ugly hack'.  
> 
> I would be thrilled to be shown to be wrong.

 

Well, prepare yourself to be thrilled   :Laughing: 

As I said before, I got it working in the stable x86 box I installed on my brother's computer over last weekend.

This week, I've been doing a fresh stable AMD64 installation on one of my free partitions, following the official AMD64 installation handbook. The only difference is that I didn't boot from the installation CD, but I chrooted into the installation partition from my current more-than-a-year-old AMD64 system.

I've installed a pretty basic system. I followed the guide to the letter and only installed kde-meta and nvidia drivers as extra packages, and added hald to my default level. Also, all of my config files have been inherited without modification from my default system: xorg.conf, hostname, rc.conf.. (you get the idea). Obviously, fstab is not the same  :Wink: 

The thing is when I booted into the new system, and after configuring KDE for the first time for the newly created regular user, I was able to mount and unmount as a regular user the USB sticks I threw at it.

So my question is: why is it working in fresh installations and not on my old one? Since it is obvious it has nothing to do with age, what extra package(s) or config file(s) could be possibly conflicting with a fresh working setup?

Just in case, here are the services running in the fresh and user-unmount-capable system:

```
$ sudo rc-update -s

           alsasound | boot default

            bootmisc | boot

             checkfs | boot

           checkroot | boot

               clock | boot

         consolefont | boot

     courier-authlib |

       courier-imapd |

   courier-imapd-ssl |

       courier-pop3d |

   courier-pop3d-ssl |

         crypto-loop |

               cupsd |

         dante-sockd |

                dbus |

          domainname | boot

                 gpm |

                hald |      default

              hdparm |

            hostname | boot

             hotplug |

             keymaps | boot

                lisa |

          lm_sensors |

               local |      default nonetwork

          localmount | boot

             modules | boot

            net.eth0 |      default

              net.lo | boot

            netmount |      default

                nscd |

             numlock |

             pwcheck |

             reslisa |

           rmnologin | boot

              rsyncd |

           saslauthd |

                slpd |

                sshd |

           syslog-ng |      default

             urandom | boot

          vixie-cron |      default

                 xdm |      default

                 xfs |

              xprint |
```

And here are the services in my user-unmount-incapable system:

```
 account_setiathome. |

                acct |

               acpid |

           alsasound |      default

             anacron |      default

                apmd |

                 atd |

                atop |

           blacklist |      default

               boinc |      default

            bootmisc | boot

             checkfs | boot

           checkroot | boot

    client_state.xml |

 client_state_prev.x |

               clock | boot

         consolefont | boot

     courier-authlib |

       courier-imapd |

   courier-imapd-ssl |

       courier-pop3d |

   courier-pop3d-ssl |

         crypto-loop |

               cupsd |      default

         dante-sockd |

                dbus |

             distccd |

          domainname |      default

              esound |

            fail2ban |

            festival |

         firestarter |

                 gpm |      default

                hald |      default

             hddtemp |

              hdparm |

            hostname | boot

             hotplug |

           ip6tables |

            iptables |      default

               ivman |

             keymaps | boot

               kudzu |

                lisa |      default

          lm_sensors |

               local |      default nonetwork

          localmount | boot

            lockfile |

 master_setiathome.b |

     mit-krb5kadmind |

         mit-krb5kdc |

             modules | boot

               mysql |

                 nas |

            net.eth0 |      default

              net.lo | boot

            netmount |      default

                 nfs |

            nfsmount |

                nscd |

          ntp-client |      default

                ntpd |      default

             numlock |

       pg_autovacuum |

             portmap |

             postfix |      default

          postgresql |

             privoxy |      default

             proftpd |      default

            projects |

             pwcheck |

             reslisa |

           rmnologin | boot

              rsyncd |

               samba |      default

           saslauthd |

 sched_reply_setiath |

 sched_request_setia |

            sendmail |

              serial | boot

               slapd |

                slpd |

              slurpd |

               snmpd |

           snmptrapd |

               spamd |

                sshd |      default

 statistics_setiatho |

           syslog-ng |      default

                 tor |      default

             unicode |      default

             urandom | boot

          vixie-cron |      default

              vmware |      default

                 xdm |      default

                 xfs |

              xinetd |

              xprint |
```

----------

## coolsnowmen

 *Quote:*   

> you wonder
> 
>  *Quote:*   
> 
> am i just supposed to yank it out?
> ...

 

VERY bad Idea with out sync writting.  Make sure to mount with the sync option if you do that.

For those with GUI's, install kde 3.5.2 (works with the new hal/dbus/udev etc)

For those without, real ALL that is ivman

afabco, 

run ivman as the user if you want the user to be able to unmount it, but becasefull aparently "multi instances of ivman can cause race conditions"

----------

## urcindalo

 *coolsnowmen wrote:*   

> For those with GUI's, install kde 3.5.2 (works with the new hal/dbus/udev etc)

 

You don't need version 3.5.2. KDE 3.4.3 is equally suitable, as I said twice in this thread, after a fresh installation (for instance, in my previous post).

The question is: why have I lost that capability over time?   :Confused: 

I need help to find the crucial difference between my two set-ups

----------

## coolsnowmen

That may be true, but I am not the only person who couldnt get auto mounting to work in 3.4 and the simple upgrade worked.  In my mind, its less hastle, (emerge and walk away)

----------

## afabco

ok.  It works in kde.  That's fantastic.  Glad to hear it.

I don't use kde.  I don't want to use kde.

I don't use gnome.  I have no desire to use gnome.

I'm an old guy.  A 'console curmudgeon'.

I do run fluxbox sometimes, mostly for firefox and multiple console windows.

How do I do it  from a console?

So, to paraphrase monty python, "I'm noowt thrilled yeht".    :Smile: 

----------

## afabco

 *Quote:*   

> For those without, real ALL that is ivman 
> 
> afabco, 
> 
> run ivman as the user if you want the user to be able to unmount it, but becasefull aparently "multi instances of ivman can cause race conditions"
> ...

 

I'm sorry, I'm not sure I understand.  Are you saying log in as ivman?  or su to ivman?

----------

## urcindalo

 *afabco wrote:*   

> ok.  It works in kde.  That's fantastic.  Glad to hear it.
> 
> I don't use kde.  I don't want to use kde
> 
> ....
> ...

 

First of all, there's no need to be rude (or so it seems).

Secondly, I'm no programmer, but I don't think KDE is responsible for that capability. It is merely using it, because it is already present.

My point is that if the capability is there after a fresh install, we must have changed some unmount-important config file or package over time. We could solve the issue by finding it out.

Remember I use the same KDE version in both setups, but the old one does not allow me to unmount as user. In no way I was forcing you to use KDE, and much less to do a fresh install.

----------

## coolsnowmen

afbco,

you can run the program ivman (/usr/bin/ivman) as a normal use (in the plugdev group)

http://gentoo-wiki.com/HOWTO_ivman#Starting_Ivman_as_a_regular_user

then your ivman rules are located in ~/.ivman/

----------

## afabco

urcindalo:

Deepest apologies.  Did not mean to sound rude, not at all.  Was actually trying for a bit of levity in my frustration.  Apparently didn't come across that way.  This means I should probably keep my day job?    :Smile: 

Also, now I understand what you were saying, and it bears looking into.  

I also stumbled onto another thread about using autofs to do the mounting and umounting.  I'm not sure how that would  (or would not) fit in, but I'm going to explore that a bit.

----------

## coolsnowmen

I've looked into autofs, AFAIK, it requires fstab entries to be quite defined which if you can do that, then ivman requires almost no configuration.  To me, autofs is only good for the case where you know ahead of time exactly what device will be plugged in.

Autofs does seem usefull for say, only mounting /boot when you need it. But as far as the 'usb problem', hal based solutions are the only way to go.

----------

## urcindalo

 *afabco wrote:*   

> urcindalo:
> 
> Deepest apologies.
> 
> ...
> ...

 

There are no apologies to accept  :Wink: 

In fact, after thinking about it, your answer was quite useful. If you don't use any GUI at all our problems arise, most probably, from some "system" file or package. I mean, I'm sure user-unmount will work in any fresh installation without further installation of anything else (I installed kde-meta both times  :Sad:  )

I don't mind to boot back and forth between my old and my fresh Gentoo systems, but unfortunately I lack the knowledge to carry out much testing on my own. I can only be the hands of some brighter mind  :Smile: 

Regarding this, in a matter of minutes you can also have a fresh installation in any spare partition you might have. This way you too can investigate the issue.

----------

## jmedin

On my system I noticed that if I click on the desktop icon as soon as it appears, I can unmount it by using right click and doing a "Safely Remove". If I don't click the icon, after a short wait, the device automatically mounts. If I then try to "Safely Remove" the device, I get the error.

What I suspect is that there is a file from a previous install that did not get cleaned up. I searched and found the file "/etc/dev.d/default/10-hal.dev", this file does not belong to any installed package. I deleted this file and this stoped the USB device from being automatically mounted.

----------

## jmedin

Ignore what I just said in the previous post. It's late and this problem has been bugging me for a while.

What you need to do is either, not have ivman running at all;

rc-update del ivman

/etc/init.d/ivman stop

Devices will not get auto mounted. You just need to click the icon on the desktop (if you have icon creation enabled) or go to media:/ in konqueror

If you want auto mounting, you need to leave ivman running but also start an instance of ivman for the logged in user as per the ivman man page.

----------

## bec

Thanks jmedin!

Running ivman as a service, and an instance for the logged user (simlinking /usr/bin/ivman to ~Desktop/Autostart) definitively solves all problems: the devices get automounted and can be safely removed!

----------

