Difference between revisions of "Connect multiple USB devices to the LinkStation via a USB hub"

From NAS-Central Buffalo - The Linkstation Wiki
Jump to: navigation, search
Line 165: Line 165:
  
 
[[Category:USB]]
 
[[Category:USB]]
 +
[[Category:Howto]]

Revision as of 03:47, 28 June 2006

This article is based on forum posts by lotus49 and Bauldrick.

USB Hard Drive | The LinkStation's USB port may not provide enough current for some USB-powered hard drives.

You can connect multiple USB device to the LinkStation via a USB hub. However, you must modify 2 files in order to share more than 1 USB disk. The following information details connecting 2 USB disks but can easily be modified to cover any number of disks.

1.) Open the file in a text editor and adjust it to the following:

vi /etc/murasaki/bin/mount_sd.sh


#!/bin/sh

BOOTCHECK=0
MNT_DIR1=/mnt2/usbdisk1
MNT_DIR2=/mnt2/usbdisk2
LOCK1=/var/lock/mount_sd1
LOCK2=/var/lock/mount_sd2
MOUNT_SD1=0
MOUNT_SD2=0

### check initial devices
if [ $# -eq 2] ; then
BOOTCHECK=1
fi

### parse usb device info
/usr/bin/parse_usbscsi > /dev/null 2>&1

start()
{
echo "mount usb disks..."
### read exist files
while read SD
do
CHECK_MOUNT=`cat /proc/mounts | grep ${SD}`
if [ ! ${CHECK_MOUNT} ] ; then
if [ ! -f ${LOCK1} ] ; then
mount -t vfat,ntfs,ext3,ext2 ${SD}1 ${MNT_DIR1}
case $? in
0)
chmod 777 ${MNT_DIR1}
MOUNT_SD1=1
echo "${SD},${SD}1,${MNT_DIR1}" > ${LOCK1}
if [ -d ${MNT_DIR1}/lost+found ] ; then
rm -rf ${MNT_DIR1}/lost+found
fi
;;
32)
mount -t vfat,ntfs,ext3,ext2 ${SD}5 ${MNT_DIR1}
if [ $? -eq 0 ] ; then
chmod 777 ${MNT_DIR1}
MOUNT_SD1=1
echo "${SD},${SD}5,${MNT_DIR1}" > ${LOCK1}
fi
;;
esac
elif [ ! -f ${LOCK2} ] ; then
mount -t vfat,ext3,ext2 ${SD}1 ${MNT_DIR2}
case $? in
0)
chmod 777 ${MNT_DIR2}
MOUNT_SD2=1
echo "${SD},${SD}1,${MNT_DIR2}" > ${LOCK2}
touch /var/lock/${SD}
;;
32)
mount -t vfat,ext3,ext2 ${SD}5 ${MNT_DIR2}
if [ $? -eq 0 ] ; then
chmod 777 ${MNT_DIR2}
MOUNT_SD2=1
echo "${SD},${SD}5,${MNT_DIR2}" > ${LOCK2}
fi
;;
esac
fi
fi
done < /mnt2/usbinfo/list

if [ ${MOUNT_SD1} -eq 1 -o ${MOUNT_SD2} -eq 1 ] ; then
# if [ ${MOUNT_SD1} -eq 1 ] ; then
/etc/init.d/chkshare
sleep 3
if [ ${BOOTCHECK} -eq 0 ] ; then
/etc/init.d/smb restart > /dev/null 2>&1
fi
# /etc/init.d/atalk start > /dev/null 2>&1
fi
}

stop()
{
echo "unmounting usb devices.."
MOUNT_SD1=1
MOUNT_SD2=1
if [ -f ${LOCK1} ]; then
rm -rf ${LOCK1}
umount -f ${MNT_DIR1}
MOUNT_SD1=0
sleep 1
fi
if [ -f ${LOCK2} ]; then
rm -rf ${LOCK2}
umount -f ${MNT_DIR2}
MOUNT_SD2=0
fi

if [ ${MOUNT_SD1} -eq 0 -o ${MOUNT_SD2} -eq 0 ] ; then
# if [ ${MOUNT_SD1} -eq 0 ] ; then
/etc/init.d/chkshare
sync
sleep 3
/etc/init.d/smb restart > /dev/null 2>&1
/etc/init.d/atalk restart > /dev/null 2>&1
else
echo ${MOUNT_SD1} ${MOUNT_SD2} >> /tmp/stop.$$ 2>&1
fi
}

case "$1" in
start)
start
;;
stop)
stop
;;
esac

exit 0


2.) Now you have to add some lines (without this modifications the usbdisk would not be shared via samba)

vi /etc/init.d/chkshare

directly after

/bin/mkcode -s > /dev/null

add this:

Different Sharenames | if you change "usbdisk2" in the first and last echo line to something different it will be shared that way!

CHECK_MOUNT=`grep /mnt2/usbdisk2 /etc/mtab`

if [ -n “$CHECK_MOUNT“ ] ; then
  echo “[usbdisk2]“ >> /etc/samba/smb.conf
  echo “comment = USB HDD2“ >> /etc/samba/smb.conf
  echo “path = /mnt2/usbdisk2“ >> /etc/samba/smb.conf
  echo “browsable = yes“ >> /etc/samba/smb.conf
  echo “writable = yes“ >> /etc/samba/smb.conf
  echo “printable = no“ >> /etc/samba/smb.conf
  echo “guest ok = yes“ >> /etc/samba/smb.conf
  echo “force create mode = 777“ >> /etc/samba/smb.conf
  echo “force directory mode = 777“ >> /etc/samba/smb.conf
  echo “###usbdisk2###“ >> /etc/samba/smb.conf
fi 

3.) Then reboot the Linkstation for the new settings to take effect. The additional USB disk(s) won't appear in the web interface.

shutdown -r now

mindbender-21.5.06: this is true at the moment if you use the 2.6-kernel. if you use the stock-kernel, then you will see the second usb-hdd over the webinterface and you can even format it as normal. in the status screen you will see all the information also accordingly.

4.) It's worth pointing out that I had already formatted the additional USB disk on another machine before doing any of this. This should all work for vfat, ext2 or ext3 file systems.