Layers of Layers
Have you tried adding an abstraction layer?
  • Cheat Sheets
    • Linux Commands
    • Linux Network
    • Markdown
    • Regular Expressions
    • Shell Scripting
    • SSL
    • VI
  • To Do
    • Blinkendecke
    • DIY Electronics Construction Kit from Duplo
    • Kobo Hacking
  • $FOO
  • Linux
  • Make
  • misc
  • Pretty
  • Software
  • Things

Novell Cool Solutions: Automatically Mount USB Hard Drives

Wonko| Tue 08 September 2009

I wrote this one for [Novell Cool Solutions][]: **Problem:** USB HDDS are not automounted when no GNOME or KDE session is active in SLES/SLED **Solution:** Seen working in: SUSE 10.1, SLES 10, SLED 10 OpenSuse 10.3 (see Update at end of Article) This article describes how to set a fixed mount point for USB Hard Drives and then automatically have them mounted when plugged in. I tend to be a bit detailed (chatty if you must) there is a short version of what you have to on the bottom of the page. Recent SUSE systems rely on udev, hal and DBUS to automatically mount Devices. Unfortunately the actual mount is only done if you are logged in a Gnome (gnome-volume-manager) or KDE session. (see [SLED Release Notes][]) But what if you want your drives to be automounted with another window manager or no X at all? It's actually all there, the only thing missing is a mount point and someone to do the mount. **Here's my scenario:** I've got a Notebook running as a little backup/projects/playingaround-server running SLES 10. The book only has about 40G of internal HDD space I added some USB HDD's to compensate. Since some Services cannot find their data if it is not in the place where they left it (stupid isn't it ;-) I needed the drives to be mounted exactly the same every time they are plugged in, the server is rebooted, etc. To make the mount points for the USB drives persistent i added the following lines to "/etc/fstab": wzxhzdk:0 I chose to identify the partitions on the disk by Label (LABEL=WORK-USB300). USB drives are actually linked to "/dev/sd-something" device entries by udev. But the order in which they appear is not always preserved. Someday udev might decide to use "/dev/sda" for the drive you used to find under "/dev/sdb". I used yast (system-\>Partitioner-\>...) to set the labels of my (ext3) partitions but you could use "e2label" (ext2/3),"reiserfstune -l" or the like for that. I use the "auto" option in my fstab to be able to mount the drives with "mount -a" wich is quite handy. The "hotplug" option is important to be able to boot the system without the usb drives attached. Without the "hotplug" option your system will boot into the rescue console when the drives are not present. The above is pretty low level. For the fancy stuff please "man fstab" and "man mount". So for now whenever i want my drives i plug them in and run "mount -a". Happy?... not quite. I HAVE TO MANUALLY TYPE "mount -a". NO WAY, GRRR. udev, the service doing all sorts of plugging in and out detection, was already so kind to create a "/dev/sd-something" device for our USB HDD. Why shouldn't it be able to ALSO mount them? In /etc/udev/rules.d/ you will find several .rules files. This is what udev does. Whenever it gets an event it runs through those rules and applies them. In case of a USB HDD it the rules in "/etc/udev/rules.d/60-persistent-storage.rules" are the important ones. The rule file numbering may be different. It is used to determine the order of the rules. To automatically run mount -a when a block device (HDD) is added, add a file to the /etc/udev/rules.d/ directory. **99-mount.rules:** wzxhzdk:1 I called the file 99-something to make sure that the "mount" rule is run after the /dev/sd-something device was created. Otherwise the drive could not be there yet. To activate the new rule do an "/etc/init.d/boot.udev restart" (or "rcudev restart" where it exists). To learn more about how to write rules for udev please consult: That's it. **Short Version:** Add your USB drives to "/etc/fstab" using labels to identify the partitions. Use the options "auto" to be able to mount them with "mount -a" and "hotplug" to avoid problems when the drives are disconnected. **Example:** wzxhzdk:2 Create a new rule for udev. Place a new file "99-mount.rules" in "/etc/udev/rules.d/" with the following content: wzxhzdk:3 Run "/etc/init.d/boot.udev restart" to make the rule available. **Update: OpenSuSE 10.3** The *hotplug* option of mount has been replaced by *nofail*. Same result. -\> man mount At boot mount now does care about the fifth (fs\_freq) and sixth (fs\_passno) field in */etc/fstab* when we give the *nofail* option. Thus we must set them to *0*. -\> man fstab The lines from above now look like: wzxhzdk:4 The udev rc-script has been removed. Now udev is started through */etc/init.d/boot.udev*. To reload the rules use */sbin/udevcontrol reload\_rule* -\> man udev, man udevcontrol The article was re-posted at [linux.wordpress.com][] There are some comments.

Category
Linux
Tags
Suse Hardware Storage

Page 1 / 1

Tags

  • Graphics
  • bash
  • Javascript
  • Database
  • Powersave
  • Cyanogen
  • synology
  • Ideas
  • Android
  • Security
  • Internal
  • Blog
  • Books
  • Network
  • Wood
  • Wallpapers
  • RasPi
  • Storage
  • Serious
  • KDE
  • Cookies
  • Suse
  • Themes
  • Ubuntu
  • Kids
  • Photos
  • Hardware
  • Java
  • Git
  • Pelican
  • Games
  • Virtualization
  • Eclipse

Links

  • CCC-FFM
  • Cat Content
design by jide