# USB Harddrive detection when plugged in

## patrix_neo

Hi.

I have a USB HDD plugged in all the time on my PC. As of now, I am mounting it manually to /mnt/usb.

I want to be lazy. 

Is there a way for udev to poll for plugged USB devices not mounted from the bootup? 

The USB HDD does indeed mount when I unplug and then plugs it in again.

I've tried reading the udev section of the documentation without any success.

----------

## vaxbrat

This has been working for me so long, I forget the exact combo of packages that implement it.  Don't be thrown off by the old hotplug and coldplug writeups that you might find from the obsolete guides.

I think as long as you have udev and have hald running, this should all "just work".  You may need to add yourself to some groups (disk, usb and plugdev I think) in /etc/group to have enough permissions to get the detection and mounting to not laugh in your face.  That would also be the way to keep users from being able to autoplay their drives when you don't want them to.

If you want each of your thumbs to mount to a unique mountpoint, look at how the device appears in /dev/disk/by-id when it is inserted.  For example, I have this fstab entry for one of my corsairs:

```
/dev/disk/by-id/usb-Corsair_Flash_Voyager_35c5853711b657-0:0-part1      /mnt/workstuff        auto             defaults,noatime,noauto,users 0 0
```

Otherwise it would be up to your desktop to set something up for you on /media or whatever.  Once again, KDE and gnome shoudl both be able to have the things "just work" with a popup asking whether you want to open a file manager on your newly inserted drive.  They should also be able to do a "safely remove" when you want to pull it, providing you have no windows or other things with locks on the drive directories.

----------

## patrix_neo

Thanks for the answer dear guru.  :Smile: 

I don't know if I have been unclear with my post or not. I am so often at times like these, so bare with me.

This is what I have:

udev, dbus, hald (with hotplug) running

GNOME is making my USB LaCie 500GB disk appear when I stick this in to a USB port. No problem. My normal user has full access to it.

I scrapped coldplug a while back though. I think it was adviced to do so in some situations. I dont really remember now.

What I want is this:

I have my LaCie already connected and boots up in gentoo.

If I use your /etc/fstab syntax will I get my LaCie automounted and appear under /media at boot time?

I'm at work and don't want to fiddle with this remotely.

Thanks again for your input!

----------

## vaxbrat

udev will populate that /dev/disk tree for you so is present at boot.  The old coldplug has been absorbed by udev.

----------

## patrix_neo

Thanks. I did use that fstab syntax and applied to my own USB drive and it worked. I will play around and see if I can make GNOME see it automagically if I mount it in /media/disk. 

But thanks for an elegant disk-mount-solution!

----------

