View previous topic :: View next topic |
Author |
Message |
jmquigs n00b
Joined: 05 Mar 2003 Posts: 11
|
Posted: Sun Sep 07, 2003 3:12 am Post subject: iPod and USB disconnection |
|
|
I got my new iPod working under gentoo without too much effort. I had to buy the USB "Dock Connector" and setup my kernel module configuration for USB (wasn't using it before), but now its working and syncing pretty fast.
One problem though. The iPod likes to be "disconnected" after sync, and unmounting doesn't do that. The iPod will just display "Do not disconnect" until I reboot or yank the cable. The only way I've figured out to disconnect it cleanly is to unload ALL of the usb modules. Does anyone know a better way to disconnect?
Thanks |
|
Back to top |
|
|
jmquigs n00b
Joined: 05 Mar 2003 Posts: 11
|
Posted: Tue Sep 09, 2003 1:47 am Post subject: oh well |
|
|
No takers? Well, to make this thread somewhat worthwhile, here's a script that I wrote to automatically load modules and mount/unmount the iPod. Use at your own risk blah blah...
Code: |
#!/bin/sh
# ipod.sh
# This script automatically loads modules and mounts/unmounts the ipod. The
# implementation just works for USB connections now, but you should be able
# to make firewire work by changing the modules (search for modprobe and
# rmmod below). Note that this assumes the iPod is your only usb device,
# since the whole USB subsystem is loaded/unloaded so that iPod can disconnect
# cleanly.
# this script should be run as root. Change MNTPOINT below if you mount
# the iPod somewhere else.
MNTPOINT=/mnt/ipod
CMD=$1
if [ "$CMD" == "" ]; then
# no command, figure out what to do:
# is it already mounted?
MOUNT_OUT=`mount | grep $MNTPOINT`
if [ ! "$MOUNT_OUT" == "" ]; then
# it is mounted, so cmd is stop
CMD="stop"
else
# not mounted, start
CMD="start"
fi
fi
if [ "$CMD" == "start" ]; then
# is it already mounted?
MOUNT_OUT=`mount | grep $MNTPOINT`
if [ ! "$MOUNT_OUT" == "" ]; then
echo "Exiting: Mount point $MNTPOINT is already mounted:"
echo $MOUNT_OUT
exit 1
fi
if [ ! -d $MNTPOINT ]; then
echo "Creating mount point: $MNTPOINT"
mkdir $MNTPOINT
if [ ! $? -eq 0 ]; then
echo "Exiting: couldn't create mountpoint: $MNTPOINT"
exit 1
fi
fi
# load usb modules
/sbin/modprobe ehci-hcd # usb hud controller
/sbin/modprobe uhci-hcd # usb hud controller
/sbin/modprobe usb-storage # usb mass storage module
/sbin/modprobe sd_mod # scsi-disk; not needed as module. could leave it
# loaded all the time or compile in
# wait a bit for scsi to init
sleep 3
# mount ipod
mount $MNTPOINT
if [ $? -ne 0 ]; then
echo "Exiting: Failed to mount $MNTPOINT"
exit 1
fi
echo "iPod mounted on $MNTPOINT"
elif [ "$CMD" == "stop" ]; then
# make sure it is mounted
MOUNT_OUT=`mount | grep $MNTPOINT`
if [ "$MOUNT_OUT" == "" ]; then
echo "Exiting: Mount point $MNTPOINT is not mounted"
exit 1
fi
# umount
umount $MNTPOINT
if [ $? -ne 0 ]; then
echo "Exiting: Failed to unmount $MNTPOINT"
exit 1
fi
# wait a bit
sleep 3
# remove modules
/sbin/rmmod sd_mod # could skip this one
/sbin/rmmod usb-storage
/sbin/rmmod uhci-hcd
/sbin/rmmod ehci-hcd
echo "iPod unmounted"
else
echo "Usage: sudo ipod.sh [start|stop]"
fi
|
|
|
Back to top |
|
|
drjimmy42 Guru
Joined: 03 Feb 2003 Posts: 512 Location: Nashua, NH
|
Posted: Thu Oct 16, 2003 5:49 am Post subject: |
|
|
Hey,
Cool script. Did you ever figure out how to do this without borking the whole usb bus? I have a usb mouse and its a little inconvenient. Thanks. |
|
Back to top |
|
|
HomerSimpson l33t
Joined: 25 Jan 2003 Posts: 869 Location: Ohio, USA
|
Posted: Sun Feb 08, 2004 11:04 pm Post subject: |
|
|
I was reading in the forums and came across a post that said to eject as root.
Mine was on sda2 so I did: Code: | # eject -s /dev/sda2
eject: unable to eject, last error: Invalid argument | as you can see I got an error. But the message on my iPod change to "Ok to Disconnect". _________________ The strong must protect the Sweet. |
|
Back to top |
|
|
cottonmouth Tux's lil' helper
Joined: 24 Jan 2004 Posts: 105
|
Posted: Wed Feb 18, 2004 9:10 am Post subject: |
|
|
I just run Code: | /etc/init.d/hotplug stop | , and it works fine.
Note 1: Just running "hotplug stop" does not work
Note 2: When reconnecting the ipod, I have to run "/etc/init.d/hotplug restart". Just running "/etc/init.d/hotplug start" does not work, even though I just stopped it the step before.
All the best _________________ Answer an unanswered post |
|
Back to top |
|
|
HomerSimpson l33t
Joined: 25 Jan 2003 Posts: 869 Location: Ohio, USA
|
Posted: Wed Feb 18, 2004 3:34 pm Post subject: |
|
|
Does stopping hotplug affect anything else? IE Printer, any other USB drives...
Thx _________________ The strong must protect the Sweet. |
|
Back to top |
|
|
cottonmouth Tux's lil' helper
Joined: 24 Jan 2004 Posts: 105
|
Posted: Thu Feb 19, 2004 9:00 am Post subject: |
|
|
HomerSimpson wrote: | Does stopping hotplug affect anything else? IE Printer, any other USB drives... |
In my case it does, so I unplug my iPod and restart it afterwards. _________________ Answer an unanswered post |
|
Back to top |
|
|
nightm4re Guru
Joined: 20 Jun 2004 Posts: 519 Location: Providence, RI, USA
|
Posted: Mon Sep 06, 2004 11:03 pm Post subject: |
|
|
HomerSimpson wrote: | I was reading in the forums and came across a post that said to eject as root.
Mine was on sda2 so I did: Code: | # eject -s /dev/sda2
eject: unable to eject, last error: Invalid argument | as you can see I got an error. But the message on my iPod change to "Ok to Disconnect". |
i know this is a mad old thread, but this was useful.
one thing: your eject parameter is wrong. it's not supposed to be /dev/sda2 (taht refers to a partition on the drive itself), it should just be /dev/sda. For some reason, it wouldn't return, but the ipod said okay to disconnect, and i just closed the terminal. _________________ Nitrogen - GtkMM based background setter/restorer, please test!
Minuslab | d.minuslab.net |
|
Back to top |
|
|
|