How to make hotplug work

Bob Chiodini rchiodin at bellsouth.net
Tue Oct 4 11:13:05 UTC 2005


On Mon, 2005-10-03 at 14:29 -0400, Gavin Li wrote:
> I want to make my small embedded system work with hotplug, I copied /lib
> /boot /bin /sbin /usr/bin /usr/sbin from RHFC 3 to my embedded system, I
> didn't copy /etc
> I have my inittab to start /etc/rc.d/rcS script., I also have my
> /sbin/hotplug script, they both have attrib 0755
> I boot this embedded system without initrd, After I boot this embedded
> system, I see bash prompt.
> but when I plug a usb flash drive, nothing happened.
> Would anyone please tell me what else do I need to do to so I can set
> /hot.txt has the desired string?
> 
> #!/bin/sh
> # /sbin/hotplug
> echo "starting hotplug" > /hot.txt
> #end of /sbin/hotplug
> 
> #!/bin/sh
> # /etc/rc.d/rcS
> kill_init=`ls /dev |grep -c tty`
> if [ $kill_init -eq 0 ]; then
>     mount -n -t proc proc /proc
>     mount -n -t sysfs sys /sys
>     mount -n -t usbfs usbfs /proc/bus/usb
>     mount -n -t tmpfs dev /dev
>     echo /sbin/udevsend > /proc/sys/kernel/hotplug
>     udevstart
>     kill -HUP 1
>     sleep 10
> fi
> ln -s /proc/self/fd  /dev/fd
> ln -s /proc/self/fd0 /dev/stdin
> ln -s /proc/self/fd1 /dev/stdout
> ln -s /proc/self/fd2 /dev/stderr
> ln -s /proc/kcore /dev/core
> moun -o remount, rw /
> exit 0
> #end of /etc/rc.d/rcS
> 

Gavin,

I think echo /sbin/udevsend > /proc/sys/kernel/hotplug should be
echo /sbin/hotplug > /proc/sys/kernel/hotplug, if it is not already.  I,
also had to modprobe usbcore as part of system initialization.  I was
working with a 2.4.x kernel.  There is a typo near the end of rcS the
moun should be mount.  Cut and paste problem?

Bob...

This is the /sbin/hotplug that I came up with.  Rather "brute force",
but it only needed to do one thing, mount a USB stick.

#!/bin/sh
echo "args = $*" >> /tmp/hotplug.out
env >> /tmp/hotplug.out
echo
if [ "$1" = "usb" ]; then
	DEVCLASS=`echo $TYPE | cut -f1 -d/`
	if [ "$DEVCLASS" = "0" ]; then
		IFCLASS=`echo $INTERFACE | cut -f1 -d/`
		if [ "$IFCLASS" = "8" ]; then
			case "$ACTION" in 
			add)
            			modprobe usb-storage 2>/dev/null
            			mount /mnt/usbdisk 2>/dev/null
			;;
			remove)
				umount -f /mnt/usbdisk 2>/dev/null
				rmmod usb-storage 2>/dev/null
			;;
			*)
				echo "hotplug: unsupported action $ACTION"
			esac
		else
			echo "hotplug: unsupported I/F class ($INTERFACE)"
		fi
	else
		echo "hotplug: unsupported type ($TYPE)"
	fi
fi




More information about the fedora-list mailing list