Murasaki LinkStation's USB hot-plugging system

From NAS-Central Buffalo - The Linkstation Wiki
Revision as of 03:59, 28 June 2006 by Ramuk (Talk | contribs)

Jump to: navigation, search

Murasaki - 'Another HotPlug'


The original LinkStation firmware and the OpenLink firmware use a software called Murasaki for handling the USB hot-plugging of printers and hard disks. [Murasaki] is not some special Buffalo software, but a free alternative hot-plugging framework for Linux. It replaces Linux's normal hot-plugging framework HotPlug. It is unknown why Buffalo / MontaVista went for Murasaki instead of the standard hot-plugging framework. But anyhow, Murasaki is suitable for the desired task.

The version 0.6.12 that comes with the mipsel-hdhlan LinkStation 2.05 firmware is rather old. That version also is incomplete. The components which are not used for USB hot-plugging are not included. However, the missing components, e.g. FireWire support, don't make much sense on the LinkStation and the old version is nevertheless functional.

Adding Support for Other Devices

Before you start to mess around with Murasaki, please be aware that you should possess some understanding of Murasaki, Linux, and shell scripting. In short, you should know what you are doing.

Murasaki is not limited to handling only printers and hard disks. It can handle other types of USB devices too. However, the necessary drivers (kernel modules) must first be built and installed on the LinkStation. Then the Murasaki configuration files need to be adapted. The Murasaki files which need to be touched are:

/etc/murasaki/murasaki.usbmap To map devices with unknown ids to a driver.

To find out the values for an entry you should plug in the unknown USB device and then fetch the data from the syslog log file /var/log/linkstation.log. Some entries can also be found in [[1]].

/etc/murasaki/ To map device types or module names to corresponding start-stop scripts which are called when a device of a certain type is plugged-in or a certain module is loaded. Also, the scripts are called after a device or module is removed. The format is

device-name script ...

for devices, or

module-name script ...

for modules. The first argument to the scripts is either start or stop to identify the actual event.

Start-stop scripts should be placed in /etc/murasaki/bin. The existing script in that directory can serve as an example. is the script which is supposed to mount USB disks, once they are plugged in.

/etc/murasaki/murasaki.precall (not used by by the stock LinkStation firmware) The file has a very similar function to The difference is when the scripts are called. murasaki.precall scripts are called before a device is loaded and before a device is unloaded. Scripts specified in are called after a device is loaded and after a device is unloaded.

/etc/murasaki/murasaki.depend: Module dependencies. This file specifies kernel module dependencies related to USB. Typically, a USB device driver at least depends on the usbcore module. The format of an entry is

dependent: depends ...

typically an entry looks like

dependent: usbcore

/etc/murasaki/murasaki.sticky (not used by by the stock LinkStation firmware) A list of modules which are not unloaded, even if a hot-plug remove event happens. This is useful for devices which are regularly plugged-in and out at a high frequency.


Supporting USB Memory Sticks and Other USB Storage Devices on stock mipsel-hdhlan firmware refuses to mount USB memory sticks or any other USB storage device which doesn't identify itself as a hard disk or optical disk. The culprit (bug or feature?) seems to be the program /usr/bin/parse_usbscsi which is used by to identify USB disks. A potential workaround is to add the following lines to, right after the call to /usr/bin/parse_usbscsi:

# HACK for mounting USB memory sticks.
# The above /usr/bin/parse_usbscsi doesn't identify
# them as usable storage device.
awk '$1 ~ /Host/ && $3 ~ /usb-storage/ {
          printf "/dev/sd%c\n", substr($2, 5, length($2) - 5) + 97
}' /proc/scsi/usb-storage-*/* >>/mnt/usbinfo/list

Please note that this hack ignores many finer details of identifying a disk. Also, the remaining unchanged parts of the script will not only mount the found memory stick but also share it via SAMBA, AppleTalk, and provide access to the data on the stick via ftp (if any of these services is configured). This may not be desirable - depending on the data on the stick. You will also see that SAMBA and AppleTalk are restarted.

Allowing More than 1 USB disk, as-delivered, just mounts the first USB disk found. This is in line with Buffalo's product description. If one feels adventurous this can be changed in The code was originally in and has just been commented out. The commented-out sections need some minor changes to get them to work again.