DM355 USB Drive Automounting

From Wiki
Jump to navigationJump to search

These commands must be executed while logged in as root from the serial console of the DM355 EVM. These commands can be performed by selecting all the text in the blue box and pasting it into the terminal program. Alternatively, a line at a time may be selected and pasted.

This creates the udev rule that identifies a USB drive with the words "Flash Disk" in the product string, and causes the script /etc/dev.d/usb/flashdisk.dev to be executed to mount or unmount the drive.

Code: Creating /etc/udev/rules.d/10-udev.rules
 
echo 'BUS=="usb", KERNEL=="sda1", SYSFS{product}=="Flash Disk",  NAME="usb/flashdisk"'  >/etc/udev/rules.d/10-udev.rules
echo 'BUS=="usb", KERNEL=="sda1", SYSFS{product}=="*Cruzer*",    NAME="usb/flashdisk"' >>/etc/udev/rules.d/10-udev.rules
echo 'BUS=="usb", KERNEL=="sda1", SYSFS{product}=="Flashdrive*", NAME="usb/flashdisk"' >>/etc/udev/rules.d/10-udev.rules
chmod 644 /etc/udev/rules.d/10-udev.rules
  


Sometimes the SYSFS{product} string will not contain the pattern Flash Disk. You can determine the product string by looking at the output of the following command. See here for udev pattern matching rules.

Code: Determining product identifier string
 
udevinfo -a -p /block/sda/sda1
  


This creates the script that actually does the mounting or unmounting, based on the passed argument.

Code: Creating /etc/dev.d/usb/flashdisk.dev
 
echo '#!/bin/sh' >/etc/dev.d/usb/flashdisk.dev
echo 'if [ "$ACTION" = "add" ] ; then' >>/etc/dev.d/usb/flashdisk.dev
echo '  /bin/mount /mnt/usb' >>/etc/dev.d/usb/flashdisk.dev
echo 'elif [ "$ACTION" = "remove" ] ; then' >>/etc/dev.d/usb/flashdisk.dev
echo '  /bin/umount /mnt/usb' >>/etc/dev.d/usb/flashdisk.dev
echo 'fi' >>/etc/dev.d/usb/flashdisk.dev
chmod 755 /etc/dev.d/usb/flashdisk.dev
  


This line must be added to /etc/fstab to mount the USB drive at /mnt/usb. Use 'cat /etc/fstab' to make sure the line is not already present in the file.

Code: Addition to /etc/fstab
 
echo '/dev/usb/flashdisk /mnt/usb     auto    auto,ro                         0 0' >>/etc/fstab