[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [K12OSN] Flash drive in thin client.



Actually, if you are running K12LTSP 4.2.1, you can have "native" access to the local drives without using MTools.
This is what you need to do.
Read http://wiki.ltsp.org/twiki/bin/view/Ltsp/LocalDrives
Almost all the steps to get it working can be found on the page. Three modified files are attached that will be needed to get this working.


To boil it down:
1. Add HOTPLUG = Y to your lts.conf file.
2. Double check that you have SAMBA Client on the server. rpm -qa |grep samba You should have samba-client. If not, install it.
3. The download at the bottom of the wiki link for updated files has a few errors in it. Use the ones attached to this email. hotplug needs to go in /opt/ltsp/i386/sbin and needs 755 for permissions.
rc.localdev need to go in /opt/ltsp/i386/etc with 755 for permissions.
4. Copy the rc.usb that is also attached into /opt/ltsp/i386/etc with 755 for permissions.
5. Download http://ltsp.mirrors.tds.net/pub/ltsp/ltsp-4.1/LDA-setup.sh and http://ltsp.mirrors.tds.net/pub/ltsp/ltsp-4.1/LDA-shutdown.sh
"If you use KDM:
/usr/local/bin/LDA-setup.sh goes into line 3 of /etc/kde/kdm/Xstartup /usr/local/bin/LDA-shutdown.sh goes into line 3 of /etc/kde/kdm/Xreset
if you use GDM:
/usr/local/bin/LDA-setup.sh goes into line 3 of /etc/X11/gdm/PostLogin/Default /usr/local/bin/LDA-shutdown.sh goes into line 3 of /etc/X11/gdm/PostSession/Default
"
6. Reboot the client
7. Look inside the users home dir. You should see a directory called Drives. There is your local device.
8. If that fails, add a SCREEN_02 = SHELL to the workstation you are on, then check in /tmp/drives and see if you can see the devices there.


Ive got this working on 2 servers so far, with 5 different test usb flash drives. If you have problems with this, send it back out to the list and I will try to walk you through it.

Shawn Austin

Client Services
University of Indianapolis

Shawn Powers wrote:

Genfil Villahermosa wrote:

Does anyone know how to mount a flash drive on a thin? It work on the
terminal server but not on the thin client.

http://www.k12ltsp.org/phpwiki/index.php/StorageFloppyUsb

(Hopefully that will answer your question... MtoolsFM is the program you use to connect to the drive...)


#!/bin/sh
#
# local_cd
#
# This script will set up a local cdrom drive for supermount.
#
PATH=/bin:$PATH; export PATH
. /etc/ltsp_functions

SAMBATMP="/tmp/samba"
SAMBACNF="/tmp/smb.conf"

mkdir /tmp/drives
chown nobody /tmp/drives

#
# Get the lts.conf entries
#
eval `/bin/getltscfg -a`

for i in 01 02 03 04 05 06 07 08 09 10; do
    DEVVAR=LOCAL_DEVICE_${i}
  
    if [ ! -z ${!DEVVAR} ] ; then
        #
        # As soon as we find at least 1 local device, we need to
        # setup the Samba config stuff
        #
	reg_info ${DEVVAR}

        DEVICE=`echo ${!DEVVAR} | sed 's/\(.*\):.*/\1/'`
        SHARE=`echo ${!DEVVAR} | sed 's/.*:\(.*\)/\1/'`
        BASE_DEVICE=`/usr/bin/basename ${DEVICE}`
        START_SAMBA="Y"

        if [ -z ${SHARE} ] ; then
            SHARE=${BASE_DEVICE}
        fi

        echo ${DEVICE} ${SHARE} ${BASE_DEVICE}

        case "${BASE_DEVICE}" in
            hd* ) modprobe ide-cd
                  modprobe iso9660
                  RW="ro"
                  FS="iso9660"
                  ;;
            fd* ) modprobe floppy
                  modprobe vfat
                  RW="rw"
                  FS="vfat"
                  ;;
            sr* ) modprobe scsi_mod 
                  modprobe sr_mod
                  RW="ro"
                  FS="iso9660"
                  ;;
            sd* ) modprobe scsi_mod 
                  modprobe sd_mod
                  RW="rw"
                  FS="auto"
                  ;;
            * )   # assume modules are already loaded 
                  RW="ro"
                  FS="auto"
                  ;;
        esac

        mkdir /tmp/drives/${SHARE}

        if [ "${DEVICE}" != "hotplug" ] ; then
          mount -t supermount	\
              -o fs=${FS},dev=${DEVICE},--,${RW},uid=99,gid=99 none /tmp/drives/${SHARE}
        fi
    fi
done

if [ "${HOTPLUG}" = "Y" ]; then
  reg_info HOTPLUG
  mkdir /tmp/drives/.hotplug
  chown nobody /tmp/drives/.hotplug
  START_SAMBA=Y
fi

if [ "${START_SAMBA}" = "Y" ] ; then
    mkdir ${SAMBATMP}
    cat <<-EOF >${SAMBACNF}
        [global]
          workgroup        = ${WORKGROUP:-"LTSP"}
          security         = SHARE
          smb passwd file  = /etc/passwd
          guest account    = nobody
          log file         = /tmp/samba/%m.log
          max log size     = 2
          socket options   = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
          load printers    = No
          dns proxy        = No
          unix extensions = No
          lock directory   = /tmp/samba
          pid directory    = /tmp/samba
          private dir      = /tmp/samba
		   
        [drives]
          path       = /tmp/drives
          read only  = no
          guest ok   = Yes
          locking    = no
	EOF
    smbd -D -s /tmp/smb.conf
fi
#!/bin/sh

for module in usb-uhci usb-ohci ehci-hcd uhci-hcd ohci-hcd usb-storage scsi_mod sd_mod
do
	modprobe $module &>/dev/null
done

if [ "`lsmod | grep usbcore`" ]
then
	echo "USB subsystem found, loading keyboard and mouse drivers"
	for module in keybdev mousedev input usbmouse usbkbd
	do
		modprobe $module > /dev/null
	done
	# quick bug-fix hack
	insmod usbmouse
else
	echo "WARNING: USB subsystem not found, skipping"
fi
#!/bin/bash

DRIVESDIR=/tmp/drives
HOTPLUGDIR=/tmp/drives/.hotplug

# 
# Read in our ltsp variables
#

eval `getltscfg -a`

#
# Module location
#

KERNEL=`uname -r`
MODULE_DIR=/lib/modules/$KERNEL

USB_MODMAP=$MODULE_DIR/modules.usbmap
LTSP_USB_MODMAP=/etc/usblist


mount_device_num()
{
  DEVNUM=$1
  mkdir ${HOTPLUGDIR}/host${DEVNUM}

  SCSI_DIR=/dev/scsi/host${DEVNUM}/bus0/target0/lun0

  PRODUCT_NAME=`grep Product /proc/scsi/usb-storage-${DEVNUM}/${DEVNUM} | \
                sed -e 's/.*: //' | tr ' ' '_'`

  MODEL=`grep -h -s "^${PRODUCT_NAME}" /etc/devname_map.local /etc/devname_map|\
         head -1 | sed 's/	/ /g' | tr -s ' ' | cut -d' ' -f 2`

  [ -n "${MODEL}" ] && PRODUCT_NAME="${MODEL}"

  COUNT=1
  while [ -L ${DRIVESDIR}/${PRODUCT_NAME}_${COUNT} ]; do
    COUNT=`expr $COUNT + 1`
  done

  LINK_NAME=${PRODUCT_NAME}_${COUNT}

  if [ -b $SCSI_DIR/part1 ] ; then
     echo "${DRIVESDIR}/${LINK_NAME}" >${HOTPLUGDIR}/host${DEVNUM}/LINK_NAME
     mount -t supermount \
       -o fs=vfat:msdos:iso9660:ext2,dev=$SCSI_DIR/part1,--,rw,uid=99,gid=99 \
       none $HOTPLUGDIR/host${DEVNUM}
     cd $HOTPLUGDIR/host${DEVNUM}
     ln -s $HOTPLUGDIR/host${DEVNUM} "${DRIVESDIR}/${LINK_NAME}"
     return
  fi
  if [ -b $SCSI_DIR/cd ] ; then
     echo "${DRIVESDIR}/${LINK_NAME}" >${HOTPLUGDIR}/host${DEVNUM}/LINK_NAME
     mount -t supermount \
       -o fs=vfat:msdos:iso9660:ext2,dev=$SCSI_DIR/cd,--,ro,uid=99,gid=99 \
       none $HOTPLUGDIR/host${DEVNUM}
     cd $HOTPLUGDIR/host${DEVNUM}
     ln -s $HOTPLUGDIR/host${DEVNUM} "${DRIVESDIR}/${LINK_NAME}"
     return
  fi
  if [ -b $SCSI_DIR/disc ] ; then
     echo "${DRIVESDIR}/${LINK_NAME}" >${HOTPLUGDIR}/host${DEVNUM}/LINK_NAME
     mount -t supermount \
       -o fs=vfat:msdos:iso9660:ext2,dev=$SCSI_DIR/disc,--,rw,uid=99,gid=99 \
       none $HOTPLUGDIR/host${DEVNUM}
     cd $HOTPLUGDIR/host${DEVNUM}
     ln -s $HOTPLUGDIR/host${DEVNUM} "${DRIVESDIR}/${LINK_NAME}"
     return
  fi
}

#
# If we've activated hotplugging, then this directory should be here, if not,
# exit quitely.  Simple way to "disable" hotplugging.
#

if [ ! -d $HOTPLUGDIR ] ; then
  exit 0
fi

#
# ADD event
#

if [ "$ACTION" = "add" ] ; then

  #
  # USB add event
  #

  if [ "$DEVFS" = "/proc/bus/usb" ] ; then
     #
     # Get vendor and product ID, and find them in the module map
     #

     ID_VENDOR=`echo $PRODUCT | cut -d'/' -f 1`
     ID_PRODUCT=`echo $PRODUCT | cut -d'/' -f 2`
     MODULE=`grep -h $ID_VENDOR $USB_MODMAP $LTSP_USB_MODMAP | \
                grep $ID_PRODUCT | cut -d' ' -f 1 | head -1`
     #
     # The LTSP configuration variable "ALLOW_UNKNOWN_USB" dictates if
     # we'll simply default to allowing anything that's plugged in to
     # qualify as usb-storage.  
     #

     if [ -z "$MODULE" -a "${ALLOW_UNKNOWN_USB}" != "N" ] ; then
        MODULE="usb-storage"
     fi
       
     #
     # If we got a module, load it, then figure out what to do
     #

     if [ ! -z ${MODULE} ] ; then
       lsmod | grep $MODULE > /dev/null
       if [ $? -eq 1 ] ; then
         modprobe $MODULE
       fi
     fi
        
     if [ $MODULE = "usb-storage" ] ; then
       lsmod | grep "s[dr]_mod" > /dev/null
       if [ $? -eq 1 ] ; then
         modprobe sd_mod && modprobe sr_mod
       fi

       #
       # OK, we've got our hotplug device plumbed.  Lets do some mounting
       #

       #
       # This needs to be generalized
       #

       for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do
         USBDEV="/proc/scsi/usb-storage-${i}/${i}"
         if [ -f ${USBDEV} ] ; then
           grep "Attached: Yes" $USBDEV > /dev/null
           if [ $? -eq 0 ] ; then
             if [ ! -d ${HOTPLUGDIR}/host${i} ] ; then
               mount_device_num ${i}
             fi
           fi
         fi
       done
     fi  # module = usbstorage
   fi    # devfs = procusb
#
# REMOVE action
#

elif [ "$ACTION" = "remove" ] ; then

  if [ "$DEVFS" = "/proc/bus/usb" ] ; then

    #
    # Scan and see if all devices are disconnected.  If they are, then
    # we can unload the "usb-storage" module
    #

    for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do
       USBDEV="/proc/scsi/usb-storage-${i}/${i}"
       if [ -f ${USBDEV} ] ; then
       grep "Attached: No" $USBDEV > /dev/null
       if [ $? -eq 0 ] ; then
         if [ -d ${HOTPLUGDIR}/host${i} ] ; then
            umount -l ${HOTPLUGDIR}/host${i}
            if [ -f ${HOTPLUGDIR}/host${i}/LINK_NAME ]; then
	      rm -f `cat ${HOTPLUGDIR}/host${i}/LINK_NAME`
              rm ${HOTPLUGDIR}/host${i}/LINK_NAME
            fi
            rmdir ${HOTPLUGDIR}/host${i}
         fi
       fi
      fi
    done

    fi
  fi

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]