Custom Mounts In udev For Non-Techs

One of the only difficult aspects I've found about transitioning to SimplyMEPIS is that while Ubuntu relied on fstab (which sometimes did make me want to f*ing stab things) for mounting drives, SimplyMEPIS uses the evidently-more-popular method called udev.

I keep all of my music, photos, videos, etc. on an external drive partition named Biggus after the Monty Python character. ;) When I'm using the command-line or a program dialog that doesn't show individual drives, it's much easier if I know Biggus is always at /media/biggus than wondering which /media/sd* it's been stuck at this time. Same goes for things like my iRiver H10 media player, external backup partition, and so forth.

So, onwards to udev... I understood the basics quickly enough, but the way to really use it eluded me for a couple of days, in part because I was using a seriously-outdated guide. (Having barely passed C programming long ago, I knew I was in trouble when the howto made reference to one of its "easier" commands.) Thankfully I found Arch's Map Custom Device Entries with udev wiki article...

Since udev is capable of so many things that it seems dauntingly complex at first, I'll explain how I met success. I'll probably need the mini-guide in the future, and maybe it will help some other hapless end-user.


1. Open a terminal (console) window and use su to log in as root. It'll make the rest of this a bit easier.

2. First thing to do is find out where in /dev the drive partition is at. Go into the file manager, click on the one you're interested in, and look at the location line -- should be something like /media/sdb1. Now, open a terminal, type mount; the correct /dev/ location is right next to the mount point you just saw. Write it down!

4. Now, in the terminal window, type this in -- but replace "yourdrive" with the location you noted:
udevadm info -a -p $(udevadm info -q path -n yourdrive)

Copy/paste the results into a text editor, then open another editor window that you'll leave blank. Search the mess for "serial", copy that whole line into the empty window, then type a comma and a space after it. Search for "partition", copy its whole line, then paste it right after the other one. The results should look like this, but might have different numbers:
ATTRS{serial}=="23541325r325", ATTRS{partition}=="1"

6. Back in the terminal as root, type this in (replace "editor" with gedit or whatever you just used):
editor /etc/udev/rules.d/00.rules

A blank editor window should come up; copy/paste the single line you'd just put together. Add a comma after it and a space, then type this -- and where I have biggus, put the name you want to use:
SYMLINK+="biggus"
Save it and close the window...we're almost done!

7. Back in the root terminal window one last time, type this in to make Linux notice that the rules have changed:
udevadm control --reload-rules

Remember the two locations you jotted down at the very beginning? Well, time to use them again... Type umount followed by the one that begins with 'media', so it stops existing at that spot:
umount /media/sdb1
Now tap in mount followed by the 'dev' place:
mount /dev/sdb1


If all went as planned, your drive should now be mounted just where you wanted it! Once it works, if you want to set up other drives or partitions, just follow all of the steps again but give your "rules" file a new line of its own.

If things didn't quite turn out as hoped, go to the ArchWiki article I'd mentioned near the beginning... Evidently in Arch and some other distros, you have to also edit fstab so it knows where to mount your drive. If doing that (which I didn't have to do in SimplyMEPIS) doesn't work, try following their guide and hopefully that will do the trick. Good luck!

No comments:

Post a Comment