Chris wrote:
On Jan 29, 2008 12:24 AM, Chris <[EMAIL PROTECTED]> wrote:
I am trying to use hotplugd(8) to mount my USB flash drive (/dev/sd1i)
automatically in /mn/flash when I plug it it. I enabled hotplugd in
/etc/rc.conf.local and wrote the following script (chmod +x bit set)

#!/bin/sh

           DEVCLASS=$1
           DEVNAME=$2

           case $DEVCLASS in
           2)
                   # disk devices

                   disklabel=`/sbin/disklabel $DEVNAME 2>&1 | \
                           sed -n '/^label: /s/^label: //p'`
                   case $disklabel in
                   flash)
                           # flash drive
                           mount /dev/"$DEVNAME"i /mnt/flash
                           ;;
                   esac
                   ;;
           3)
                   # network devices

                   /sbin/dhclient $DEVNAME

                   ;;
           esac

I can mount the flash drive fine with mount /dev/sd1i /mnt/flash

Any help would be much appreciated. Thanks.

I figured (from /var/log/messages) that the flash drive is mounted as
"JetFlash" so I changed the script to reflect this and still no luck.
Following the /var/log/message after the flash drive is plugged in and
also the new modified script.

Jan 29 19:40:44 red /bsd: sd1 detached
Jan 29 19:40:44 red /bsd: scsibus2 detached
Jan 29 19:40:44 red /bsd: umass0 detached
Jan 29 19:40:47 red /bsd: umass0 at uhub0 port 2 configuration 1 interface 0
Jan 29 19:40:47 red /bsd:
Jan 29 19:40:47 red /bsd: umass0: JetFlash Mass Storage Device, rev
2.00/1.41, addr 2
Jan 29 19:40:47 red /bsd: umass0: using SCSI over Bulk-Only
Jan 29 19:40:47 red /bsd: scsibus2 at umass0: 2 targets
Jan 29 19:40:47 red /bsd: sd1 at scsibus2 targ 1 lun 0: <JetFlash,
TS8GJFV30, 8.07> SCSI2 0/direct removable
Jan 29 19:40:47 red /bsd: sd1: 7799MB, 994 cyl, 255 head, 63 sec, 512
bytes/sec, 15974398 sec total

 #!/bin/sh
#
# Maybe some debugging will help:
#
exec >> /tmp/logfile 2>&1
set -x
#

            DEVCLASS=$1
            DEVNAME=$2

            case $DEVCLASS in
            2)
                    # disk devices

                    disklabel=`/sbin/disklabel $DEVNAME 2>&1 | \
                            sed -n '/^label: /s/^label: //p'`
                    case $disklabel in
                    JetFlash)
                            # flash drive
                            mount /dev/"$DEVNAME"i /mnt/flash
                            ;;
                    esac
                    ;;
            3)
                    # network devices

                    /sbin/dhclient $DEVNAME

                    ;;
            esac

Is there anything I am doing wrong? Thanks for any help.


-Heinrich

Reply via email to