Monday, December 20, 2010

Ubuntu Server auto USB mounting

I finally got around to setting up the nT330i box that I purchased like 3 months ago. I wasted so much time because I thought the built-in SD card slot hooks up to a USB interface, but turns out it's hooked up to more like the SATA/IDE interface, so the SD card will only be detected if I rebooted the system, but not a hot plug. I finally figured it out by using an external USB-SD adapter, and viola, the SD card showed right up in dmesg when I plugged it in.

Anyway, here are the notes for myself so I don't ever forget how I set up the udev rules to automatically mount them using udev rules:

1. Create the file /etc/udev/rules.d/10-persistent-usb-storage.rules, and put in it the following content as one long line:
KERNEL=="sd?1", SUBSYSTEMS=="usb", RUN+="/bin/mount /dev/%k /media/usb"

2. Reload udev by running "/etc/init.d/udev reload"

Of course, after I got all of this working, then I figured out that for my purpose, I could have just installed 'usbmount', and it will automatically do all the work for me (even unmounting). So... apt-get install usbmount took care of it. The only down side is that I need to physically remove the entire USB adapter (not just the SD card), but that I can live with.

No comments: