# udev + unplugging usb drive > freeze

## baeksu

I've been trying to fix up some kind of a automagical mounting for my system. I have a external usb harddisk connected to my laptop, and I use it as my music library and backup space. I don't want to keep the disk running all the time, so I needed something to automount it when I turn it on and unmount it when I turn it off.

 I've tried ivman, gnome-volume-manager, submount and autofs.

 All of the solutions I've tried rely on udev. Unfortunately, all of them (except for autofs, which is what I'm using now) also cause a problem.

 If I unplug/turn off the harddisk while it's still mounted, my machine freezes. In the case of ivman and gvm, which use hal, manually unmounting from terminal also triggers this freeze.

 I'm still able to use mouse and type, but I can't start any programs, even from a terminal. Once I happened to be running top on one of the terminals, and I saw the load average climb way high. It reached 250 when my machine became completely unresponsive.

 Most programs keep running until they try to access my laptop's harddisk. Naturally I haven't been able to use dmesg to get any output. I'm thinking something (maybe udevd?) is blocking i/o activity to all of the harddisks.

 I have 050 udev emerged, and am running ck-based kernels. I've tried with several different patches, including the plain ck-patch with vanilla kernel. Haven't tried with a plain vanilla kernel or gentoo-kernels.

 If anyone has similar experiences (couldn't find any in the forums yet) or solutions, I'd greatly appreciate it.

----------

## wnelson

udev is up to 58. What version of the kernel are you running?

First I think you would want to unmount it first before unplugging it.

----------

## baeksu

I started with 2.6.10, now I'm at 2.6.11 (tried .12-releases, but those won't work with nvidia 6111).

 I didn't want to try other versions of udev, cause I couldn't find anyone with similar problems, so I didn't think it's a version-specifig bug. 58 is marked ~x86, and I didn't see anything in bugs.gentoo.org to indicate that version would work differently.

 ivman and gvm (and submount, I think) are supposed to do the unplugging when the drive becomes unplugged. If I had to manually unmount it each time, there wouldn't be much use for those programs.

 Unfortunately, with ivman and gvm, the system would freeze if I did unmount manually. Plus, hal writes entries in fstab, and I would get multiple entries in mtab eventually as well (but that's just my personal gripe with hal).

 Autofs mounts/unmounts automatically depending on whether there are any processes that access the connected filesystem. As it means that the filesystem is unmounted before I disconnect the drive, it doesn't usually cause any problems, which is why I'm using it right now.

 A while ago, I had a slightly faulty usb drive that would turn itself off randomly. On a couple of these occasions, the system would freeze in a similar way, even though I used autofs. That's why I'm thinking it's a udev problem, as udev is the only thing common with these four automounters (ivman, gvm, submount, autofs).

----------

## wnelson

Are there any message in the system log?

----------

## wnelson

BTW I did take a peek at my udev v58 and there are changes that may effect the way usb devices are handled. You may want to upgrade to that version.

----------

## wnelson

I also came across this site http://users.actrix.co.nz/michael/usbmount.html

I don't know if it may help or not?

----------

## baeksu

Maybe I'll have a go with a newer version of udev. I'm just surprised that I couldn't find anyone else that suffered from the same problems.

 Also, while I'm at it, I'll try if I can reproduce the freeze with a plain vanilla kernel. Though if it comes to a choice between the schedulers from ck-sources and a utopia stack, I'll choose the former, no doubt.

----------

## Pseud

I am getting system freezes too.

I posted my gripe in another thread ... Might want to take a look and see if its a similar problem.

https://forums.gentoo.org/viewtopic-t-352444-highlight-.html

Btw, I'm using udev 0.58 and still have the issue.

----------

## Pseud

I'll save you the trouble of trying to find my post in that other thread:

 *Quote:*   

> 
> 
> I get system freezes too! Everything locks up, the keyboard, mouse ... nothing works, and I'm forced to use the reset button.
> 
> I have tried hard to figure out what causes it, but not very lucky yet. But I've noticed one pattern ... it always seems to happen a few minutes after I use a USB device like a usb digital camera or my ipod. I think our problems might be similar.
> ...

 

But do look at that thread to see if the original post seems to be the same issue.

----------

## baeksu

 *Pseud wrote:*   

> But do look at that thread to see if the original post seems to be the same issue.

 

 The original post doesn't seem to be related. My freezes usually came after disconnecting a mounted drive (or unmounting it manually). I think it's something related to HAL, as removing it removed the freezes.

 With HAL, at the beginning of the "freeze" mouse and keyboard would still be working, but I wouldn't be able to start new apps (or even do 'ls' in terminal). I think it's something to do with harddisk access, cause the hd in my laptop (as well as external usb disks) would just stop. No leds or anything. Eventually the whole machine freezes.

 Anyway, I've been using autofs for a while now without problems. I really don't like HAL, mainly because it writes entries to your /etc/fstab. I hope the gentoo devs figure out a little nicer way of doing stuff with the gentopia stack.

----------

## Pseud

Ok, found another one; this sure is relevant!

https://forums.gentoo.org/viewtopic-t-281056-highlight-usb+system+freeze.html

----------

