Removable Media - Automount

From NAS-Central Buffalo - The Linkstation Wiki
Jump to: navigation, search

This article Based on work by Myno, andre, mindbender, downlalaway, Thorongil, frontalot, and TcT. Originally by downlalaway at

This is a basic run through of USB devices connecting for Debian on an PPC LinkStation. See Murasaki LinkStation's USB hot-plugging system for information about removable Media with the original Firmware or OpenLink on, for example, the LS1 and LS2.

On the PPC LinkStation the USB hard drive is USB 2.0 at 3Mb/s (on a laptop HD). NB. This was based on using the original kernel #990 conversion of the LS 1 and not the Freelink project. It has been updated for use with Freelink 1.11 but requires run-throughs by others to check. USB and hotplug was/is a little flakey on 2.4 kernels in recognising devices. A reboot while the device is in should make things work. The 2.6 debian kernel is highly recommended if hot-swapping of usb devices might occur.

USB Removable Media: Automount

Note to kernel 2.4.17_mvl21-sandpoint #997 users (ships with Freelink 1.1.1): You need to move a few modules out of the way before you can continue:

mv /lib/modules/2.4.17_mvl21-sandpoint/kernel/drivers/scsi/scsi_mod.o /root/            
mv /lib/modules/2.4.17_mvl21-sandpoint/kernel/drivers/scsi/sd_mod.o /root/              
mv /lib/modules/2.4.17_mvl21-sandpoint/kernel/drivers/usb/storage/usb-storage.o /root/  

Reboot when done.

Note to Linkstation HG users: You may also need to do this; adjust the paths to your needs.

I found this to be the easiest way to automount removable USB devices:

apt-get install autofs gawk wget bzip2 make
tar -xjf 
cd mounttero-0.5 
/etc/init.d/autofs restart 
apt-get remove gawk # this step is optional 

The devices will be mounted automagically in /mnt/auto/, for example, /mnt/auto/usb/ in case of a typical USB thumb drive, and unmounted automagically after four seconds when unplugged.

Edit /etc/auto.tero and comment out all /dev/hda? entries:

#hda1 -fstype=auto,nosuid,nodev,user  :/dev/hda1 
#hda2 -fstype=auto,nosuid,nodev,user  :/dev/hda2 
#hda3 -fstype=auto,nosuid,nodev,user  :/dev/hda3 
#hda4 -fstype=auto,nosuid,nodev,user  :/dev/hda4 

The default entry for usb devices shows a single entry for each partition:

usb     -fstype=auto,nosuid,nodev,noexec,user,gid=100,umask=000 :/dev/sda1 

To access a second device, create an entry for the partitions of the next device by using the next letter:

usb2    -fstype=auto,nosuid,nodev,noexec,user,gid=100,umask=000 :/dev/sdb1 

Note (Valid for LS 1 Users): The first device plugged in, whether it use the front or rear plug, gets the first drive designation.

Kernel 2.6 (Power PC)

This will add USB Drive automounting and mount USB drives to /media/usb0,1,2,3 etc. symbolic links in /mnt/share will also be created usb0,usb1,usb2,usb3 so that they will be accessable via your samba share

apt-get remove hotplug 
apt-get install usbmount

You should change the lines in /etc/usbmount/usbmount.conf to give you more universal access

  • Line that starts FILESYSTEMS change to FILESYSTEMS="ext3 ext2 vfat"
  • Line that starts MOUNTOPTIONS change to MOUNTOPTIONS="noexec,nodev,noatime"
  • Line that starts FS_MOUNTOPTIONS change to FS_MOUNTOPTIONS="-fstype=vfat,umask=000"

These commands will create symbolic links will be into the shared filespace ( /mnt/share )

ln -s /media/usb0/ /mnt/share
ln -s /media/usb1/ /mnt/share
ln -s /media/usb2/ /mnt/share
ln -s /media/usb3/ /mnt/share

Enjoy and please carefully comment if it doesn't work or changes needed.

dynamic symlinks

If you want a symlink to automatically appear in the Samba share when a device is mounted instead of always being present, you will need to edit the scripts in /etc/usbmount/mount.d and /etc/usbmount/umount.d. Note, use the path to your shared directory, it may be different from mine.

Edit the mount.d script:

nano /etc/usbmount/mount.d/00_create_model_symlink

Add the following to the symlink creation section of the script:

test -e "/mnt/disk1/share/$name" || ln -sf "$UM_MOUNTPOINT" "/mnt/disk1/share/$name"

Edit the umount.d script:

nano /etc/usbmount/umount.d/00_remove_model_symlink

Add the following section:

ls /mnt/disk1/share | while read name; do
   if test "`readlink \"/mnt/disk1/share/$name\" || :`" = "$UM_MOUNTPOINT"; then
       rm -f "/mnt/disk1/share/$name"

See Also

Originally by downlalaway and edited by frontalot, Myno, andre, mindbender, downlalaway, Thorongil and TcT from