OpenWrt Forum Archive

Topic: Howto mount drives by ID ( /dev/disk/by-id )

The content of this topic has been archived on 15 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Maybe this is useful for someone...

Before we begin... you might want to disable automounting of devices...
Do this by simply putting hashes ("#") in front of the following lines in the file /etc/hotplug.d/block/10-mount

"mkdir -p /mnt/$device"
"mount /dev/$device /mnt/$device"
"umount /dev/$device"

(You can of course also delete the file, however you might need it some time later...)

-----

You need to install the util-linux-ng mount-utils, because the busybox mount command doesn't work by IDs.
Do the following:

opkg update
opkg install mount-utils

The second command will fail, because /bin/mount and /bin/umount already exist. -> Simply delete those two and try again. They are only symlinks to the busybox-executable.

If you want to revert to the original status some time later, do:

opkg remove mount-utils
cd /bin
ln -s busybox mount
ln -s busybox umount


-----
Howto mount drives by ID ( /dev/disk/by-id )
-----

Since the last release, the /dev/disk dynamic directory has disappeared. However you can get it back.

opkg update
opkg install udev
opkg remove udevtrigger

Nevertheless you must also start the udev daemon somehow:

Paste the following (excluding the lines) into the new file /etc/init.d/udev

-------------------------------------------------------
#!/bin/sh /etc/rc.common
# Copyright (C) 2009 OpenWrt.org

START=19
start() {
#make sure deamon is not running
        killall udevd > /dev/null 2> /dev/null
#start the deamon
        udevd --daemon --debug-trace
#Force it to evaulate already connected devices
        udevadm trigger
#This should block until all events are processed - however it does not work currently
        udevadm settle
#Until someone fixes it ... 5 seconds longer to boot...
        sleep 5                                 
}

stop() {
        killall udevd
}

--------------------------------------------------------------

... and execute the following commands afterwards:

chmod 755 /etc/init.d/udev
/etc/init.d/udev enable

Connect a USB-Stick or USB-Enclosure and reboot your box.
You should now see the /dev/disk/ directory.

I assume you have already tried mounting the device traditionally ("mount /dev/sda1 /mnt" or so )
If this works, you should now be able to mount the device via its ID too.
In my case:

"mount /dev/disk/by-id/usb-Kingston_DataTraveler_2.0_5B81DC001388-0:0-part1 /mnt"


(You might want to test whether your hotplug-commands still work...)

------
Howto mount devices by ID at startup
------

If you want, you can use the config infrastructure of openwrt to mount devices by id at startup:

Go to /etc/config/fstab (not /etc/fstab!) and add a block somewhat like this
-------------------------------------------------
config mount
        option target   /mnt
        option device   /dev/disk/by-id/usb-Kingston_DataTraveler_2.0_5B81DC001388-0:0-part1
        option fstype   ext2
        option options  rw,sync
        option enabled  1
-------------------------------------------------

reboot -> mounted.

---

lg, Mr.M

(Last edited by mr.m on 28 Nov 2009, 03:14)

Hi there,

I just found out that you have to install mount-utils. The busy-box mount does not work by-id.
Therefore I updated the the first post of this howto topic accordingly.

lg, Mr.M

The discussion might have continued from here.