Udev provides a means of dynamically creating devices in /dev

From NAS-Central Buffalo - The Linkstation Wiki
(Redirected from Add UDEV)
Jump to: navigation, search


Udev provides a means of dynamically creating devices in /dev.


Kernnel 2.6 and above. However, I have also had this working on 2.4.20

Installation and configuration

To install, under Debian distribution, type:

apt-get install udev

This also requires the legacy hotplug but this is slowly being removed.

udev establishes a directory /etc/udev. Within this are the configration files and rules for udev. The configuration file udev.conf can be left as installed. The rules (udev.rules and directory rules.d) will be left to the user to edit depending on the devices being used. The rules detail what is to happen on detection of certain hardware types. Descriptions can use manufacturers names or device code, pretty much anything really and wild cards can also be used. This can then indicate what kernel modules are required, permissions and launched scripts.

Another directory, /etc/dev.d is also created. This contains directorys pertaining to the type of device, say block for a scsi based device. This directory contains a file (extension of .dev) which is the script that is auto run on detection of the device. This script will perform actions depending on if the device has been 'added' or 'removed'.

Example uses

For 'hotplug' USB devices, install usbmount:

apt-get install usbmount

This installs a udev script at /etc/dev.d/block/usbmount.dev and also a bash script in /usr/sbin. A configuration file is used to determine where the media is to be mounted, defaults to /media/usb1..9. udev will auto-detect the drive and the usbmount script will mount each detected partition at /media/usb1, /media/usb2, ... On removal, the drive will be un-mounted and the device node removed.

The current version of usbmount does not support NTFS-3G. It will always use the kernel NTFS driver that has some drawbacks writing to NTFS volumes.

Applying the following patch to usbmount allows you to specify a new configuration variable USE_NTFS3G in /etc/usbmount/usbmount.conf. If this variable is set to "yes", then usbmount will utilize NTFS-3G instead of the kernel mode NTFS driver.

diff -Naur /usr/share/usbmount.old/usbmount /usr/share/usbmount/usbmount
--- /usr/share/usbmount.old/usbmount    2007-01-27 12:22:14.000000000 +0100
+++ /usr/share/usbmount/usbmount        2007-11-05 08:02:24.000000000 +0100
@@ -45,6 +45,7 @@

 # Read configuration file.
 if test -r /etc/usbmount/usbmount.conf; then
@@ -119,7 +120,11 @@

                # Mount the filesystem.
                log info "executing command: mount -t$fstype ${options:+-o$options} $DEVNAME $mountpoint"
-               mount "-t$fstype" "${options:+-o$options}" "$DEVNAME" "$mountpoint"
+                if test $fstype == "ntfs" && expr "$USE_NTFS3G" : "[yY]" > /dev/null; then
+                    mount "-tntfs-3g" "${options:+-o$options}" "$DEVNAME" "$mountpoint"
+                else
+                    mount "-t$fstype" "${options:+-o$options}" "$DEVNAME" "$mountpoint"
+                fi

                # Determine vendor and model.
@@ -166,6 +171,11 @@

 elif test "$1" = remove; then

+    # if we utilize ntfs-3g, we need to add the fuseblk fstype to allow proper unmounting
+    if [ `expr "$USE_NTFS3G" : "[yY]"` -eq "1" ]; then
+    fi
     # A block or partition device has been removed.
     # Test if it is mounted.
     while read device mountpoint fstype remainder; do

And what should you do with this patch?

Just copy & past the patch source code from above into your favorite editor and save it as "usbmount-ntfs3g.patch". Now transfer the file to your LS. After this, apply the patch as user root issuing the command
patch /usr/share/usbmount/usbmount <path>/usbmount-ntfs3g.patch
Thats it!