View Full Version : Hot-swap CDROM drive


danieldg
05-25-2006, 08:01 PM
I'd like to be able to insert the CDROM drive on my laptop after booting, or (later) remove it and prevent applications accessing /dev/hdc from going into I/O sleep (can't kill -9 them).

How do I get the linux kernel to re-probe IDE interfaces? I think this would do it.

Also, just curious if I need to do something before removing the CDROM - like windows's Safely Remove Hardware thingy.

EDIT: I'll post things I discover here, in the hopes that it could help someone else, or get someone to reply :D

"hdparm -U 1 /dev/hdc" (run by idectl 1 off) seems to partially work for disabling it - udev removes the /dev/hdc file, and the copy returns "No such device or address" from then on. Only problem is the hdparm process is in uninterruptable sleep.

elektronaut
07-15-2006, 12:02 AM
May be a bit late: There is hotswap (http://timstadelmann.de/hotswap.html) for this. I use it on my ASUS M2400N like this:

sudo hotswap -c 1 rescan-ide

to insert the cd drive and

sudo /usr/bin/hotswap -c 1 unregister-ide

to take it out.

danieldg
07-15-2006, 09:18 PM
After some modifications, it looks like hotswap will only work for half of what I want.

On my laptop, the device /dev/hda does not exist. (the hard drive is SATA, /dev/sda). Because hotswap assumes that /dev/hda is present, it gave me errors until I created a symlink from /dev/hda to /dev/hdc (a copy would have done the same thing).

However, since it uses open() on /dev/hda to get an open IDE device, a CD must be present in the drive to remove it. This presents a problem when the drive has been removed, since it does not yet exist.

This seems to be a design flaw in the ioctl methods to remove and add devices; definately no modification I can think of in user-level code will help. I'll start looking for kernel-level hacks to get insertion working.

Thanks for the tip; I can at least avoid hanging my laptop, and am able to reboot for the times I need to use the CD.

Laptop Deals