<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.thinkwiki.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Zin</id>
	<title>ThinkWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.thinkwiki.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Zin"/>
	<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/wiki/Special:Contributions/Zin"/>
	<updated>2026-05-01T20:33:48Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.12</generator>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=How_to_hotswap_Ultrabay_devices&amp;diff=38693</id>
		<title>How to hotswap Ultrabay devices</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=How_to_hotswap_Ultrabay_devices&amp;diff=38693"/>
		<updated>2008-08-26T11:33:18Z</updated>

		<summary type="html">&lt;p&gt;Zin: /* Scripts for hotswapping */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The following discusses hotswap (AKA &amp;quot;hotplug&amp;quot;) of devices in the [[UltraBay]].&lt;br /&gt;
&lt;br /&gt;
==Which driver?==&lt;br /&gt;
Since this may be confusing for SATA thinkpad owners, which are likely all the same for now, you have two busses and drivers: one SATA bus which works with the AHCI driver and one IDE bus for the ultrabay for which you should pick ata_piix (not piix/CONFIG_BLK_DEV_PIIX). See below for hotswapping.&lt;br /&gt;
&lt;br /&gt;
==Choosing the right driver: new style &amp;lt;tt&amp;gt;ata_piix&amp;lt;/tt&amp;gt; vs old style &amp;lt;tt&amp;gt;piix/ide-disk&amp;lt;/tt&amp;gt;==&lt;br /&gt;
For ICH5,6,7,8, systems, whether you have an older IDE only thinkpad, or a newer thinkpad like the T/Z61p, there is one SATA bus for the system hard drive and an IDE bus for the ultrabay (even if your ultrabay happens to have a SATA drive, as it'll be seen as an IDE device), you'll have two drivers to chose from for your ultrabay: the old IDE/piix+ide-disk driver, and the newer PATA (=IDE) support of the newer ata_piix driver.&amp;lt;BR&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;piix+ide-disk&amp;lt;/tt&amp;gt; are part of the old original IDE driver and your ultrabay device will show up as &amp;lt;tt&amp;gt;/dev/hda&amp;lt;/tt&amp;gt;.&amp;lt;BR&amp;gt;&amp;lt;tt&amp;gt;ata-piix&amp;lt;/tt&amp;gt; is the new SATA/PATA (=IDE) driver that will cause your ultrabay Hard Drive to show up as &amp;lt;tt&amp;gt;/dev/sda&amp;lt;/tt&amp;gt; and your CD-Rom as &amp;lt;tt&amp;gt;/dev/sr0&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The two things to know are: 1) you want to use ata_piix and 2) if you build piix in (CONFIG_BLK_DEV_PIIX enabled), or load it as a module, it'll take over the IDE bus and prevent ATA_PIIX from seeing your ultrabay. You don't want that.&lt;br /&gt;
&lt;br /&gt;
The longer details are:&amp;lt;BR&amp;gt;&lt;br /&gt;
You don't want the piix+ide-disk combo because even as modules, you will not be able to unload piix to reset the bus if there are issues swapping devices (with ata_piix, even if you forget to unregister a drive before removing it, you can unload the module and reload it to reset the bus after the fact if you have a newer thinkpad with a separate AHCI/SATA bus for the boot drive).&lt;br /&gt;
&lt;br /&gt;
As for hotswap, with piix+ide-disk, you can read the section below, but after more than one day of trying on 2.6.22.15 (as piix+ide-disk was taking over my IDE bus, and stopping me from using ata_piix before I removed it), I was not able to get hotswapping to work with piix+ide-disk (lt_hotswap would not even build on 2.6.22.15).&lt;br /&gt;
&lt;br /&gt;
hotswap just works with ata_pixx on 2.6.22, and reportedly with anything newer than 2.6.18, so you want to get rid of piix+ide-disk.&lt;br /&gt;
There are several ways to do that:&lt;br /&gt;
* if piix is built in your kernel (CONFIG_BLK_DEV_PIIX):&lt;br /&gt;
** rebuild your kernel with CONFIG_BLK_DEV_PIIX turned off.&lt;br /&gt;
** if you don't want to rebuild your kernel, try disabling the IDE bus grabbing by that driver with &amp;lt;tt&amp;gt;ide0=noprobe hda=noprobe hdb=noprobe&amp;lt;/tt&amp;gt; in your grub/lilo config (adjust the drive letters as appropriate, but note that this did not work for me on 2.6.22.15: the drive didn't show up on the piix bus, but it didn't show up on the ata_piix bus either).&lt;br /&gt;
* if piix is built in as a module&lt;br /&gt;
** you can move out the module in {{path|/lib/modules/ver/kernel/drivers/ide/pci/piix.ko}} and reboot.&lt;br /&gt;
** or build a new kernel, again with CONFIG_BLK_DEV_PIIX turned off.&lt;br /&gt;
** or add &amp;lt;tt&amp;gt;options ide_core options=&amp;quot;ide0=noprobe hda=noprobe hdb=noprobe&amp;quot;&amp;lt;/tt&amp;gt; to your modprobe.conf is supposed to work too (but didn't work on 2.6.22.15, see comment above)&lt;br /&gt;
&lt;br /&gt;
Then, continue this document to see how to do hotswap with ata_piix (if you are lucky enough to have a newer SATA thinkpad where the ata_piix driver only runs the ultrabay, and you have a separate bus and ahci driver for your main drive, it is recommended to have ata_piix as a module (&amp;lt;tt&amp;gt;CONFIG_ATA_PIIX=m&amp;lt;/tt&amp;gt;) so that you can unload/reload it if your bus gets in a bad state after a failed hotswap)&lt;br /&gt;
&lt;br /&gt;
==When using the &amp;lt;tt&amp;gt;ata_piix&amp;lt;/tt&amp;gt; driver==&lt;br /&gt;
The following applies when using the &amp;lt;tt&amp;gt;ata_piix&amp;lt;/tt&amp;gt; driver, which is necessary for many recent ThinkPad models that use an [[Intel ICH6-M]] controller. See also [[Problems with SATA and Linux]]. &lt;br /&gt;
&lt;br /&gt;
Mainline kernels before 2.6.18 cannot reliably recognize newly (re-)inserted UltraBay drives without a reboot. There are experimental hotplug patches against pre-2.6.18 mainline kernels [http://home-tj.org/wiki/index.php/Libata-tj-stable here].&lt;br /&gt;
&lt;br /&gt;
* Available hotplug patches&lt;br /&gt;
**[http://home-tj.org/files/libata-tj-stable/libata-tj-2.6.16.16-20060512.tar.bz2 Patch tarball against 2.6.16.16] ([http://lwn.net/Articles/183407/ Announce])&lt;br /&gt;
**[http://home-tj.org/files/libata-tj-stable/libata-tj-2.6.17-20060625-1.tar.bz2 Patch tarball against 2.6.17/2.6.17.1] ([http://article.gmane.org/gmane.linux.ide/11598 Announce])&lt;br /&gt;
**[http://home-tj.org/files/libata-tj-stable/libata-tj-2.6.17.4-20060710.tar.bz2 Patch tarball against 2.6.17.4]&lt;br /&gt;
**[http://whoopie.gmxhome.de/linux/patches/2.6.17.14-tj/00-libata-tj-2.6.17.4-20060710.patch Patch against 2.6.17.14]&lt;br /&gt;
&lt;br /&gt;
* Confirmed to work on the following laptops, with bus the following ID &lt;br /&gt;
**ThinkPad {{T30}}&lt;br /&gt;
**ThinkPad {{T43}}, {{T43p}}&lt;br /&gt;
**ThinkPad {{R52}}&lt;br /&gt;
**ThinkPad {{T60}} ID=4&lt;br /&gt;
**ThinkPad {{T61}} ID=0&lt;br /&gt;
**ThinkPad {{Z61p}} ID=4 (0-3:ahci, 5-6: ata_piix)&lt;br /&gt;
ID will typically be 1 if you only have an IDE bus (0 is boot drive, 1 is ultrabay), and it'll be 4 if you have a SATA bus your system boots from (ID 0-3) and an IDE bus for your ultrabay (ID 4-5).&amp;lt;BR&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Note that even on a given laptop model the ID can vary depending on whether your kernel has drivers that configure your boot drive is using the old style IDE driver (which doesn't add IDs before your ultrabay), or whether your boot drive is using the new style driver (which  adds IDs before your ultrabay)&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hotplug just works with kernels newer than 2.6.18 ( or older kernels that were patched to support &amp;lt;tt&amp;gt;ata_piix&amp;lt;/tt&amp;gt; hotplug (don't try it otherwise!))&amp;lt;BR&amp;gt;&lt;br /&gt;
First, it is recommended you find the right SCSI ID for your drive to hotswap and unregister it before removing it (this works with all recent mainline kernels):&lt;br /&gt;
 {{cmdroot|echo 1 &amp;gt; /sys/class/scsi_device/$ID:0:0:0/device/delete}} &lt;br /&gt;
 {{cmdroot|echo eject &amp;gt;  /proc/acpi/ibm/bay}}&lt;br /&gt;
The drive can now be ejected (without this, your IDE bus may complain if you just yank a drive, but you can usually recover by unloading/reloading the ata_piix module on a SATA laptop if your main drive is not on the ata_piix bus)&lt;br /&gt;
&lt;br /&gt;
You can then issue the following after inserting an UltraBay drive to rescan the port:&lt;br /&gt;
 {{cmdroot|echo 0 0 0 &amp;gt;  /sys/class/scsi_host/host$ID/scan}}&lt;br /&gt;
The inserted drive should now be recognized by the kernel, and appropriate {{path|/dev/*}} entries created automatically (e.g., by &amp;lt;tt&amp;gt;udev&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Ted T'so has also written this hotswap patch, which may or may not be needed for you, see [http://www.mail-archive.com/linux-acpi@vger.kernel.org/msg04716.html hotswap patch] and report back&lt;br /&gt;
&lt;br /&gt;
===Scripts for hotswapping===&lt;br /&gt;
&lt;br /&gt;
The following scripts and [[acpid]] daemon configuration files do the following:&lt;br /&gt;
* Automatically unmounts the relevant filesystems and power off the UltraBay when the UltraBay eject lever is released. Screams if some filesystem can't be unmounted.&lt;br /&gt;
* Rescans the UltraBay port when then UltraBay eject lever is pushed back in.&lt;br /&gt;
&lt;br /&gt;
They assumes you're using the &amp;lt;tt&amp;gt;ata_piix&amp;lt;/tt&amp;gt; driver with an appropriate kernel (see above).&lt;br /&gt;
&lt;br /&gt;
Create {{path|/usr/local/sbin/ultrabay_insert}} with permissions 755:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
echo 12 &amp;gt; /proc/acpi/ibm/beep&lt;br /&gt;
sync&lt;br /&gt;
echo 0 0 0 &amp;gt; /sys/class/scsi_host/host1/scan&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create {{path|/usr/local/sbin/ultrabay_eject}} with permissions 755:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
ULTRABAY_SYSDIR='/sys/class/scsi_device/1:0:0:0/device'&lt;br /&gt;
shopt -s nullglob&lt;br /&gt;
&lt;br /&gt;
# Umount the filesystem(s) backed by the given major:minor device(s)&lt;br /&gt;
unmount_rdev() { perl - &amp;quot;$@&amp;quot; &amp;lt;&amp;lt;'EOPERL'  # let's do it in Perl&lt;br /&gt;
	for $major_minor (@ARGV) {&lt;br /&gt;
		$major_minor =~ m/^(\d+):(\d+)$/ or die;&lt;br /&gt;
		push(@tgt_rdevs, ($1&amp;lt;&amp;lt;8)|$2);&lt;br /&gt;
	}&lt;br /&gt;
        # Sort by reverse length of mount point, to unmount sub-directories first&lt;br /&gt;
        open MOUNTS,&amp;quot;&amp;lt;/proc/mounts&amp;quot; or die &amp;quot;$!&amp;quot;;&lt;br /&gt;
        @mounts=sort { length($b-&amp;gt;[1]) &amp;lt;=&amp;gt; length($a-&amp;gt;[1]) } map { [ split ] } &amp;lt;MOUNTS&amp;gt;;&lt;br /&gt;
        close MOUNTS;&lt;br /&gt;
        foreach $m (@mounts) {&lt;br /&gt;
                ($dev,$dir)=@$m;&lt;br /&gt;
		next unless -b $dev;  $rdev=(stat($dev))[6];&lt;br /&gt;
		next unless grep($_==$rdev, @tgt_rdevs);&lt;br /&gt;
		system(&amp;quot;umount&amp;quot;,&amp;quot;-v&amp;quot;,&amp;quot;$dir&amp;quot;)==0  or  $bad=1;&lt;br /&gt;
	}&lt;br /&gt;
	exit 1 if $bad;&lt;br /&gt;
EOPERL&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# Get the UltraBay's /dev/foo block device node&lt;br /&gt;
ultrabay_dev_node() {&lt;br /&gt;
	UDEV_PATH=&amp;quot;`readlink -e &amp;quot;$ULTRABAY_SYSDIR/block:&amp;quot;*`&amp;quot; || return 1&lt;br /&gt;
	UDEV_NAME=&amp;quot;`udevinfo -q name -p $UDEV_PATH`&amp;quot; || return 1&lt;br /&gt;
	echo /dev/$UDEV_NAME&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if [ -d $ULTRABAY_SYSDIR ]; then&lt;br /&gt;
	sync&lt;br /&gt;
	# Unmount filesystems backed by this device&lt;br /&gt;
	unmount_rdev `cat $ULTRABAY_SYSDIR/block\:*/dev     \&lt;br /&gt;
	                  $ULTRABAY_SYSDIR/block\:*/*/dev`  \&lt;br /&gt;
	|| {&lt;br /&gt;
		echo 10 &amp;gt; /proc/acpi/ibm/beep;  # error tone&lt;br /&gt;
		exit 1;&lt;br /&gt;
	}&lt;br /&gt;
        sync&lt;br /&gt;
        # Nicely power off the device&lt;br /&gt;
	DEVNODE=`ultrabay_dev_node` &amp;amp;&amp;amp; hdparm -Y $DEVNODE&lt;br /&gt;
        # Let HAL+KDE notice the unmount and let the disk spin down&lt;br /&gt;
	sleep 0.5&lt;br /&gt;
	# Unregister this SCSI device:&lt;br /&gt;
	sync&lt;br /&gt;
	echo 1 &amp;gt; $ULTRABAY_SYSDIR/delete&lt;br /&gt;
fi&lt;br /&gt;
sync&lt;br /&gt;
# Turn off power to the UltraBay:&lt;br /&gt;
if [ -d /sys/devices/platform/bay.0 ]; then&lt;br /&gt;
	echo 1 &amp;gt; /sys/devices/platform/bay.0/eject&lt;br /&gt;
elif [ -e /proc/acpi/ibm/bay ]; then&lt;br /&gt;
	echo eject &amp;gt; /proc/acpi/ibm/bay&lt;br /&gt;
fi&lt;br /&gt;
# Tell the user we're OK&lt;br /&gt;
echo 12 &amp;gt; /proc/acpi/ibm/beep&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Use the modified version below if the above doesn't work for you (for kernels 2.6.25+ due to &amp;quot;ULTRABAY_SYSDIR/block\:*/dev&amp;quot; path change). It was tested on a Thinkpad X41 with Fedora 9 and kernel 2.6.25.11:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
ULTRABAY_SYSDIR='/sys/class/scsi_device/1:0:0:0/device'&lt;br /&gt;
shopt -s nullglob&lt;br /&gt;
&lt;br /&gt;
# Umount the filesystem(s) backed by the given major:minor device(s)&lt;br /&gt;
unmount_rdev() { perl - &amp;quot;$@&amp;quot; &amp;lt;&amp;lt;'EOPERL'  # let's do it in Perl&lt;br /&gt;
	for $major_minor (@ARGV) {&lt;br /&gt;
		$major_minor =~ m/^(\d+):(\d+)$/ or die;&lt;br /&gt;
		push(@tgt_rdevs, ($1&amp;lt;&amp;lt;8)|$2);&lt;br /&gt;
	}&lt;br /&gt;
        # Sort by reverse length of mount point, to unmount sub-directories first&lt;br /&gt;
        open MOUNTS,&amp;quot;&amp;lt;/proc/mounts&amp;quot; or die &amp;quot;$!&amp;quot;;&lt;br /&gt;
        @mounts=sort { length($b-&amp;gt;[1]) &amp;lt;=&amp;gt; length($a-&amp;gt;[1]) } map { [ split ] } &amp;lt;MOUNTS&amp;gt;;&lt;br /&gt;
        close MOUNTS;&lt;br /&gt;
        foreach $m (@mounts) {&lt;br /&gt;
                ($dev,$dir)=@$m;&lt;br /&gt;
		next unless -b $dev;  $rdev=(stat($dev))[6];&lt;br /&gt;
		next unless grep($_==$rdev, @tgt_rdevs);&lt;br /&gt;
		system(&amp;quot;umount&amp;quot;,&amp;quot;-v&amp;quot;,&amp;quot;$dir&amp;quot;)==0  or  $bad=1;&lt;br /&gt;
	}&lt;br /&gt;
	exit 1 if $bad;&lt;br /&gt;
EOPERL&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# Get the UltraBay's /dev/foo block device node&lt;br /&gt;
ultrabay_dev_node() {&lt;br /&gt;
	UDEV_PATH=&amp;quot;`readlink -e &amp;quot;$ULTRABAY_SYSDIR/block/&amp;quot;*`&amp;quot; || return 1&lt;br /&gt;
	UDEV_NAME=&amp;quot;`udevinfo -q name -p $UDEV_PATH`&amp;quot; || return 1&lt;br /&gt;
	echo /dev/$UDEV_NAME&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if [ -d $ULTRABAY_SYSDIR ]; then&lt;br /&gt;
	sync&lt;br /&gt;
	# Unmount filesystems backed by this device&lt;br /&gt;
	unmount_rdev `cat $ULTRABAY_SYSDIR/block/*/dev     \&lt;br /&gt;
	                  $ULTRABAY_SYSDIR/block/*/*/dev`  \&lt;br /&gt;
	|| {&lt;br /&gt;
		echo 10 &amp;gt; /proc/acpi/ibm/beep;  # error tone&lt;br /&gt;
		exit 1;&lt;br /&gt;
	}&lt;br /&gt;
        sync&lt;br /&gt;
        # Nicely power off the device&lt;br /&gt;
	DEVNODE=`ultrabay_dev_node` &amp;amp;&amp;amp; hdparm -Y $DEVNODE&lt;br /&gt;
        # Let HAL+KDE notice the unmount and let the disk spin down&lt;br /&gt;
	sleep 0.5&lt;br /&gt;
	# Unregister this SCSI device:&lt;br /&gt;
	sync&lt;br /&gt;
	echo 1 &amp;gt; $ULTRABAY_SYSDIR/delete&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# We really need a 3 sec pause here otherwise the system will freeze..&lt;br /&gt;
sleep 3&lt;br /&gt;
&lt;br /&gt;
# Turn off power to the UltraBay:&lt;br /&gt;
if [ -d /sys/devices/platform/bay.0 ]; then&lt;br /&gt;
	echo 1 &amp;gt; /sys/devices/platform/bay.0/eject&lt;br /&gt;
elif [ -e /proc/acpi/ibm/bay ]; then&lt;br /&gt;
	echo eject &amp;gt; /proc/acpi/ibm/bay&lt;br /&gt;
fi&lt;br /&gt;
# Tell the user we're OK&lt;br /&gt;
echo 12 &amp;gt; /proc/acpi/ibm/beep&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create {{path|/etc/acpi/events/ultrabay-insert}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
event=ibm/bay MSTR 00000001 00000000&lt;br /&gt;
action=/usr/local/sbin/ultrabay_insert&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create {{path|/etc/acpi/events/ultrabay-eject}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
event=ibm/bay MSTR 00000003 00000000&lt;br /&gt;
action=/usr/local/sbin/ultrabay_eject&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart &amp;lt;tt&amp;gt;acpid&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===using the generic bay driver and udev===&lt;br /&gt;
&lt;br /&gt;
Starting from kernel 2.6.23-rc3, it's possible to use the generic &amp;lt;tt&amp;gt;bay&amp;lt;/tt&amp;gt; driver in combination with udev to hotswap. Please check if CONFIG_ACPI_BAY is enabled (module or built-in) in your kernel configuration.&lt;br /&gt;
&lt;br /&gt;
Create {{path|/etc/udev/rules.d/ibm-ultrabay.rules}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ENV{BAY_EVENT}==&amp;quot;3&amp;quot;, KERNEL==&amp;quot;bay.0&amp;quot;, ACTION==&amp;quot;change&amp;quot;, SUBSYSTEM==&amp;quot;platform&amp;quot;, RUN+=&amp;quot;/usr/local/sbin/ultrabay_eject&amp;quot;&lt;br /&gt;
ENV{BAY_EVENT}==&amp;quot;1&amp;quot;, KERNEL==&amp;quot;bay.0&amp;quot;, ACTION==&amp;quot;change&amp;quot;, SUBSYSTEM==&amp;quot;platform&amp;quot;, RUN+=&amp;quot;/usr/local/sbin/ultrabay_insert&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===using libata-acpi and udev===&lt;br /&gt;
&lt;br /&gt;
Starting from kernel 2.6.26-rc5, it's possible to use &amp;lt;tt&amp;gt;libata-acpi&amp;lt;/tt&amp;gt; in combination with udev to hotswap. Please check if CONFIG_ATA_ACPI is enabled in your kernel configuration.&lt;br /&gt;
&lt;br /&gt;
For 2.6.25, you need two patches which can be easily backported ([http://article.gmane.org/gmane.linux.acpi.devel/31159],[http://article.gmane.org/gmane.linux.acpi.devel/31369]).&lt;br /&gt;
&lt;br /&gt;
Create {{path|/etc/udev/rules.d/ibm-ultrabay.rules}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ENV{BAY_EVENT}==&amp;quot;3&amp;quot;, ACTION==&amp;quot;change&amp;quot;, SUBSYSTEM==&amp;quot;scsi&amp;quot;, RUN+=&amp;quot;/usr/local/sbin/ultrabay_eject&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Model-specific notes===&lt;br /&gt;
See the table above for a list of ata_piix supported laptops and the bus ID to use.&lt;br /&gt;
&lt;br /&gt;
===HAL support===&lt;br /&gt;
&lt;br /&gt;
{{NOTE| Starting from HAL 0.5.11, you need to replace &amp;quot;storage.physical_device&amp;quot; with &amp;quot;info.parent&amp;quot;.}}&lt;br /&gt;
&lt;br /&gt;
Many programs, KDE included, rely on [[HAL]] to get notifications and information about device hotplugging. You need to tell HAL that devices connected the UltraBay port are hotpluggable. To do so, create the file {{path|/etc/hal/fdi/information/10-ultrabay.fdi}} as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt; &amp;lt;!-- -*- SGML -*- --&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;deviceinfo version=&amp;quot;0.2&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;device&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- UltraBay Devices --&amp;gt;&lt;br /&gt;
    &amp;lt;match key=&amp;quot;storage.bus&amp;quot; string=&amp;quot;scsi&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;match key=&amp;quot;storage.physical_device&amp;quot; string=&amp;quot;/org/freedesktop/Hal/devices/pci_8086_2653_scsi_host_0_scsi_device_lun0&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;merge key=&amp;quot;storage.hotpluggable&amp;quot; type=&amp;quot;bool&amp;quot;&amp;gt;true&amp;lt;/merge&amp;gt;&lt;br /&gt;
      &amp;lt;/match&amp;gt;&lt;br /&gt;
    &amp;lt;/match&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/device&amp;gt;&lt;br /&gt;
&amp;lt;/deviceinfo&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The string &amp;quot;8086_2653&amp;quot; may need to be changed to match your ThinkPad model; see below.&lt;br /&gt;
&lt;br /&gt;
====Details====&lt;br /&gt;
&lt;br /&gt;
By default, HAL doesn't know that UltraBay devices are hotpluggable:&lt;br /&gt;
&lt;br /&gt;
 # PHYSDEV=/org/freedesktop/Hal/devices/pci_8086_2653_scsi_host_0_scsi_device_lun0&lt;br /&gt;
 # UDI=`hal-find-by-property --key storage.physical_device --string $PHYSDEV` || echo Failed&lt;br /&gt;
 # hal-get-property --udi $UDI --key block.device&lt;br /&gt;
 /dev/sdb&lt;br /&gt;
 # hal-get-property --udi $UDI --key storage.hotpluggable&lt;br /&gt;
 false&lt;br /&gt;
&lt;br /&gt;
After creating {{path|/etc/hal/fdi/information/10-ultrabay.fdi}} as above and re-plugging the device, it will get marked correctly:&lt;br /&gt;
&lt;br /&gt;
 # PHYSDEV=/org/freedesktop/Hal/devices/pci_8086_2653_scsi_host_0_scsi_device_lun0&lt;br /&gt;
 # UDI=`hal-find-by-property --key storage.physical_device --string $PHYSDEV` || echo Failed&lt;br /&gt;
 # hal-get-property --udi $UDI --key block.device&lt;br /&gt;
 /dev/sdb&lt;br /&gt;
 # hal-get-property --udi $UDI --key storage.hotpluggable&lt;br /&gt;
 true&lt;br /&gt;
&lt;br /&gt;
The string &amp;quot;8086_2653&amp;quot; gives the PCI ID of the [[Intel 82801FBM]] southbridge. If your model has a different southbridge, or the UltraBay is attached to a different port, then you can find the appropriate &amp;lt;tt&amp;gt;storage.physical_device&amp;lt;/tt&amp;gt; value by finding out the block device of the currently running UltraBay device (&amp;lt;tt&amp;gt;/dev/sdb&amp;lt;/tt&amp;gt; in the following example) and then running:&lt;br /&gt;
&lt;br /&gt;
 # DEVICE=/dev/sdb&lt;br /&gt;
 # UDI=`hal-find-by-property --key block.device --string $DEVICE` || echo Failed&lt;br /&gt;
 # hal-get-property --udi $UDI --key storage.physical_device&lt;br /&gt;
 /org/freedesktop/Hal/devices/pci_8086_2653_scsi_host_0_scsi_device_lun0&lt;br /&gt;
&lt;br /&gt;
If you have a different &amp;lt;tt&amp;gt;storage.physical_device&amp;lt;/tt&amp;gt; value, please report your findings.&lt;br /&gt;
&lt;br /&gt;
{| border=1&lt;br /&gt;
|+ Known South Bridge PCI IDs&lt;br /&gt;
! ID !! ThinkPad model !! South Bridge chip&lt;br /&gt;
|-&lt;br /&gt;
| 8086_248a || 2366-83U (T30) || Intel 82801CAM IDE U100 (rev 2)&lt;br /&gt;
|-&lt;br /&gt;
| 8086_2653 || 2525FAG (X41), ? (T43) || Intel 82801FBM (ICH6-M)&lt;br /&gt;
|-&lt;br /&gt;
| 8086_24ca || 237358U (T40), 2373KXU (T42p) || Intel 82801DBM (ICH4-M)&lt;br /&gt;
|-&lt;br /&gt;
| 8086_27c4 || X60           || Intel 82801GBM (ICH7 Family)&lt;br /&gt;
|-&lt;br /&gt;
| 8086_27df || Z61p, T60, T60p || Intel 82801GBM/GHM (ICH7 Family)&lt;br /&gt;
|-&lt;br /&gt;
| 8086_2850 || T61p || Intel 82801H (ICH8 Family)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==When using the &amp;lt;tt&amp;gt;ide-disk&amp;lt;/tt&amp;gt; driver==&lt;br /&gt;
The following applies if you use the &amp;lt;tt&amp;gt;ide-disk&amp;lt;/tt&amp;gt; driver for the UltraBay device.&amp;lt;BR&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Note that essentially, you shouldn't be using this driver, and use ata_piix instead unless you're running an older kernel where ata_piix won't work for you&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hotswapping is supposed to be supported as well, using either hdparm/[http://packages.debian.org/unstable/admin/hotswap Debian hotswap] or [[lt_hotswap]] to (un)register IDE devices. The latter is the recommended method with kernels from 2.6, since it will leave DMA working. However, for recent models (R52, T43, X41, Z60 and later) no method is known to work while maintaining DMA support; see [[Problems with SATA and Linux]].&lt;br /&gt;
&lt;br /&gt;
Only IDE devices (HDD's, optical drives, zip drives) require special treatment - batteries, floppies and other devices can just be pulled from the bay, provided they are not mounted or in use at the time. However, you should still power them down first using the [[ibm-acpi]] eject function.&lt;br /&gt;
&lt;br /&gt;
The [[ibm-acpi]] kernel module has an eject function ({{cmdroot|echo eject &amp;gt; /proc/acpi/ibm/bay}}). This only manages the ACPI calls to power down the device and the bay. It does not actually unregister the device from the IDE driver. {{cmdroot|cat /proc/acpi/ibm/bay}} shows &amp;quot;unoccupied&amp;quot; unless an IDE device is present, but the eject function still works and should still be used.&lt;br /&gt;
&lt;br /&gt;
To unregister the device, you can either use the [http://packages.debian.org/unstable/admin/hotswap Debian hotswap] package, or [[lt_hotswap]]. Note that lt_hotswap doesn't seem to even build on recent (at 2.6.22 or newer, although it probably broke before 2.6.22) and on newer kernels, you should not build/load the old IDE PIIX (CONFIG_BLK_DEV_PIIX) and use the natively hotswapping ata_piix (CONFIG_ATA_PIIX) as explained on the top of this page.&lt;br /&gt;
&lt;br /&gt;
[http://packages.debian.org/unstable/admin/hotswap Debian hotswap] also allows the drive to be swapped as a normal user by default, which is useful. You should use &amp;lt;tt&amp;gt;hotswap&amp;lt;/tt&amp;gt; to unregister the device and then {{cmdroot|echo eject &amp;gt; /proc/acpi/ibm/bay}}. However, if you use this method on a 2.6 kernel, you will lose DMA support for the reinserted drive. This is due to kernel issues. This method was reported to work on a ThinkPad {{T23}} (kernels 2.6.8.1, 2.6.14.2 and 2.6.15-arch) and {{T42}} (kernel 2.6.13), but fails on a ThinkPad {{T43}} (kernel 2.6.14.3).&lt;br /&gt;
&lt;br /&gt;
[[lt_hotswap]] is now the recommended method to un- and reregister the IDE device. It installs as a kernel module and has support for automatically unregistering (if loaded with the auto_eject=1 option) the device when the eject event is generated by [[ibm-acpi]]. It will leave DMA support intact. It has supported to work on a ThinkPad {{T22}} and {{T40}} and should work with many other models (but not recent models which require the &amp;lt;tt&amp;gt;ata_piix&amp;lt;/tt&amp;gt; driver for disk DMA support). With the [[lt_hotswap]] kernel module loaded, run: {{cmdroot|modprobe -r ide_cd &amp;amp;&amp;amp; modprobe -r cdrom &amp;amp;&amp;amp; echo &amp;quot;MSTR eject&amp;quot; &amp;gt; /proc/acpi/lths}}&lt;br /&gt;
&lt;br /&gt;
===HAL support===&lt;br /&gt;
&lt;br /&gt;
HAL support also can also be configured To do so, create the file {{path|/etc/hal/fdi/information/10-ultrabay.fdi}} as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt; &amp;lt;!-- -*- SGML -*- --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;deviceinfo version=&amp;quot;0.2&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;device&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- UltraBay Devices --&amp;gt;&lt;br /&gt;
    &amp;lt;match key=&amp;quot;storage.bus&amp;quot; string=&amp;quot;ide&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;match key=&amp;quot;storage.physical_device&amp;quot; string=&amp;quot;/org/freedesktop/Hal/devices/pci_8086_24ca_ide_1_0&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;merge key=&amp;quot;storage.hotpluggable&amp;quot; type=&amp;quot;bool&amp;quot;&amp;gt;true&amp;lt;/merge&amp;gt;&lt;br /&gt;
      &amp;lt;/match&amp;gt;&lt;br /&gt;
    &amp;lt;/match&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/device&amp;gt;&lt;br /&gt;
&amp;lt;/deviceinfo&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For more details see HAL section for ata driver.&lt;br /&gt;
&lt;br /&gt;
==Other comments==&lt;br /&gt;
&lt;br /&gt;
If you are hot-swapping a hard disk on a disk tray, make sure the disk does not have a password set, otherwise it will not be recognized on reinsertion.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripts]]&lt;br /&gt;
[[Category:HOWTOs]]&lt;/div&gt;</summary>
		<author><name>Zin</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=How_to_hotswap_Ultrabay_devices&amp;diff=38692</id>
		<title>How to hotswap Ultrabay devices</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=How_to_hotswap_Ultrabay_devices&amp;diff=38692"/>
		<updated>2008-08-26T11:27:28Z</updated>

		<summary type="html">&lt;p&gt;Zin: /* Scripts for hotswapping */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The following discusses hotswap (AKA &amp;quot;hotplug&amp;quot;) of devices in the [[UltraBay]].&lt;br /&gt;
&lt;br /&gt;
==Which driver?==&lt;br /&gt;
Since this may be confusing for SATA thinkpad owners, which are likely all the same for now, you have two busses and drivers: one SATA bus which works with the AHCI driver and one IDE bus for the ultrabay for which you should pick ata_piix (not piix/CONFIG_BLK_DEV_PIIX). See below for hotswapping.&lt;br /&gt;
&lt;br /&gt;
==Choosing the right driver: new style &amp;lt;tt&amp;gt;ata_piix&amp;lt;/tt&amp;gt; vs old style &amp;lt;tt&amp;gt;piix/ide-disk&amp;lt;/tt&amp;gt;==&lt;br /&gt;
For ICH5,6,7,8, systems, whether you have an older IDE only thinkpad, or a newer thinkpad like the T/Z61p, there is one SATA bus for the system hard drive and an IDE bus for the ultrabay (even if your ultrabay happens to have a SATA drive, as it'll be seen as an IDE device), you'll have two drivers to chose from for your ultrabay: the old IDE/piix+ide-disk driver, and the newer PATA (=IDE) support of the newer ata_piix driver.&amp;lt;BR&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;piix+ide-disk&amp;lt;/tt&amp;gt; are part of the old original IDE driver and your ultrabay device will show up as &amp;lt;tt&amp;gt;/dev/hda&amp;lt;/tt&amp;gt;.&amp;lt;BR&amp;gt;&amp;lt;tt&amp;gt;ata-piix&amp;lt;/tt&amp;gt; is the new SATA/PATA (=IDE) driver that will cause your ultrabay Hard Drive to show up as &amp;lt;tt&amp;gt;/dev/sda&amp;lt;/tt&amp;gt; and your CD-Rom as &amp;lt;tt&amp;gt;/dev/sr0&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The two things to know are: 1) you want to use ata_piix and 2) if you build piix in (CONFIG_BLK_DEV_PIIX enabled), or load it as a module, it'll take over the IDE bus and prevent ATA_PIIX from seeing your ultrabay. You don't want that.&lt;br /&gt;
&lt;br /&gt;
The longer details are:&amp;lt;BR&amp;gt;&lt;br /&gt;
You don't want the piix+ide-disk combo because even as modules, you will not be able to unload piix to reset the bus if there are issues swapping devices (with ata_piix, even if you forget to unregister a drive before removing it, you can unload the module and reload it to reset the bus after the fact if you have a newer thinkpad with a separate AHCI/SATA bus for the boot drive).&lt;br /&gt;
&lt;br /&gt;
As for hotswap, with piix+ide-disk, you can read the section below, but after more than one day of trying on 2.6.22.15 (as piix+ide-disk was taking over my IDE bus, and stopping me from using ata_piix before I removed it), I was not able to get hotswapping to work with piix+ide-disk (lt_hotswap would not even build on 2.6.22.15).&lt;br /&gt;
&lt;br /&gt;
hotswap just works with ata_pixx on 2.6.22, and reportedly with anything newer than 2.6.18, so you want to get rid of piix+ide-disk.&lt;br /&gt;
There are several ways to do that:&lt;br /&gt;
* if piix is built in your kernel (CONFIG_BLK_DEV_PIIX):&lt;br /&gt;
** rebuild your kernel with CONFIG_BLK_DEV_PIIX turned off.&lt;br /&gt;
** if you don't want to rebuild your kernel, try disabling the IDE bus grabbing by that driver with &amp;lt;tt&amp;gt;ide0=noprobe hda=noprobe hdb=noprobe&amp;lt;/tt&amp;gt; in your grub/lilo config (adjust the drive letters as appropriate, but note that this did not work for me on 2.6.22.15: the drive didn't show up on the piix bus, but it didn't show up on the ata_piix bus either).&lt;br /&gt;
* if piix is built in as a module&lt;br /&gt;
** you can move out the module in {{path|/lib/modules/ver/kernel/drivers/ide/pci/piix.ko}} and reboot.&lt;br /&gt;
** or build a new kernel, again with CONFIG_BLK_DEV_PIIX turned off.&lt;br /&gt;
** or add &amp;lt;tt&amp;gt;options ide_core options=&amp;quot;ide0=noprobe hda=noprobe hdb=noprobe&amp;quot;&amp;lt;/tt&amp;gt; to your modprobe.conf is supposed to work too (but didn't work on 2.6.22.15, see comment above)&lt;br /&gt;
&lt;br /&gt;
Then, continue this document to see how to do hotswap with ata_piix (if you are lucky enough to have a newer SATA thinkpad where the ata_piix driver only runs the ultrabay, and you have a separate bus and ahci driver for your main drive, it is recommended to have ata_piix as a module (&amp;lt;tt&amp;gt;CONFIG_ATA_PIIX=m&amp;lt;/tt&amp;gt;) so that you can unload/reload it if your bus gets in a bad state after a failed hotswap)&lt;br /&gt;
&lt;br /&gt;
==When using the &amp;lt;tt&amp;gt;ata_piix&amp;lt;/tt&amp;gt; driver==&lt;br /&gt;
The following applies when using the &amp;lt;tt&amp;gt;ata_piix&amp;lt;/tt&amp;gt; driver, which is necessary for many recent ThinkPad models that use an [[Intel ICH6-M]] controller. See also [[Problems with SATA and Linux]]. &lt;br /&gt;
&lt;br /&gt;
Mainline kernels before 2.6.18 cannot reliably recognize newly (re-)inserted UltraBay drives without a reboot. There are experimental hotplug patches against pre-2.6.18 mainline kernels [http://home-tj.org/wiki/index.php/Libata-tj-stable here].&lt;br /&gt;
&lt;br /&gt;
* Available hotplug patches&lt;br /&gt;
**[http://home-tj.org/files/libata-tj-stable/libata-tj-2.6.16.16-20060512.tar.bz2 Patch tarball against 2.6.16.16] ([http://lwn.net/Articles/183407/ Announce])&lt;br /&gt;
**[http://home-tj.org/files/libata-tj-stable/libata-tj-2.6.17-20060625-1.tar.bz2 Patch tarball against 2.6.17/2.6.17.1] ([http://article.gmane.org/gmane.linux.ide/11598 Announce])&lt;br /&gt;
**[http://home-tj.org/files/libata-tj-stable/libata-tj-2.6.17.4-20060710.tar.bz2 Patch tarball against 2.6.17.4]&lt;br /&gt;
**[http://whoopie.gmxhome.de/linux/patches/2.6.17.14-tj/00-libata-tj-2.6.17.4-20060710.patch Patch against 2.6.17.14]&lt;br /&gt;
&lt;br /&gt;
* Confirmed to work on the following laptops, with bus the following ID &lt;br /&gt;
**ThinkPad {{T30}}&lt;br /&gt;
**ThinkPad {{T43}}, {{T43p}}&lt;br /&gt;
**ThinkPad {{R52}}&lt;br /&gt;
**ThinkPad {{T60}} ID=4&lt;br /&gt;
**ThinkPad {{T61}} ID=0&lt;br /&gt;
**ThinkPad {{Z61p}} ID=4 (0-3:ahci, 5-6: ata_piix)&lt;br /&gt;
ID will typically be 1 if you only have an IDE bus (0 is boot drive, 1 is ultrabay), and it'll be 4 if you have a SATA bus your system boots from (ID 0-3) and an IDE bus for your ultrabay (ID 4-5).&amp;lt;BR&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Note that even on a given laptop model the ID can vary depending on whether your kernel has drivers that configure your boot drive is using the old style IDE driver (which doesn't add IDs before your ultrabay), or whether your boot drive is using the new style driver (which  adds IDs before your ultrabay)&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hotplug just works with kernels newer than 2.6.18 ( or older kernels that were patched to support &amp;lt;tt&amp;gt;ata_piix&amp;lt;/tt&amp;gt; hotplug (don't try it otherwise!))&amp;lt;BR&amp;gt;&lt;br /&gt;
First, it is recommended you find the right SCSI ID for your drive to hotswap and unregister it before removing it (this works with all recent mainline kernels):&lt;br /&gt;
 {{cmdroot|echo 1 &amp;gt; /sys/class/scsi_device/$ID:0:0:0/device/delete}} &lt;br /&gt;
 {{cmdroot|echo eject &amp;gt;  /proc/acpi/ibm/bay}}&lt;br /&gt;
The drive can now be ejected (without this, your IDE bus may complain if you just yank a drive, but you can usually recover by unloading/reloading the ata_piix module on a SATA laptop if your main drive is not on the ata_piix bus)&lt;br /&gt;
&lt;br /&gt;
You can then issue the following after inserting an UltraBay drive to rescan the port:&lt;br /&gt;
 {{cmdroot|echo 0 0 0 &amp;gt;  /sys/class/scsi_host/host$ID/scan}}&lt;br /&gt;
The inserted drive should now be recognized by the kernel, and appropriate {{path|/dev/*}} entries created automatically (e.g., by &amp;lt;tt&amp;gt;udev&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Ted T'so has also written this hotswap patch, which may or may not be needed for you, see [http://www.mail-archive.com/linux-acpi@vger.kernel.org/msg04716.html hotswap patch] and report back&lt;br /&gt;
&lt;br /&gt;
===Scripts for hotswapping===&lt;br /&gt;
&lt;br /&gt;
The following scripts and [[acpid]] daemon configuration files do the following:&lt;br /&gt;
* Automatically unmounts the relevant filesystems and power off the UltraBay when the UltraBay eject lever is released. Screams if some filesystem can't be unmounted.&lt;br /&gt;
* Rescans the UltraBay port when then UltraBay eject lever is pushed back in.&lt;br /&gt;
&lt;br /&gt;
They assumes you're using the &amp;lt;tt&amp;gt;ata_piix&amp;lt;/tt&amp;gt; driver with an appropriate kernel (see above).&lt;br /&gt;
&lt;br /&gt;
Create {{path|/usr/local/sbin/ultrabay_insert}} with permissions 755:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
echo 12 &amp;gt; /proc/acpi/ibm/beep&lt;br /&gt;
sync&lt;br /&gt;
echo 0 0 0 &amp;gt; /sys/class/scsi_host/host1/scan&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create {{path|/usr/local/sbin/ultrabay_eject}} with permissions 755:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
ULTRABAY_SYSDIR='/sys/class/scsi_device/1:0:0:0/device'&lt;br /&gt;
shopt -s nullglob&lt;br /&gt;
&lt;br /&gt;
# Umount the filesystem(s) backed by the given major:minor device(s)&lt;br /&gt;
unmount_rdev() { perl - &amp;quot;$@&amp;quot; &amp;lt;&amp;lt;'EOPERL'  # let's do it in Perl&lt;br /&gt;
	for $major_minor (@ARGV) {&lt;br /&gt;
		$major_minor =~ m/^(\d+):(\d+)$/ or die;&lt;br /&gt;
		push(@tgt_rdevs, ($1&amp;lt;&amp;lt;8)|$2);&lt;br /&gt;
	}&lt;br /&gt;
        # Sort by reverse length of mount point, to unmount sub-directories first&lt;br /&gt;
        open MOUNTS,&amp;quot;&amp;lt;/proc/mounts&amp;quot; or die &amp;quot;$!&amp;quot;;&lt;br /&gt;
        @mounts=sort { length($b-&amp;gt;[1]) &amp;lt;=&amp;gt; length($a-&amp;gt;[1]) } map { [ split ] } &amp;lt;MOUNTS&amp;gt;;&lt;br /&gt;
        close MOUNTS;&lt;br /&gt;
        foreach $m (@mounts) {&lt;br /&gt;
                ($dev,$dir)=@$m;&lt;br /&gt;
		next unless -b $dev;  $rdev=(stat($dev))[6];&lt;br /&gt;
		next unless grep($_==$rdev, @tgt_rdevs);&lt;br /&gt;
		system(&amp;quot;umount&amp;quot;,&amp;quot;-v&amp;quot;,&amp;quot;$dir&amp;quot;)==0  or  $bad=1;&lt;br /&gt;
	}&lt;br /&gt;
	exit 1 if $bad;&lt;br /&gt;
EOPERL&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# Get the UltraBay's /dev/foo block device node&lt;br /&gt;
ultrabay_dev_node() {&lt;br /&gt;
	UDEV_PATH=&amp;quot;`readlink -e &amp;quot;$ULTRABAY_SYSDIR/block:&amp;quot;*`&amp;quot; || return 1&lt;br /&gt;
	UDEV_NAME=&amp;quot;`udevinfo -q name -p $UDEV_PATH`&amp;quot; || return 1&lt;br /&gt;
	echo /dev/$UDEV_NAME&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if [ -d $ULTRABAY_SYSDIR ]; then&lt;br /&gt;
	sync&lt;br /&gt;
	# Unmount filesystems backed by this device&lt;br /&gt;
	unmount_rdev `cat $ULTRABAY_SYSDIR/block\:*/dev     \&lt;br /&gt;
	                  $ULTRABAY_SYSDIR/block\:*/*/dev`  \&lt;br /&gt;
	|| {&lt;br /&gt;
		echo 10 &amp;gt; /proc/acpi/ibm/beep;  # error tone&lt;br /&gt;
		exit 1;&lt;br /&gt;
	}&lt;br /&gt;
        sync&lt;br /&gt;
        # Nicely power off the device&lt;br /&gt;
	DEVNODE=`ultrabay_dev_node` &amp;amp;&amp;amp; hdparm -Y $DEVNODE&lt;br /&gt;
        # Let HAL+KDE notice the unmount and let the disk spin down&lt;br /&gt;
	sleep 0.5&lt;br /&gt;
	# Unregister this SCSI device:&lt;br /&gt;
	sync&lt;br /&gt;
	echo 1 &amp;gt; $ULTRABAY_SYSDIR/delete&lt;br /&gt;
fi&lt;br /&gt;
sync&lt;br /&gt;
# Turn off power to the UltraBay:&lt;br /&gt;
if [ -d /sys/devices/platform/bay.0 ]; then&lt;br /&gt;
	echo 1 &amp;gt; /sys/devices/platform/bay.0/eject&lt;br /&gt;
elif [ -e /proc/acpi/ibm/bay ]; then&lt;br /&gt;
	echo eject &amp;gt; /proc/acpi/ibm/bay&lt;br /&gt;
fi&lt;br /&gt;
# Tell the user we're OK&lt;br /&gt;
echo 12 &amp;gt; /proc/acpi/ibm/beep&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Use the modified version below if the above doesn't work for you (for kernels 2.6.25+ due to ULTRABAY_SYSDIR/block\:*/dev path change). It was tested on a Thinkpad X41 with Fedora 9 and kernel 2.6.25.11:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
ULTRABAY_SYSDIR='/sys/class/scsi_device/1:0:0:0/device'&lt;br /&gt;
shopt -s nullglob&lt;br /&gt;
&lt;br /&gt;
# Umount the filesystem(s) backed by the given major:minor device(s)&lt;br /&gt;
unmount_rdev() { perl - &amp;quot;$@&amp;quot; &amp;lt;&amp;lt;'EOPERL'  # let's do it in Perl&lt;br /&gt;
	for $major_minor (@ARGV) {&lt;br /&gt;
		$major_minor =~ m/^(\d+):(\d+)$/ or die;&lt;br /&gt;
		push(@tgt_rdevs, ($1&amp;lt;&amp;lt;8)|$2);&lt;br /&gt;
	}&lt;br /&gt;
        # Sort by reverse length of mount point, to unmount sub-directories first&lt;br /&gt;
        open MOUNTS,&amp;quot;&amp;lt;/proc/mounts&amp;quot; or die &amp;quot;$!&amp;quot;;&lt;br /&gt;
        @mounts=sort { length($b-&amp;gt;[1]) &amp;lt;=&amp;gt; length($a-&amp;gt;[1]) } map { [ split ] } &amp;lt;MOUNTS&amp;gt;;&lt;br /&gt;
        close MOUNTS;&lt;br /&gt;
        foreach $m (@mounts) {&lt;br /&gt;
                ($dev,$dir)=@$m;&lt;br /&gt;
		next unless -b $dev;  $rdev=(stat($dev))[6];&lt;br /&gt;
		next unless grep($_==$rdev, @tgt_rdevs);&lt;br /&gt;
		system(&amp;quot;umount&amp;quot;,&amp;quot;-v&amp;quot;,&amp;quot;$dir&amp;quot;)==0  or  $bad=1;&lt;br /&gt;
	}&lt;br /&gt;
	exit 1 if $bad;&lt;br /&gt;
EOPERL&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# Get the UltraBay's /dev/foo block device node&lt;br /&gt;
ultrabay_dev_node() {&lt;br /&gt;
	UDEV_PATH=&amp;quot;`readlink -e &amp;quot;$ULTRABAY_SYSDIR/block/&amp;quot;*`&amp;quot; || return 1&lt;br /&gt;
	UDEV_NAME=&amp;quot;`udevinfo -q name -p $UDEV_PATH`&amp;quot; || return 1&lt;br /&gt;
	echo /dev/$UDEV_NAME&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if [ -d $ULTRABAY_SYSDIR ]; then&lt;br /&gt;
	sync&lt;br /&gt;
	# Unmount filesystems backed by this device&lt;br /&gt;
	unmount_rdev `cat $ULTRABAY_SYSDIR/block/*/dev     \&lt;br /&gt;
	                  $ULTRABAY_SYSDIR/block/*/*/dev`  \&lt;br /&gt;
	|| {&lt;br /&gt;
		echo 10 &amp;gt; /proc/acpi/ibm/beep;  # error tone&lt;br /&gt;
		exit 1;&lt;br /&gt;
	}&lt;br /&gt;
        sync&lt;br /&gt;
        # Nicely power off the device&lt;br /&gt;
	DEVNODE=`ultrabay_dev_node` &amp;amp;&amp;amp; hdparm -Y $DEVNODE&lt;br /&gt;
        # Let HAL+KDE notice the unmount and let the disk spin down&lt;br /&gt;
	sleep 0.5&lt;br /&gt;
	# Unregister this SCSI device:&lt;br /&gt;
	sync&lt;br /&gt;
	echo 1 &amp;gt; $ULTRABAY_SYSDIR/delete&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# We really need a 3 sec pause here otherwise the system will freeze..&lt;br /&gt;
sleep 3&lt;br /&gt;
&lt;br /&gt;
# Turn off power to the UltraBay:&lt;br /&gt;
if [ -d /sys/devices/platform/bay.0 ]; then&lt;br /&gt;
	echo 1 &amp;gt; /sys/devices/platform/bay.0/eject&lt;br /&gt;
elif [ -e /proc/acpi/ibm/bay ]; then&lt;br /&gt;
	echo eject &amp;gt; /proc/acpi/ibm/bay&lt;br /&gt;
fi&lt;br /&gt;
# Tell the user we're OK&lt;br /&gt;
echo 12 &amp;gt; /proc/acpi/ibm/beep&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create {{path|/etc/acpi/events/ultrabay-insert}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
event=ibm/bay MSTR 00000001 00000000&lt;br /&gt;
action=/usr/local/sbin/ultrabay_insert&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create {{path|/etc/acpi/events/ultrabay-eject}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
event=ibm/bay MSTR 00000003 00000000&lt;br /&gt;
action=/usr/local/sbin/ultrabay_eject&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart &amp;lt;tt&amp;gt;acpid&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===using the generic bay driver and udev===&lt;br /&gt;
&lt;br /&gt;
Starting from kernel 2.6.23-rc3, it's possible to use the generic &amp;lt;tt&amp;gt;bay&amp;lt;/tt&amp;gt; driver in combination with udev to hotswap. Please check if CONFIG_ACPI_BAY is enabled (module or built-in) in your kernel configuration.&lt;br /&gt;
&lt;br /&gt;
Create {{path|/etc/udev/rules.d/ibm-ultrabay.rules}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ENV{BAY_EVENT}==&amp;quot;3&amp;quot;, KERNEL==&amp;quot;bay.0&amp;quot;, ACTION==&amp;quot;change&amp;quot;, SUBSYSTEM==&amp;quot;platform&amp;quot;, RUN+=&amp;quot;/usr/local/sbin/ultrabay_eject&amp;quot;&lt;br /&gt;
ENV{BAY_EVENT}==&amp;quot;1&amp;quot;, KERNEL==&amp;quot;bay.0&amp;quot;, ACTION==&amp;quot;change&amp;quot;, SUBSYSTEM==&amp;quot;platform&amp;quot;, RUN+=&amp;quot;/usr/local/sbin/ultrabay_insert&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===using libata-acpi and udev===&lt;br /&gt;
&lt;br /&gt;
Starting from kernel 2.6.26-rc5, it's possible to use &amp;lt;tt&amp;gt;libata-acpi&amp;lt;/tt&amp;gt; in combination with udev to hotswap. Please check if CONFIG_ATA_ACPI is enabled in your kernel configuration.&lt;br /&gt;
&lt;br /&gt;
For 2.6.25, you need two patches which can be easily backported ([http://article.gmane.org/gmane.linux.acpi.devel/31159],[http://article.gmane.org/gmane.linux.acpi.devel/31369]).&lt;br /&gt;
&lt;br /&gt;
Create {{path|/etc/udev/rules.d/ibm-ultrabay.rules}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ENV{BAY_EVENT}==&amp;quot;3&amp;quot;, ACTION==&amp;quot;change&amp;quot;, SUBSYSTEM==&amp;quot;scsi&amp;quot;, RUN+=&amp;quot;/usr/local/sbin/ultrabay_eject&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Model-specific notes===&lt;br /&gt;
See the table above for a list of ata_piix supported laptops and the bus ID to use.&lt;br /&gt;
&lt;br /&gt;
===HAL support===&lt;br /&gt;
&lt;br /&gt;
{{NOTE| Starting from HAL 0.5.11, you need to replace &amp;quot;storage.physical_device&amp;quot; with &amp;quot;info.parent&amp;quot;.}}&lt;br /&gt;
&lt;br /&gt;
Many programs, KDE included, rely on [[HAL]] to get notifications and information about device hotplugging. You need to tell HAL that devices connected the UltraBay port are hotpluggable. To do so, create the file {{path|/etc/hal/fdi/information/10-ultrabay.fdi}} as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt; &amp;lt;!-- -*- SGML -*- --&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;deviceinfo version=&amp;quot;0.2&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;device&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- UltraBay Devices --&amp;gt;&lt;br /&gt;
    &amp;lt;match key=&amp;quot;storage.bus&amp;quot; string=&amp;quot;scsi&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;match key=&amp;quot;storage.physical_device&amp;quot; string=&amp;quot;/org/freedesktop/Hal/devices/pci_8086_2653_scsi_host_0_scsi_device_lun0&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;merge key=&amp;quot;storage.hotpluggable&amp;quot; type=&amp;quot;bool&amp;quot;&amp;gt;true&amp;lt;/merge&amp;gt;&lt;br /&gt;
      &amp;lt;/match&amp;gt;&lt;br /&gt;
    &amp;lt;/match&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/device&amp;gt;&lt;br /&gt;
&amp;lt;/deviceinfo&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The string &amp;quot;8086_2653&amp;quot; may need to be changed to match your ThinkPad model; see below.&lt;br /&gt;
&lt;br /&gt;
====Details====&lt;br /&gt;
&lt;br /&gt;
By default, HAL doesn't know that UltraBay devices are hotpluggable:&lt;br /&gt;
&lt;br /&gt;
 # PHYSDEV=/org/freedesktop/Hal/devices/pci_8086_2653_scsi_host_0_scsi_device_lun0&lt;br /&gt;
 # UDI=`hal-find-by-property --key storage.physical_device --string $PHYSDEV` || echo Failed&lt;br /&gt;
 # hal-get-property --udi $UDI --key block.device&lt;br /&gt;
 /dev/sdb&lt;br /&gt;
 # hal-get-property --udi $UDI --key storage.hotpluggable&lt;br /&gt;
 false&lt;br /&gt;
&lt;br /&gt;
After creating {{path|/etc/hal/fdi/information/10-ultrabay.fdi}} as above and re-plugging the device, it will get marked correctly:&lt;br /&gt;
&lt;br /&gt;
 # PHYSDEV=/org/freedesktop/Hal/devices/pci_8086_2653_scsi_host_0_scsi_device_lun0&lt;br /&gt;
 # UDI=`hal-find-by-property --key storage.physical_device --string $PHYSDEV` || echo Failed&lt;br /&gt;
 # hal-get-property --udi $UDI --key block.device&lt;br /&gt;
 /dev/sdb&lt;br /&gt;
 # hal-get-property --udi $UDI --key storage.hotpluggable&lt;br /&gt;
 true&lt;br /&gt;
&lt;br /&gt;
The string &amp;quot;8086_2653&amp;quot; gives the PCI ID of the [[Intel 82801FBM]] southbridge. If your model has a different southbridge, or the UltraBay is attached to a different port, then you can find the appropriate &amp;lt;tt&amp;gt;storage.physical_device&amp;lt;/tt&amp;gt; value by finding out the block device of the currently running UltraBay device (&amp;lt;tt&amp;gt;/dev/sdb&amp;lt;/tt&amp;gt; in the following example) and then running:&lt;br /&gt;
&lt;br /&gt;
 # DEVICE=/dev/sdb&lt;br /&gt;
 # UDI=`hal-find-by-property --key block.device --string $DEVICE` || echo Failed&lt;br /&gt;
 # hal-get-property --udi $UDI --key storage.physical_device&lt;br /&gt;
 /org/freedesktop/Hal/devices/pci_8086_2653_scsi_host_0_scsi_device_lun0&lt;br /&gt;
&lt;br /&gt;
If you have a different &amp;lt;tt&amp;gt;storage.physical_device&amp;lt;/tt&amp;gt; value, please report your findings.&lt;br /&gt;
&lt;br /&gt;
{| border=1&lt;br /&gt;
|+ Known South Bridge PCI IDs&lt;br /&gt;
! ID !! ThinkPad model !! South Bridge chip&lt;br /&gt;
|-&lt;br /&gt;
| 8086_248a || 2366-83U (T30) || Intel 82801CAM IDE U100 (rev 2)&lt;br /&gt;
|-&lt;br /&gt;
| 8086_2653 || 2525FAG (X41), ? (T43) || Intel 82801FBM (ICH6-M)&lt;br /&gt;
|-&lt;br /&gt;
| 8086_24ca || 237358U (T40), 2373KXU (T42p) || Intel 82801DBM (ICH4-M)&lt;br /&gt;
|-&lt;br /&gt;
| 8086_27c4 || X60           || Intel 82801GBM (ICH7 Family)&lt;br /&gt;
|-&lt;br /&gt;
| 8086_27df || Z61p, T60, T60p || Intel 82801GBM/GHM (ICH7 Family)&lt;br /&gt;
|-&lt;br /&gt;
| 8086_2850 || T61p || Intel 82801H (ICH8 Family)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==When using the &amp;lt;tt&amp;gt;ide-disk&amp;lt;/tt&amp;gt; driver==&lt;br /&gt;
The following applies if you use the &amp;lt;tt&amp;gt;ide-disk&amp;lt;/tt&amp;gt; driver for the UltraBay device.&amp;lt;BR&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Note that essentially, you shouldn't be using this driver, and use ata_piix instead unless you're running an older kernel where ata_piix won't work for you&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hotswapping is supposed to be supported as well, using either hdparm/[http://packages.debian.org/unstable/admin/hotswap Debian hotswap] or [[lt_hotswap]] to (un)register IDE devices. The latter is the recommended method with kernels from 2.6, since it will leave DMA working. However, for recent models (R52, T43, X41, Z60 and later) no method is known to work while maintaining DMA support; see [[Problems with SATA and Linux]].&lt;br /&gt;
&lt;br /&gt;
Only IDE devices (HDD's, optical drives, zip drives) require special treatment - batteries, floppies and other devices can just be pulled from the bay, provided they are not mounted or in use at the time. However, you should still power them down first using the [[ibm-acpi]] eject function.&lt;br /&gt;
&lt;br /&gt;
The [[ibm-acpi]] kernel module has an eject function ({{cmdroot|echo eject &amp;gt; /proc/acpi/ibm/bay}}). This only manages the ACPI calls to power down the device and the bay. It does not actually unregister the device from the IDE driver. {{cmdroot|cat /proc/acpi/ibm/bay}} shows &amp;quot;unoccupied&amp;quot; unless an IDE device is present, but the eject function still works and should still be used.&lt;br /&gt;
&lt;br /&gt;
To unregister the device, you can either use the [http://packages.debian.org/unstable/admin/hotswap Debian hotswap] package, or [[lt_hotswap]]. Note that lt_hotswap doesn't seem to even build on recent (at 2.6.22 or newer, although it probably broke before 2.6.22) and on newer kernels, you should not build/load the old IDE PIIX (CONFIG_BLK_DEV_PIIX) and use the natively hotswapping ata_piix (CONFIG_ATA_PIIX) as explained on the top of this page.&lt;br /&gt;
&lt;br /&gt;
[http://packages.debian.org/unstable/admin/hotswap Debian hotswap] also allows the drive to be swapped as a normal user by default, which is useful. You should use &amp;lt;tt&amp;gt;hotswap&amp;lt;/tt&amp;gt; to unregister the device and then {{cmdroot|echo eject &amp;gt; /proc/acpi/ibm/bay}}. However, if you use this method on a 2.6 kernel, you will lose DMA support for the reinserted drive. This is due to kernel issues. This method was reported to work on a ThinkPad {{T23}} (kernels 2.6.8.1, 2.6.14.2 and 2.6.15-arch) and {{T42}} (kernel 2.6.13), but fails on a ThinkPad {{T43}} (kernel 2.6.14.3).&lt;br /&gt;
&lt;br /&gt;
[[lt_hotswap]] is now the recommended method to un- and reregister the IDE device. It installs as a kernel module and has support for automatically unregistering (if loaded with the auto_eject=1 option) the device when the eject event is generated by [[ibm-acpi]]. It will leave DMA support intact. It has supported to work on a ThinkPad {{T22}} and {{T40}} and should work with many other models (but not recent models which require the &amp;lt;tt&amp;gt;ata_piix&amp;lt;/tt&amp;gt; driver for disk DMA support). With the [[lt_hotswap]] kernel module loaded, run: {{cmdroot|modprobe -r ide_cd &amp;amp;&amp;amp; modprobe -r cdrom &amp;amp;&amp;amp; echo &amp;quot;MSTR eject&amp;quot; &amp;gt; /proc/acpi/lths}}&lt;br /&gt;
&lt;br /&gt;
===HAL support===&lt;br /&gt;
&lt;br /&gt;
HAL support also can also be configured To do so, create the file {{path|/etc/hal/fdi/information/10-ultrabay.fdi}} as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt; &amp;lt;!-- -*- SGML -*- --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;deviceinfo version=&amp;quot;0.2&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;device&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- UltraBay Devices --&amp;gt;&lt;br /&gt;
    &amp;lt;match key=&amp;quot;storage.bus&amp;quot; string=&amp;quot;ide&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;match key=&amp;quot;storage.physical_device&amp;quot; string=&amp;quot;/org/freedesktop/Hal/devices/pci_8086_24ca_ide_1_0&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;merge key=&amp;quot;storage.hotpluggable&amp;quot; type=&amp;quot;bool&amp;quot;&amp;gt;true&amp;lt;/merge&amp;gt;&lt;br /&gt;
      &amp;lt;/match&amp;gt;&lt;br /&gt;
    &amp;lt;/match&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/device&amp;gt;&lt;br /&gt;
&amp;lt;/deviceinfo&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For more details see HAL section for ata driver.&lt;br /&gt;
&lt;br /&gt;
==Other comments==&lt;br /&gt;
&lt;br /&gt;
If you are hot-swapping a hard disk on a disk tray, make sure the disk does not have a password set, otherwise it will not be recognized on reinsertion.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripts]]&lt;br /&gt;
[[Category:HOWTOs]]&lt;/div&gt;</summary>
		<author><name>Zin</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=How_to_hotswap_Ultrabay_devices&amp;diff=38691</id>
		<title>How to hotswap Ultrabay devices</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=How_to_hotswap_Ultrabay_devices&amp;diff=38691"/>
		<updated>2008-08-26T10:55:45Z</updated>

		<summary type="html">&lt;p&gt;Zin: /* Scripts for hotswapping */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The following discusses hotswap (AKA &amp;quot;hotplug&amp;quot;) of devices in the [[UltraBay]].&lt;br /&gt;
&lt;br /&gt;
==Which driver?==&lt;br /&gt;
Since this may be confusing for SATA thinkpad owners, which are likely all the same for now, you have two busses and drivers: one SATA bus which works with the AHCI driver and one IDE bus for the ultrabay for which you should pick ata_piix (not piix/CONFIG_BLK_DEV_PIIX). See below for hotswapping.&lt;br /&gt;
&lt;br /&gt;
==Choosing the right driver: new style &amp;lt;tt&amp;gt;ata_piix&amp;lt;/tt&amp;gt; vs old style &amp;lt;tt&amp;gt;piix/ide-disk&amp;lt;/tt&amp;gt;==&lt;br /&gt;
For ICH5,6,7,8, systems, whether you have an older IDE only thinkpad, or a newer thinkpad like the T/Z61p, there is one SATA bus for the system hard drive and an IDE bus for the ultrabay (even if your ultrabay happens to have a SATA drive, as it'll be seen as an IDE device), you'll have two drivers to chose from for your ultrabay: the old IDE/piix+ide-disk driver, and the newer PATA (=IDE) support of the newer ata_piix driver.&amp;lt;BR&amp;gt;&lt;br /&gt;
&amp;lt;tt&amp;gt;piix+ide-disk&amp;lt;/tt&amp;gt; are part of the old original IDE driver and your ultrabay device will show up as &amp;lt;tt&amp;gt;/dev/hda&amp;lt;/tt&amp;gt;.&amp;lt;BR&amp;gt;&amp;lt;tt&amp;gt;ata-piix&amp;lt;/tt&amp;gt; is the new SATA/PATA (=IDE) driver that will cause your ultrabay Hard Drive to show up as &amp;lt;tt&amp;gt;/dev/sda&amp;lt;/tt&amp;gt; and your CD-Rom as &amp;lt;tt&amp;gt;/dev/sr0&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The two things to know are: 1) you want to use ata_piix and 2) if you build piix in (CONFIG_BLK_DEV_PIIX enabled), or load it as a module, it'll take over the IDE bus and prevent ATA_PIIX from seeing your ultrabay. You don't want that.&lt;br /&gt;
&lt;br /&gt;
The longer details are:&amp;lt;BR&amp;gt;&lt;br /&gt;
You don't want the piix+ide-disk combo because even as modules, you will not be able to unload piix to reset the bus if there are issues swapping devices (with ata_piix, even if you forget to unregister a drive before removing it, you can unload the module and reload it to reset the bus after the fact if you have a newer thinkpad with a separate AHCI/SATA bus for the boot drive).&lt;br /&gt;
&lt;br /&gt;
As for hotswap, with piix+ide-disk, you can read the section below, but after more than one day of trying on 2.6.22.15 (as piix+ide-disk was taking over my IDE bus, and stopping me from using ata_piix before I removed it), I was not able to get hotswapping to work with piix+ide-disk (lt_hotswap would not even build on 2.6.22.15).&lt;br /&gt;
&lt;br /&gt;
hotswap just works with ata_pixx on 2.6.22, and reportedly with anything newer than 2.6.18, so you want to get rid of piix+ide-disk.&lt;br /&gt;
There are several ways to do that:&lt;br /&gt;
* if piix is built in your kernel (CONFIG_BLK_DEV_PIIX):&lt;br /&gt;
** rebuild your kernel with CONFIG_BLK_DEV_PIIX turned off.&lt;br /&gt;
** if you don't want to rebuild your kernel, try disabling the IDE bus grabbing by that driver with &amp;lt;tt&amp;gt;ide0=noprobe hda=noprobe hdb=noprobe&amp;lt;/tt&amp;gt; in your grub/lilo config (adjust the drive letters as appropriate, but note that this did not work for me on 2.6.22.15: the drive didn't show up on the piix bus, but it didn't show up on the ata_piix bus either).&lt;br /&gt;
* if piix is built in as a module&lt;br /&gt;
** you can move out the module in {{path|/lib/modules/ver/kernel/drivers/ide/pci/piix.ko}} and reboot.&lt;br /&gt;
** or build a new kernel, again with CONFIG_BLK_DEV_PIIX turned off.&lt;br /&gt;
** or add &amp;lt;tt&amp;gt;options ide_core options=&amp;quot;ide0=noprobe hda=noprobe hdb=noprobe&amp;quot;&amp;lt;/tt&amp;gt; to your modprobe.conf is supposed to work too (but didn't work on 2.6.22.15, see comment above)&lt;br /&gt;
&lt;br /&gt;
Then, continue this document to see how to do hotswap with ata_piix (if you are lucky enough to have a newer SATA thinkpad where the ata_piix driver only runs the ultrabay, and you have a separate bus and ahci driver for your main drive, it is recommended to have ata_piix as a module (&amp;lt;tt&amp;gt;CONFIG_ATA_PIIX=m&amp;lt;/tt&amp;gt;) so that you can unload/reload it if your bus gets in a bad state after a failed hotswap)&lt;br /&gt;
&lt;br /&gt;
==When using the &amp;lt;tt&amp;gt;ata_piix&amp;lt;/tt&amp;gt; driver==&lt;br /&gt;
The following applies when using the &amp;lt;tt&amp;gt;ata_piix&amp;lt;/tt&amp;gt; driver, which is necessary for many recent ThinkPad models that use an [[Intel ICH6-M]] controller. See also [[Problems with SATA and Linux]]. &lt;br /&gt;
&lt;br /&gt;
Mainline kernels before 2.6.18 cannot reliably recognize newly (re-)inserted UltraBay drives without a reboot. There are experimental hotplug patches against pre-2.6.18 mainline kernels [http://home-tj.org/wiki/index.php/Libata-tj-stable here].&lt;br /&gt;
&lt;br /&gt;
* Available hotplug patches&lt;br /&gt;
**[http://home-tj.org/files/libata-tj-stable/libata-tj-2.6.16.16-20060512.tar.bz2 Patch tarball against 2.6.16.16] ([http://lwn.net/Articles/183407/ Announce])&lt;br /&gt;
**[http://home-tj.org/files/libata-tj-stable/libata-tj-2.6.17-20060625-1.tar.bz2 Patch tarball against 2.6.17/2.6.17.1] ([http://article.gmane.org/gmane.linux.ide/11598 Announce])&lt;br /&gt;
**[http://home-tj.org/files/libata-tj-stable/libata-tj-2.6.17.4-20060710.tar.bz2 Patch tarball against 2.6.17.4]&lt;br /&gt;
**[http://whoopie.gmxhome.de/linux/patches/2.6.17.14-tj/00-libata-tj-2.6.17.4-20060710.patch Patch against 2.6.17.14]&lt;br /&gt;
&lt;br /&gt;
* Confirmed to work on the following laptops, with bus the following ID &lt;br /&gt;
**ThinkPad {{T30}}&lt;br /&gt;
**ThinkPad {{T43}}, {{T43p}}&lt;br /&gt;
**ThinkPad {{R52}}&lt;br /&gt;
**ThinkPad {{T60}} ID=4&lt;br /&gt;
**ThinkPad {{T61}} ID=0&lt;br /&gt;
**ThinkPad {{Z61p}} ID=4 (0-3:ahci, 5-6: ata_piix)&lt;br /&gt;
ID will typically be 1 if you only have an IDE bus (0 is boot drive, 1 is ultrabay), and it'll be 4 if you have a SATA bus your system boots from (ID 0-3) and an IDE bus for your ultrabay (ID 4-5).&amp;lt;BR&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Note that even on a given laptop model the ID can vary depending on whether your kernel has drivers that configure your boot drive is using the old style IDE driver (which doesn't add IDs before your ultrabay), or whether your boot drive is using the new style driver (which  adds IDs before your ultrabay)&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hotplug just works with kernels newer than 2.6.18 ( or older kernels that were patched to support &amp;lt;tt&amp;gt;ata_piix&amp;lt;/tt&amp;gt; hotplug (don't try it otherwise!))&amp;lt;BR&amp;gt;&lt;br /&gt;
First, it is recommended you find the right SCSI ID for your drive to hotswap and unregister it before removing it (this works with all recent mainline kernels):&lt;br /&gt;
 {{cmdroot|echo 1 &amp;gt; /sys/class/scsi_device/$ID:0:0:0/device/delete}} &lt;br /&gt;
 {{cmdroot|echo eject &amp;gt;  /proc/acpi/ibm/bay}}&lt;br /&gt;
The drive can now be ejected (without this, your IDE bus may complain if you just yank a drive, but you can usually recover by unloading/reloading the ata_piix module on a SATA laptop if your main drive is not on the ata_piix bus)&lt;br /&gt;
&lt;br /&gt;
You can then issue the following after inserting an UltraBay drive to rescan the port:&lt;br /&gt;
 {{cmdroot|echo 0 0 0 &amp;gt;  /sys/class/scsi_host/host$ID/scan}}&lt;br /&gt;
The inserted drive should now be recognized by the kernel, and appropriate {{path|/dev/*}} entries created automatically (e.g., by &amp;lt;tt&amp;gt;udev&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Ted T'so has also written this hotswap patch, which may or may not be needed for you, see [http://www.mail-archive.com/linux-acpi@vger.kernel.org/msg04716.html hotswap patch] and report back&lt;br /&gt;
&lt;br /&gt;
===Scripts for hotswapping===&lt;br /&gt;
&lt;br /&gt;
The following scripts and [[acpid]] daemon configuration files do the following:&lt;br /&gt;
* Automatically unmounts the relevant filesystems and power off the UltraBay when the UltraBay eject lever is released. Screams if some filesystem can't be unmounted.&lt;br /&gt;
* Rescans the UltraBay port when then UltraBay eject lever is pushed back in.&lt;br /&gt;
&lt;br /&gt;
They assumes you're using the &amp;lt;tt&amp;gt;ata_piix&amp;lt;/tt&amp;gt; driver with an appropriate kernel (see above).&lt;br /&gt;
&lt;br /&gt;
Create {{path|/usr/local/sbin/ultrabay_insert}} with permissions 755:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
echo 12 &amp;gt; /proc/acpi/ibm/beep&lt;br /&gt;
sync&lt;br /&gt;
echo 0 0 0 &amp;gt; /sys/class/scsi_host/host1/scan&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create {{path|/usr/local/sbin/ultrabay_eject}} with permissions 755:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
ULTRABAY_SYSDIR='/sys/class/scsi_device/1:0:0:0/device'&lt;br /&gt;
shopt -s nullglob&lt;br /&gt;
&lt;br /&gt;
# Umount the filesystem(s) backed by the given major:minor device(s)&lt;br /&gt;
unmount_rdev() { perl - &amp;quot;$@&amp;quot; &amp;lt;&amp;lt;'EOPERL'  # let's do it in Perl&lt;br /&gt;
	for $major_minor (@ARGV) {&lt;br /&gt;
		$major_minor =~ m/^(\d+):(\d+)$/ or die;&lt;br /&gt;
		push(@tgt_rdevs, ($1&amp;lt;&amp;lt;8)|$2);&lt;br /&gt;
	}&lt;br /&gt;
        # Sort by reverse length of mount point, to unmount sub-directories first&lt;br /&gt;
        open MOUNTS,&amp;quot;&amp;lt;/proc/mounts&amp;quot; or die &amp;quot;$!&amp;quot;;&lt;br /&gt;
        @mounts=sort { length($b-&amp;gt;[1]) &amp;lt;=&amp;gt; length($a-&amp;gt;[1]) } map { [ split ] } &amp;lt;MOUNTS&amp;gt;;&lt;br /&gt;
        close MOUNTS;&lt;br /&gt;
        foreach $m (@mounts) {&lt;br /&gt;
                ($dev,$dir)=@$m;&lt;br /&gt;
		next unless -b $dev;  $rdev=(stat($dev))[6];&lt;br /&gt;
		next unless grep($_==$rdev, @tgt_rdevs);&lt;br /&gt;
		system(&amp;quot;umount&amp;quot;,&amp;quot;-v&amp;quot;,&amp;quot;$dir&amp;quot;)==0  or  $bad=1;&lt;br /&gt;
	}&lt;br /&gt;
	exit 1 if $bad;&lt;br /&gt;
EOPERL&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# Get the UltraBay's /dev/foo block device node&lt;br /&gt;
ultrabay_dev_node() {&lt;br /&gt;
	UDEV_PATH=&amp;quot;`readlink -e &amp;quot;$ULTRABAY_SYSDIR/block:&amp;quot;*`&amp;quot; || return 1&lt;br /&gt;
	UDEV_NAME=&amp;quot;`udevinfo -q name -p $UDEV_PATH`&amp;quot; || return 1&lt;br /&gt;
	echo /dev/$UDEV_NAME&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if [ -d $ULTRABAY_SYSDIR ]; then&lt;br /&gt;
	sync&lt;br /&gt;
	# Unmount filesystems backed by this device&lt;br /&gt;
	unmount_rdev `cat $ULTRABAY_SYSDIR/block\:*/dev     \&lt;br /&gt;
	                  $ULTRABAY_SYSDIR/block\:*/*/dev`  \&lt;br /&gt;
	|| {&lt;br /&gt;
		echo 10 &amp;gt; /proc/acpi/ibm/beep;  # error tone&lt;br /&gt;
		exit 1;&lt;br /&gt;
	}&lt;br /&gt;
        sync&lt;br /&gt;
        # Nicely power off the device&lt;br /&gt;
	DEVNODE=`ultrabay_dev_node` &amp;amp;&amp;amp; hdparm -Y $DEVNODE&lt;br /&gt;
        # Let HAL+KDE notice the unmount and let the disk spin down&lt;br /&gt;
	sleep 0.5&lt;br /&gt;
	# Unregister this SCSI device:&lt;br /&gt;
	sync&lt;br /&gt;
	echo 1 &amp;gt; $ULTRABAY_SYSDIR/delete&lt;br /&gt;
fi&lt;br /&gt;
sync&lt;br /&gt;
# Turn off power to the UltraBay:&lt;br /&gt;
if [ -d /sys/devices/platform/bay.0 ]; then&lt;br /&gt;
	echo 1 &amp;gt; /sys/devices/platform/bay.0/eject&lt;br /&gt;
elif [ -e /proc/acpi/ibm/bay ]; then&lt;br /&gt;
	echo eject &amp;gt; /proc/acpi/ibm/bay&lt;br /&gt;
fi&lt;br /&gt;
# Tell the user we're OK&lt;br /&gt;
echo 12 &amp;gt; /proc/acpi/ibm/beep&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Use the modified version below if the above doesn't work for you (for kernels 2.5.25+ due to ULTRABAY_SYSDIR/block\:*/dev path change). It was tested on a Thinkpad X41 with Fedora 9 and kernel 2.6.25.11:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
ULTRABAY_SYSDIR='/sys/class/scsi_device/1:0:0:0/device'&lt;br /&gt;
shopt -s nullglob&lt;br /&gt;
&lt;br /&gt;
# Umount the filesystem(s) backed by the given major:minor device(s)&lt;br /&gt;
unmount_rdev() { perl - &amp;quot;$@&amp;quot; &amp;lt;&amp;lt;'EOPERL'  # let's do it in Perl&lt;br /&gt;
	for $major_minor (@ARGV) {&lt;br /&gt;
		$major_minor =~ m/^(\d+):(\d+)$/ or die;&lt;br /&gt;
		push(@tgt_rdevs, ($1&amp;lt;&amp;lt;8)|$2);&lt;br /&gt;
	}&lt;br /&gt;
        # Sort by reverse length of mount point, to unmount sub-directories first&lt;br /&gt;
        open MOUNTS,&amp;quot;&amp;lt;/proc/mounts&amp;quot; or die &amp;quot;$!&amp;quot;;&lt;br /&gt;
        @mounts=sort { length($b-&amp;gt;[1]) &amp;lt;=&amp;gt; length($a-&amp;gt;[1]) } map { [ split ] } &amp;lt;MOUNTS&amp;gt;;&lt;br /&gt;
        close MOUNTS;&lt;br /&gt;
        foreach $m (@mounts) {&lt;br /&gt;
                ($dev,$dir)=@$m;&lt;br /&gt;
		next unless -b $dev;  $rdev=(stat($dev))[6];&lt;br /&gt;
		next unless grep($_==$rdev, @tgt_rdevs);&lt;br /&gt;
		system(&amp;quot;umount&amp;quot;,&amp;quot;-v&amp;quot;,&amp;quot;$dir&amp;quot;)==0  or  $bad=1;&lt;br /&gt;
	}&lt;br /&gt;
	exit 1 if $bad;&lt;br /&gt;
EOPERL&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# Get the UltraBay's /dev/foo block device node&lt;br /&gt;
ultrabay_dev_node() {&lt;br /&gt;
	UDEV_PATH=&amp;quot;`readlink -e &amp;quot;$ULTRABAY_SYSDIR/block/&amp;quot;*`&amp;quot; || return 1&lt;br /&gt;
	UDEV_NAME=&amp;quot;`udevinfo -q name -p $UDEV_PATH`&amp;quot; || return 1&lt;br /&gt;
	echo /dev/$UDEV_NAME&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if [ -d $ULTRABAY_SYSDIR ]; then&lt;br /&gt;
	sync&lt;br /&gt;
	# Unmount filesystems backed by this device&lt;br /&gt;
	unmount_rdev `cat $ULTRABAY_SYSDIR/block/*/dev     \&lt;br /&gt;
	                  $ULTRABAY_SYSDIR/block/*/*/dev`  \&lt;br /&gt;
	|| {&lt;br /&gt;
		echo 10 &amp;gt; /proc/acpi/ibm/beep;  # error tone&lt;br /&gt;
		exit 1;&lt;br /&gt;
	}&lt;br /&gt;
        sync&lt;br /&gt;
        # Nicely power off the device&lt;br /&gt;
	DEVNODE=`ultrabay_dev_node` &amp;amp;&amp;amp; hdparm -Y $DEVNODE&lt;br /&gt;
        # Let HAL+KDE notice the unmount and let the disk spin down&lt;br /&gt;
	sleep 0.5&lt;br /&gt;
	# Unregister this SCSI device:&lt;br /&gt;
	sync&lt;br /&gt;
	echo 1 &amp;gt; $ULTRABAY_SYSDIR/delete&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# We really need a 3 sec pause here otherwise the system will freeze..&lt;br /&gt;
sleep 3&lt;br /&gt;
&lt;br /&gt;
# Turn off power to the UltraBay:&lt;br /&gt;
if [ -d /sys/devices/platform/bay.0 ]; then&lt;br /&gt;
	echo 1 &amp;gt; /sys/devices/platform/bay.0/eject&lt;br /&gt;
elif [ -e /proc/acpi/ibm/bay ]; then&lt;br /&gt;
	echo eject &amp;gt; /proc/acpi/ibm/bay&lt;br /&gt;
fi&lt;br /&gt;
# Tell the user we're OK&lt;br /&gt;
echo 12 &amp;gt; /proc/acpi/ibm/beep&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create {{path|/etc/acpi/events/ultrabay-insert}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
event=ibm/bay MSTR 00000001 00000000&lt;br /&gt;
action=/usr/local/sbin/ultrabay_insert&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create {{path|/etc/acpi/events/ultrabay-eject}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
event=ibm/bay MSTR 00000003 00000000&lt;br /&gt;
action=/usr/local/sbin/ultrabay_eject&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart &amp;lt;tt&amp;gt;acpid&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===using the generic bay driver and udev===&lt;br /&gt;
&lt;br /&gt;
Starting from kernel 2.6.23-rc3, it's possible to use the generic &amp;lt;tt&amp;gt;bay&amp;lt;/tt&amp;gt; driver in combination with udev to hotswap. Please check if CONFIG_ACPI_BAY is enabled (module or built-in) in your kernel configuration.&lt;br /&gt;
&lt;br /&gt;
Create {{path|/etc/udev/rules.d/ibm-ultrabay.rules}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ENV{BAY_EVENT}==&amp;quot;3&amp;quot;, KERNEL==&amp;quot;bay.0&amp;quot;, ACTION==&amp;quot;change&amp;quot;, SUBSYSTEM==&amp;quot;platform&amp;quot;, RUN+=&amp;quot;/usr/local/sbin/ultrabay_eject&amp;quot;&lt;br /&gt;
ENV{BAY_EVENT}==&amp;quot;1&amp;quot;, KERNEL==&amp;quot;bay.0&amp;quot;, ACTION==&amp;quot;change&amp;quot;, SUBSYSTEM==&amp;quot;platform&amp;quot;, RUN+=&amp;quot;/usr/local/sbin/ultrabay_insert&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===using libata-acpi and udev===&lt;br /&gt;
&lt;br /&gt;
Starting from kernel 2.6.26-rc5, it's possible to use &amp;lt;tt&amp;gt;libata-acpi&amp;lt;/tt&amp;gt; in combination with udev to hotswap. Please check if CONFIG_ATA_ACPI is enabled in your kernel configuration.&lt;br /&gt;
&lt;br /&gt;
For 2.6.25, you need two patches which can be easily backported ([http://article.gmane.org/gmane.linux.acpi.devel/31159],[http://article.gmane.org/gmane.linux.acpi.devel/31369]).&lt;br /&gt;
&lt;br /&gt;
Create {{path|/etc/udev/rules.d/ibm-ultrabay.rules}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ENV{BAY_EVENT}==&amp;quot;3&amp;quot;, ACTION==&amp;quot;change&amp;quot;, SUBSYSTEM==&amp;quot;scsi&amp;quot;, RUN+=&amp;quot;/usr/local/sbin/ultrabay_eject&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Model-specific notes===&lt;br /&gt;
See the table above for a list of ata_piix supported laptops and the bus ID to use.&lt;br /&gt;
&lt;br /&gt;
===HAL support===&lt;br /&gt;
&lt;br /&gt;
{{NOTE| Starting from HAL 0.5.11, you need to replace &amp;quot;storage.physical_device&amp;quot; with &amp;quot;info.parent&amp;quot;.}}&lt;br /&gt;
&lt;br /&gt;
Many programs, KDE included, rely on [[HAL]] to get notifications and information about device hotplugging. You need to tell HAL that devices connected the UltraBay port are hotpluggable. To do so, create the file {{path|/etc/hal/fdi/information/10-ultrabay.fdi}} as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt; &amp;lt;!-- -*- SGML -*- --&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;deviceinfo version=&amp;quot;0.2&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;device&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- UltraBay Devices --&amp;gt;&lt;br /&gt;
    &amp;lt;match key=&amp;quot;storage.bus&amp;quot; string=&amp;quot;scsi&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;match key=&amp;quot;storage.physical_device&amp;quot; string=&amp;quot;/org/freedesktop/Hal/devices/pci_8086_2653_scsi_host_0_scsi_device_lun0&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;merge key=&amp;quot;storage.hotpluggable&amp;quot; type=&amp;quot;bool&amp;quot;&amp;gt;true&amp;lt;/merge&amp;gt;&lt;br /&gt;
      &amp;lt;/match&amp;gt;&lt;br /&gt;
    &amp;lt;/match&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/device&amp;gt;&lt;br /&gt;
&amp;lt;/deviceinfo&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The string &amp;quot;8086_2653&amp;quot; may need to be changed to match your ThinkPad model; see below.&lt;br /&gt;
&lt;br /&gt;
====Details====&lt;br /&gt;
&lt;br /&gt;
By default, HAL doesn't know that UltraBay devices are hotpluggable:&lt;br /&gt;
&lt;br /&gt;
 # PHYSDEV=/org/freedesktop/Hal/devices/pci_8086_2653_scsi_host_0_scsi_device_lun0&lt;br /&gt;
 # UDI=`hal-find-by-property --key storage.physical_device --string $PHYSDEV` || echo Failed&lt;br /&gt;
 # hal-get-property --udi $UDI --key block.device&lt;br /&gt;
 /dev/sdb&lt;br /&gt;
 # hal-get-property --udi $UDI --key storage.hotpluggable&lt;br /&gt;
 false&lt;br /&gt;
&lt;br /&gt;
After creating {{path|/etc/hal/fdi/information/10-ultrabay.fdi}} as above and re-plugging the device, it will get marked correctly:&lt;br /&gt;
&lt;br /&gt;
 # PHYSDEV=/org/freedesktop/Hal/devices/pci_8086_2653_scsi_host_0_scsi_device_lun0&lt;br /&gt;
 # UDI=`hal-find-by-property --key storage.physical_device --string $PHYSDEV` || echo Failed&lt;br /&gt;
 # hal-get-property --udi $UDI --key block.device&lt;br /&gt;
 /dev/sdb&lt;br /&gt;
 # hal-get-property --udi $UDI --key storage.hotpluggable&lt;br /&gt;
 true&lt;br /&gt;
&lt;br /&gt;
The string &amp;quot;8086_2653&amp;quot; gives the PCI ID of the [[Intel 82801FBM]] southbridge. If your model has a different southbridge, or the UltraBay is attached to a different port, then you can find the appropriate &amp;lt;tt&amp;gt;storage.physical_device&amp;lt;/tt&amp;gt; value by finding out the block device of the currently running UltraBay device (&amp;lt;tt&amp;gt;/dev/sdb&amp;lt;/tt&amp;gt; in the following example) and then running:&lt;br /&gt;
&lt;br /&gt;
 # DEVICE=/dev/sdb&lt;br /&gt;
 # UDI=`hal-find-by-property --key block.device --string $DEVICE` || echo Failed&lt;br /&gt;
 # hal-get-property --udi $UDI --key storage.physical_device&lt;br /&gt;
 /org/freedesktop/Hal/devices/pci_8086_2653_scsi_host_0_scsi_device_lun0&lt;br /&gt;
&lt;br /&gt;
If you have a different &amp;lt;tt&amp;gt;storage.physical_device&amp;lt;/tt&amp;gt; value, please report your findings.&lt;br /&gt;
&lt;br /&gt;
{| border=1&lt;br /&gt;
|+ Known South Bridge PCI IDs&lt;br /&gt;
! ID !! ThinkPad model !! South Bridge chip&lt;br /&gt;
|-&lt;br /&gt;
| 8086_248a || 2366-83U (T30) || Intel 82801CAM IDE U100 (rev 2)&lt;br /&gt;
|-&lt;br /&gt;
| 8086_2653 || 2525FAG (X41), ? (T43) || Intel 82801FBM (ICH6-M)&lt;br /&gt;
|-&lt;br /&gt;
| 8086_24ca || 237358U (T40), 2373KXU (T42p) || Intel 82801DBM (ICH4-M)&lt;br /&gt;
|-&lt;br /&gt;
| 8086_27c4 || X60           || Intel 82801GBM (ICH7 Family)&lt;br /&gt;
|-&lt;br /&gt;
| 8086_27df || Z61p, T60, T60p || Intel 82801GBM/GHM (ICH7 Family)&lt;br /&gt;
|-&lt;br /&gt;
| 8086_2850 || T61p || Intel 82801H (ICH8 Family)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==When using the &amp;lt;tt&amp;gt;ide-disk&amp;lt;/tt&amp;gt; driver==&lt;br /&gt;
The following applies if you use the &amp;lt;tt&amp;gt;ide-disk&amp;lt;/tt&amp;gt; driver for the UltraBay device.&amp;lt;BR&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Note that essentially, you shouldn't be using this driver, and use ata_piix instead unless you're running an older kernel where ata_piix won't work for you&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hotswapping is supposed to be supported as well, using either hdparm/[http://packages.debian.org/unstable/admin/hotswap Debian hotswap] or [[lt_hotswap]] to (un)register IDE devices. The latter is the recommended method with kernels from 2.6, since it will leave DMA working. However, for recent models (R52, T43, X41, Z60 and later) no method is known to work while maintaining DMA support; see [[Problems with SATA and Linux]].&lt;br /&gt;
&lt;br /&gt;
Only IDE devices (HDD's, optical drives, zip drives) require special treatment - batteries, floppies and other devices can just be pulled from the bay, provided they are not mounted or in use at the time. However, you should still power them down first using the [[ibm-acpi]] eject function.&lt;br /&gt;
&lt;br /&gt;
The [[ibm-acpi]] kernel module has an eject function ({{cmdroot|echo eject &amp;gt; /proc/acpi/ibm/bay}}). This only manages the ACPI calls to power down the device and the bay. It does not actually unregister the device from the IDE driver. {{cmdroot|cat /proc/acpi/ibm/bay}} shows &amp;quot;unoccupied&amp;quot; unless an IDE device is present, but the eject function still works and should still be used.&lt;br /&gt;
&lt;br /&gt;
To unregister the device, you can either use the [http://packages.debian.org/unstable/admin/hotswap Debian hotswap] package, or [[lt_hotswap]]. Note that lt_hotswap doesn't seem to even build on recent (at 2.6.22 or newer, although it probably broke before 2.6.22) and on newer kernels, you should not build/load the old IDE PIIX (CONFIG_BLK_DEV_PIIX) and use the natively hotswapping ata_piix (CONFIG_ATA_PIIX) as explained on the top of this page.&lt;br /&gt;
&lt;br /&gt;
[http://packages.debian.org/unstable/admin/hotswap Debian hotswap] also allows the drive to be swapped as a normal user by default, which is useful. You should use &amp;lt;tt&amp;gt;hotswap&amp;lt;/tt&amp;gt; to unregister the device and then {{cmdroot|echo eject &amp;gt; /proc/acpi/ibm/bay}}. However, if you use this method on a 2.6 kernel, you will lose DMA support for the reinserted drive. This is due to kernel issues. This method was reported to work on a ThinkPad {{T23}} (kernels 2.6.8.1, 2.6.14.2 and 2.6.15-arch) and {{T42}} (kernel 2.6.13), but fails on a ThinkPad {{T43}} (kernel 2.6.14.3).&lt;br /&gt;
&lt;br /&gt;
[[lt_hotswap]] is now the recommended method to un- and reregister the IDE device. It installs as a kernel module and has support for automatically unregistering (if loaded with the auto_eject=1 option) the device when the eject event is generated by [[ibm-acpi]]. It will leave DMA support intact. It has supported to work on a ThinkPad {{T22}} and {{T40}} and should work with many other models (but not recent models which require the &amp;lt;tt&amp;gt;ata_piix&amp;lt;/tt&amp;gt; driver for disk DMA support). With the [[lt_hotswap]] kernel module loaded, run: {{cmdroot|modprobe -r ide_cd &amp;amp;&amp;amp; modprobe -r cdrom &amp;amp;&amp;amp; echo &amp;quot;MSTR eject&amp;quot; &amp;gt; /proc/acpi/lths}}&lt;br /&gt;
&lt;br /&gt;
===HAL support===&lt;br /&gt;
&lt;br /&gt;
HAL support also can also be configured To do so, create the file {{path|/etc/hal/fdi/information/10-ultrabay.fdi}} as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt; &amp;lt;!-- -*- SGML -*- --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;deviceinfo version=&amp;quot;0.2&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;device&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- UltraBay Devices --&amp;gt;&lt;br /&gt;
    &amp;lt;match key=&amp;quot;storage.bus&amp;quot; string=&amp;quot;ide&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;match key=&amp;quot;storage.physical_device&amp;quot; string=&amp;quot;/org/freedesktop/Hal/devices/pci_8086_24ca_ide_1_0&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;merge key=&amp;quot;storage.hotpluggable&amp;quot; type=&amp;quot;bool&amp;quot;&amp;gt;true&amp;lt;/merge&amp;gt;&lt;br /&gt;
      &amp;lt;/match&amp;gt;&lt;br /&gt;
    &amp;lt;/match&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;/device&amp;gt;&lt;br /&gt;
&amp;lt;/deviceinfo&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For more details see HAL section for ata driver.&lt;br /&gt;
&lt;br /&gt;
==Other comments==&lt;br /&gt;
&lt;br /&gt;
If you are hot-swapping a hard disk on a disk tray, make sure the disk does not have a password set, otherwise it will not be recognized on reinsertion.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripts]]&lt;br /&gt;
[[Category:HOWTOs]]&lt;/div&gt;</summary>
		<author><name>Zin</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Talk:How_to_hotswap_Ultrabay_devices&amp;diff=38690</id>
		<title>Talk:How to hotswap Ultrabay devices</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Talk:How_to_hotswap_Ultrabay_devices&amp;diff=38690"/>
		<updated>2008-08-26T10:38:29Z</updated>

		<summary type="html">&lt;p&gt;Zin: /* Ultrabay Hotswap on ThinkPad X41 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I recently tried using the libata-tj patch tarball for 2.6.16.16, applying this against the newly released 2.6.16.18 kernel (released today.)  Patch applied cleanly.  Upon boot, I immediately get a multitude of &amp;quot;weird&amp;quot; errors -- strange lockups, programs segmentation fault (running &amp;quot;top&amp;quot; resulted in a seg fault), and ultimately a hard lockup.&lt;br /&gt;
&lt;br /&gt;
I booted back to my vanilla 2.6.16.16, ran fsck (appeared to just replay a few transactions, no major damage), and am back to normal.  However, it successfully scared me off - unfortunately can't risk too much downtime (or worse, subtle fs corruption) right now on my main system.  Anybody have experiences with this on a T43p using piix driver?&lt;br /&gt;
&lt;br /&gt;
--[[User:gsmenden|gsmenden]] 00:00, 23 May 2006 (EST)&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The 2.6.16.16 patch works fine on my T43. There's a git tree (mentioned on the patch's webpage) which is closer to 2.6.18, but AFAIK no simple unified patch was prepred.&lt;br /&gt;
&lt;br /&gt;
--[[User:Thinker|Thinker]] 08:37, 23 May 2006 (CEST)&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Cool.  If I get brave I'll try it again on the 43p against 2.6.16.16 proper and report back.&lt;br /&gt;
&lt;br /&gt;
--[[User:gsmenden|gsmenden]] 15:29, 23 May 2006 (EST)&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Works fine here on 2.6.16.&lt;br /&gt;
I got only one crash with Suspend to Ram, which I'm unable to reproduce yet.&lt;br /&gt;
I renamed the acpi event files because at least my acpid doesn't read files that ends with .conf&lt;br /&gt;
&lt;br /&gt;
--[[User:Defiant|Defiant]] 21:09, 28 May 2006 (CEST)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Update - patched against 2.6.16.19, works fine.  It appears my previous problems were due to a disk error unrelated to the patch.  Excellent!&lt;br /&gt;
&lt;br /&gt;
--[[User:gsmenden|gsmenden]] 00:57, 31 May 2006 (EST)&lt;br /&gt;
&lt;br /&gt;
Anybody have time to make a patch of the libata(-tj) .git tree against the recently released 2.6.17?  I hope to make one in the future if not...&lt;br /&gt;
&lt;br /&gt;
--[[User:gsmenden|gsmenden]] 22:08, 19 Jun 2006 (EST)&lt;br /&gt;
&lt;br /&gt;
== one nit about ultrabay_close script / patch against 2.6.17 available ==&lt;br /&gt;
&lt;br /&gt;
Howdy,&lt;br /&gt;
&lt;br /&gt;
In ultrabay_close, there is 'sleep 3' for disk spinup, which isn't necessary.  libata itself waits for disk spinup and if something breaks (e.g. first reset fails w/ timeout or something), it's libata's fault.  Please remove that line and see if anything breaks.&lt;br /&gt;
&lt;br /&gt;
Also, I've uploaded patch against 2.6.17/2.6.17.1 today.&lt;br /&gt;
&lt;br /&gt;
http://home-tj.org/files/libata-tj-stable/libata-tj-2.6.17-20060625-1.tar.bz2&lt;br /&gt;
&lt;br /&gt;
Hmmm... My post looks different from others.  This wasn't intentional.  Just don't know how to add normal discussion entry.  Sorry.&lt;br /&gt;
&lt;br /&gt;
--tj&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Right, it works fine without &amp;quot;sleep 3&amp;quot; using the new patches. Sleep removed.&lt;br /&gt;
&lt;br /&gt;
--[[User:Thinker|Thinker]] 12:35, 1 July 2006 (CEST)&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Is it correct, that the ata_piix driver in kernel 2.6.18 RC4 now supports hot swapping like described in the howto and announced here http://lwn.net/Articles/183734/?&lt;br /&gt;
&lt;br /&gt;
--[[User:cob|cob]] 15:53, 23 August 2006&lt;br /&gt;
&lt;br /&gt;
== T42 freezing up when trying to hot swap ultrabay. ==&lt;br /&gt;
&lt;br /&gt;
Hi, &lt;br /&gt;
&lt;br /&gt;
Please bear with me.  I am totally new at this and I am making my best effort to understand and learn. &lt;br /&gt;
&lt;br /&gt;
My problem is that when typing &amp;quot;# echo eject &amp;gt; /proc/acpi/ibm/bay&amp;quot; to eject my ultrabay and put another in, I see the power going off in the ultrabay LED, but then my PC freezes completely. &lt;br /&gt;
&lt;br /&gt;
I am running Fedora 6 Test 3, kernel 2.6.17-1.2647 and my notebook is a ThinkPad T42.&lt;br /&gt;
&lt;br /&gt;
Please help!  I have to constantly be changing my bay to use information in other hard drives, and I have to shutdown the system completely to not have any problems. &lt;br /&gt;
&lt;br /&gt;
Thanks,&lt;br /&gt;
&lt;br /&gt;
--Barny  09/21/2006@7:46PM EST&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Have the same problem on a T40p running SuSE 10.1. Also lt_hotplug module is of no help. Keep me informed in case you have a solution!&lt;br /&gt;
Thanks,&lt;br /&gt;
--[[User:Ays|Ays]] 19:49, 5 October 2006 (CEST)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
I have no problems with kernel 2.6.17-1.2187_1.fc5.cu from suspend2 on my T42p running Fedora Core 5. I have compiled the lt_hotswap module and every thing works fine. Since kernel 2.6.18-1.2200.fc5 my system freeez on loading the modul or on calling &amp;quot;echo eject &amp;gt; /proc/acpi/ibm/bay&amp;quot;.&lt;br /&gt;
Any ideas what has changed in the kernel?&lt;br /&gt;
&lt;br /&gt;
--CoolMischa 2006-11-06@13:24 CET&lt;br /&gt;
&lt;br /&gt;
== Second disk not seen correctly on reinsert (T43p) [solved] ==&lt;br /&gt;
&lt;br /&gt;
(update: see below for solution)&lt;br /&gt;
&lt;br /&gt;
I have followed the instructions on my T43p running Gentoo using 2.6.18. I have a second hard disk in the UltraBay, using ata_piix, so it is seen as /dev/sdb (as described in [[Problems with SATA and Linux#No_DMA_on_system_hard_disk|Problems with SATA and Linux]]). The eject works fine. When I reinsert it and issue the rescan command, Only the main /dev/sdb device reappears, but not the ones corresponding to the partitions (/dev/sdb1, etc.), so I cannot mount them, and fdisk /dev/sdb says that it cannot open the device.&lt;br /&gt;
&lt;br /&gt;
In dmesg, I see a bunch of errors like these, repeated multiple times:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sd 1:0:0:0: SCSI error: return code = 0x08000002&lt;br /&gt;
sdb: Current: sense key=0xb&lt;br /&gt;
    ASC=0x0 ASCQ=0x0&lt;br /&gt;
end_request: I/O error, dev sdb, sector 0&lt;br /&gt;
ata2: EH complete&lt;br /&gt;
ata2.00: speed down requested but no transfer mode left&lt;br /&gt;
ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0&lt;br /&gt;
ata2.00: tag 0 cmd 0x20 Emask 0x1 stat 0x51 err 0x4 (device error)&lt;br /&gt;
ata2: EH complete&lt;br /&gt;
ata2.00: speed down requested but no transfer mode left&lt;br /&gt;
ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0&lt;br /&gt;
ata2.00: tag 0 cmd 0x20 Emask 0x1 stat 0x51 err 0x4 (device error)&lt;br /&gt;
ata2: EH complete&lt;br /&gt;
ata2.00: speed down requested but no transfer mode left&lt;br /&gt;
ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0&lt;br /&gt;
ata2.00: tag 0 cmd 0x20 Emask 0x1 stat 0x51 err 0x4 (device error)&lt;br /&gt;
ata2: EH complete&lt;br /&gt;
ata2.00: speed down requested but no transfer mode left&lt;br /&gt;
ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0&lt;br /&gt;
ata2.00: tag 0 cmd 0x20 Emask 0x1 stat 0x51 err 0x4 (device error)&lt;br /&gt;
ata2: EH complete&lt;br /&gt;
ata2.00: speed down requested but no transfer mode left&lt;br /&gt;
ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0&lt;br /&gt;
ata2.00: tag 0 cmd 0x20 Emask 0x1 stat 0x51 err 0x4 (device error)&lt;br /&gt;
ata2: EH complete&lt;br /&gt;
ata2.00: speed down requested but no transfer mode left&lt;br /&gt;
ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0&lt;br /&gt;
ata2.00: tag 0 cmd 0x20 Emask 0x1 stat 0x51 err 0x4 (device error)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And at the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sdb: Current: sense key=0xb&lt;br /&gt;
    ASC=0x0 ASCQ=0x0&lt;br /&gt;
end_request: I/O error, dev sdb, sector 0&lt;br /&gt;
ata2: EH complete&lt;br /&gt;
SCSI device sdb: 117210240 512-byte hdwr sectors (60012 MB)&lt;br /&gt;
sdb: Write Protect is off&lt;br /&gt;
sdb: Mode Sense: 00 3a 00 00&lt;br /&gt;
SCSI device sdb: drive cache: write back&lt;br /&gt;
SCSI device sdb: 117210240 512-byte hdwr sectors (60012 MB)&lt;br /&gt;
sdb: Write Protect is off&lt;br /&gt;
sdb: Mode Sense: 00 3a 00 00&lt;br /&gt;
SCSI device sdb: drive cache: write back&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The situation is not cured by a reboot (I still see only /dev/sdb), I have to power cycle to get the devices back.&lt;br /&gt;
&lt;br /&gt;
Thanks for any ideas.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
(2006-10-10) As a followup to my note above, I have noticed that the DVD-RW drive works perfectly after hot-swapping it - it's just the second hard disk that doesg not get recognized properly. I can &amp;quot;scsiping&amp;quot; the /dev/sdb device and it seems to respond OK, I have tried restarting udevd without success, and I'm at a loss as to what to try next.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
It turned out to be an obvious problem - I had a disk password set on my second disk, so on reinsert it could not be accessed. I turned off the disk password, and now it works perfectly.&lt;br /&gt;
&lt;br /&gt;
== ultrabay_open: Problem when using /proc/mounts ==&lt;br /&gt;
&lt;br /&gt;
I am just working on a perl-free version of the ultrabay_open script. When the script reads the currently mounted devices from /proc/mounts, it may not find all the relevant device files. A file system mounted with a relative device path given to the mount command doesn't show up with the absolute device path in /proc/mounts. Example:&lt;br /&gt;
&lt;br /&gt;
{{cmdroot|cd /dev/; mount sdb5 /mnt}} results in the following line in {{path|/proc/mounts}}:&lt;br /&gt;
&lt;br /&gt;
{{cmdresult|sdb5 /mnt ext3 rw 0 0}}&lt;br /&gt;
&lt;br /&gt;
{{path|/etc/mtab}} contains the needed information:&lt;br /&gt;
&lt;br /&gt;
{{cmdresult|/dev/sdb5 /mnt ext3 rw 0 0}}&lt;br /&gt;
&lt;br /&gt;
However, /proc/mounts is the more reliable source of information IMHO. The absolute device path is needed to find out its major and minor numbers.&lt;br /&gt;
&lt;br /&gt;
Any suggestions?&lt;br /&gt;
&lt;br /&gt;
--[[User:Acolomb|MinioN]] 01:03, 28 December 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
== Can/t  mount CD after reinsert on X41 ==&lt;br /&gt;
&lt;br /&gt;
I did all the steps described on this page, and the drive ejects fine, and then when I&lt;br /&gt;
reinsert it the /dev/scd0 entry reappears, but when I insert a CD Gnome won't mount it&lt;br /&gt;
automatically, and when I try manually I ger this message:&lt;br /&gt;
&lt;br /&gt;
    mount: wrong fs type, bad option, bad superblock on /dev/scd0,&lt;br /&gt;
    missing codepage or other error&lt;br /&gt;
&lt;br /&gt;
and dmesg says:&lt;br /&gt;
&lt;br /&gt;
    isofs_fill_super: bread failed, dev=sr0, iso_blknum=16, block=16&lt;br /&gt;
&lt;br /&gt;
I have to reboot to use the drive again.&lt;br /&gt;
&lt;br /&gt;
P.S.  I discovered the following in dmesg when I boot:&lt;br /&gt;
&lt;br /&gt;
    ata2.01: qc timeout (cmd 0xa1)&lt;br /&gt;
    ata2.01: failed to IDENTIFY (I/O error, err_mask=0x4)&lt;br /&gt;
    ata2: failed to recover some devices, retrying in 5 secs&lt;br /&gt;
    ata2.01: qc timeout (cmd 0xa1)&lt;br /&gt;
    ata2.01: failed to IDENTIFY (I/O error, err_mask=0x4)&lt;br /&gt;
    ata2: failed to recover some devices, retrying in 5 secs&lt;br /&gt;
    ata2.01: qc timeout (cmd 0xa1)&lt;br /&gt;
    ata2.01: failed to IDENTIFY (I/O error, err_mask=0x4)&lt;br /&gt;
    ata2: failed to recover some devices, retrying in 5 secs&lt;br /&gt;
    ata2.00: configured for UDMA/33&lt;br /&gt;
&lt;br /&gt;
Is that relevant?&lt;br /&gt;
&lt;br /&gt;
== hdparm -Y /dev/&amp;lt;devnode&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
is the hdparm part in the ultrabay_eject script really necessary?&lt;br /&gt;
&lt;br /&gt;
It does not work with my dvdram drive (R60):&lt;br /&gt;
&lt;br /&gt;
 hdparm -Y /dev/sdb&lt;br /&gt;
 &lt;br /&gt;
 /dev/sdb:&lt;br /&gt;
 issuing sleep command&lt;br /&gt;
 HDIO_DRIVE_CMD(sleep) failed: Input/output error&lt;br /&gt;
&lt;br /&gt;
thanks,&lt;br /&gt;
&lt;br /&gt;
== problem with umount_rdev ==&lt;br /&gt;
&lt;br /&gt;
I tried out the ultrabay_eject script and get this error (debian lenny with kernel 2.6.22.3)&lt;br /&gt;
&lt;br /&gt;
 cat: /sys/class/scsi_device/1:0:0:0/device/block:*/*/dev: No such file or directory&lt;br /&gt;
&lt;br /&gt;
What is wrong? Why I need the output of $ULTRABAY_SYSDIR/block\:*/*/dev in &lt;br /&gt;
&lt;br /&gt;
 unmount_rdev `cat $ULTRABAY_SYSDIR/block\:*/dev    /&lt;br /&gt;
 $ULTRABAY_SYSDIR/block\:*/*/dev`  \&lt;br /&gt;
&lt;br /&gt;
?&lt;br /&gt;
== hotswap with kernel 2.6.24 and archlinux ==&lt;br /&gt;
Since I change to kernle 2.6.24 on my archlinux hotswap isn't working anymore. When I try to swap between harddisk and DVD-drive the system frezzes and the only way to get it back to work ist turn the power of.&lt;br /&gt;
Has anyone else the same problem? And is there a way to fix it?&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
Yes I stumbled today(6.Apr.) over this annoying regression: On my T42p 2373-KYG with Kubuntu 8.04 Hardy Heron&lt;br /&gt;
Kubuntu is freezing totally after only removing the DVD drive from the UltraBay slot.&lt;br /&gt;
This happens on a T42p upgraded from Gutsy and on another T42p with a clean and fresh Hardy install. (/Lophiomys)&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
I think I may know what is causing the issue:  Disable ACPI support on libata, or switch to thinkpad-acpi [deprecated] bay support.  The bay module is not able to load on 2.6.24+ if libata is compiled with ACPI support.&lt;br /&gt;
&lt;br /&gt;
--[[User:Hmh|hmh]] 06:30, 7 May 2008 (CEST)&lt;br /&gt;
&lt;br /&gt;
Could you help out with instructions for an interim workaround, how to disable ACPI support on libdata or switch to thinkpad-acpi? Thanks.&lt;br /&gt;
&lt;br /&gt;
--[[User:Lophiomys|lophiomys]] 19:13, 7 May 2008 (CEST)&lt;br /&gt;
&lt;br /&gt;
== Ultrabay Hotswap on ThinkPad X41 ==&lt;br /&gt;
&lt;br /&gt;
After several hours of debugging and trial+error, I managed to get hotswaping ultrabay devices working in Fedora 9. The kernels I tested were 2.6.25.11 and 2.6.25.14 from fedora updates. The bay.ko driver was not present in the kernel so I just used the ibm-acpi driver (works fine). You need to create only 4 files (/usr/sbin/ultrabay_insert; /usr/sbin/ultrabay_eject; /etc/acpi/events/ultrabay-insert and /etc/acpi/events/ultrabay-eject) available from the linnk here: [http://www.thinkwiki.org/wiki/How_to_hotswap_UltraBay_devices]. NOTE!! - DO NOT use the ultrabay_eject script from the link as it won't work. I have a modified version that works below. I have tested swapping dvdrw with an hdd and it works just fine. Make sure you restart acpid after adding the scripts. Hope this works for others..&lt;br /&gt;
&lt;br /&gt;
/usr/sbin/ultrabay_eject:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
ULTRABAY_SYSDIR='/sys/class/scsi_device/1:0:0:0/device'&lt;br /&gt;
shopt -s nullglob&lt;br /&gt;
&lt;br /&gt;
# Umount the filesystem(s) backed by the given major:minor device(s)&lt;br /&gt;
unmount_rdev() { perl - &amp;quot;$@&amp;quot; &amp;lt;&amp;lt;'EOPERL'  # let's do it in Perl&lt;br /&gt;
	for $major_minor (@ARGV) {&lt;br /&gt;
		$major_minor =~ m/^(\d+):(\d+)$/ or die;&lt;br /&gt;
		push(@tgt_rdevs, ($1&amp;lt;&amp;lt;8)|$2);&lt;br /&gt;
	}&lt;br /&gt;
        # Sort by reverse length of mount point, to unmount sub-directories first&lt;br /&gt;
        open MOUNTS,&amp;quot;&amp;lt;/proc/mounts&amp;quot; or die &amp;quot;$!&amp;quot;;&lt;br /&gt;
        @mounts=sort { length($b-&amp;gt;[1]) &amp;lt;=&amp;gt; length($a-&amp;gt;[1]) } map { [ split ] } &amp;lt;MOUNTS&amp;gt;;&lt;br /&gt;
        close MOUNTS;&lt;br /&gt;
        foreach $m (@mounts) {&lt;br /&gt;
                ($dev,$dir)=@$m;&lt;br /&gt;
		next unless -b $dev;  $rdev=(stat($dev))[6];&lt;br /&gt;
		next unless grep($_==$rdev, @tgt_rdevs);&lt;br /&gt;
		system(&amp;quot;umount&amp;quot;,&amp;quot;-v&amp;quot;,&amp;quot;$dir&amp;quot;)==0  or  $bad=1;&lt;br /&gt;
	}&lt;br /&gt;
	exit 1 if $bad;&lt;br /&gt;
EOPERL&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# Get the UltraBay's /dev/foo block device node&lt;br /&gt;
ultrabay_dev_node() {&lt;br /&gt;
	UDEV_PATH=&amp;quot;`readlink -e &amp;quot;$ULTRABAY_SYSDIR/block/&amp;quot;*`&amp;quot; || return 1&lt;br /&gt;
	UDEV_NAME=&amp;quot;`udevinfo -q name -p $UDEV_PATH`&amp;quot; || return 1&lt;br /&gt;
	echo /dev/$UDEV_NAME&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if [ -d $ULTRABAY_SYSDIR ]; then&lt;br /&gt;
	sync&lt;br /&gt;
	# Unmount filesystems backed by this device&lt;br /&gt;
	unmount_rdev `cat $ULTRABAY_SYSDIR/block/*/dev     \&lt;br /&gt;
	                  $ULTRABAY_SYSDIR/block/*/*/dev`  \&lt;br /&gt;
	|| {&lt;br /&gt;
		echo 10 &amp;gt; /proc/acpi/ibm/beep;  # error tone&lt;br /&gt;
		exit 1;&lt;br /&gt;
	}&lt;br /&gt;
        sync&lt;br /&gt;
        # Nicely power off the device&lt;br /&gt;
	DEVNODE=`ultrabay_dev_node` &amp;amp;&amp;amp; hdparm -Y $DEVNODE&lt;br /&gt;
        # Let HAL+KDE notice the unmount and let the disk spin down&lt;br /&gt;
	sleep 0.5&lt;br /&gt;
	# Unregister this SCSI device:&lt;br /&gt;
	sync&lt;br /&gt;
	echo 1 &amp;gt; $ULTRABAY_SYSDIR/delete&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# We really need a 3 sec pause here otherwise the system will freeze..&lt;br /&gt;
sleep 3&lt;br /&gt;
&lt;br /&gt;
# Turn off power to the UltraBay:&lt;br /&gt;
if [ -d /sys/devices/platform/bay.0 ]; then&lt;br /&gt;
	echo 1 &amp;gt; /sys/devices/platform/bay.0/eject&lt;br /&gt;
elif [ -e /proc/acpi/ibm/bay ]; then&lt;br /&gt;
	echo eject &amp;gt; /proc/acpi/ibm/bay&lt;br /&gt;
fi&lt;br /&gt;
# Tell the user we're OK&lt;br /&gt;
echo 12 &amp;gt; /proc/acpi/ibm/beep&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
zin 26 August 2008&lt;/div&gt;</summary>
		<author><name>Zin</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=Talk:How_to_hotswap_Ultrabay_devices&amp;diff=38689</id>
		<title>Talk:How to hotswap Ultrabay devices</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=Talk:How_to_hotswap_Ultrabay_devices&amp;diff=38689"/>
		<updated>2008-08-26T10:37:28Z</updated>

		<summary type="html">&lt;p&gt;Zin: New section: Ultrabay Hotswap on ThinkPad X41&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I recently tried using the libata-tj patch tarball for 2.6.16.16, applying this against the newly released 2.6.16.18 kernel (released today.)  Patch applied cleanly.  Upon boot, I immediately get a multitude of &amp;quot;weird&amp;quot; errors -- strange lockups, programs segmentation fault (running &amp;quot;top&amp;quot; resulted in a seg fault), and ultimately a hard lockup.&lt;br /&gt;
&lt;br /&gt;
I booted back to my vanilla 2.6.16.16, ran fsck (appeared to just replay a few transactions, no major damage), and am back to normal.  However, it successfully scared me off - unfortunately can't risk too much downtime (or worse, subtle fs corruption) right now on my main system.  Anybody have experiences with this on a T43p using piix driver?&lt;br /&gt;
&lt;br /&gt;
--[[User:gsmenden|gsmenden]] 00:00, 23 May 2006 (EST)&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The 2.6.16.16 patch works fine on my T43. There's a git tree (mentioned on the patch's webpage) which is closer to 2.6.18, but AFAIK no simple unified patch was prepred.&lt;br /&gt;
&lt;br /&gt;
--[[User:Thinker|Thinker]] 08:37, 23 May 2006 (CEST)&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Cool.  If I get brave I'll try it again on the 43p against 2.6.16.16 proper and report back.&lt;br /&gt;
&lt;br /&gt;
--[[User:gsmenden|gsmenden]] 15:29, 23 May 2006 (EST)&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Works fine here on 2.6.16.&lt;br /&gt;
I got only one crash with Suspend to Ram, which I'm unable to reproduce yet.&lt;br /&gt;
I renamed the acpi event files because at least my acpid doesn't read files that ends with .conf&lt;br /&gt;
&lt;br /&gt;
--[[User:Defiant|Defiant]] 21:09, 28 May 2006 (CEST)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Update - patched against 2.6.16.19, works fine.  It appears my previous problems were due to a disk error unrelated to the patch.  Excellent!&lt;br /&gt;
&lt;br /&gt;
--[[User:gsmenden|gsmenden]] 00:57, 31 May 2006 (EST)&lt;br /&gt;
&lt;br /&gt;
Anybody have time to make a patch of the libata(-tj) .git tree against the recently released 2.6.17?  I hope to make one in the future if not...&lt;br /&gt;
&lt;br /&gt;
--[[User:gsmenden|gsmenden]] 22:08, 19 Jun 2006 (EST)&lt;br /&gt;
&lt;br /&gt;
== one nit about ultrabay_close script / patch against 2.6.17 available ==&lt;br /&gt;
&lt;br /&gt;
Howdy,&lt;br /&gt;
&lt;br /&gt;
In ultrabay_close, there is 'sleep 3' for disk spinup, which isn't necessary.  libata itself waits for disk spinup and if something breaks (e.g. first reset fails w/ timeout or something), it's libata's fault.  Please remove that line and see if anything breaks.&lt;br /&gt;
&lt;br /&gt;
Also, I've uploaded patch against 2.6.17/2.6.17.1 today.&lt;br /&gt;
&lt;br /&gt;
http://home-tj.org/files/libata-tj-stable/libata-tj-2.6.17-20060625-1.tar.bz2&lt;br /&gt;
&lt;br /&gt;
Hmmm... My post looks different from others.  This wasn't intentional.  Just don't know how to add normal discussion entry.  Sorry.&lt;br /&gt;
&lt;br /&gt;
--tj&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Right, it works fine without &amp;quot;sleep 3&amp;quot; using the new patches. Sleep removed.&lt;br /&gt;
&lt;br /&gt;
--[[User:Thinker|Thinker]] 12:35, 1 July 2006 (CEST)&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Is it correct, that the ata_piix driver in kernel 2.6.18 RC4 now supports hot swapping like described in the howto and announced here http://lwn.net/Articles/183734/?&lt;br /&gt;
&lt;br /&gt;
--[[User:cob|cob]] 15:53, 23 August 2006&lt;br /&gt;
&lt;br /&gt;
== T42 freezing up when trying to hot swap ultrabay. ==&lt;br /&gt;
&lt;br /&gt;
Hi, &lt;br /&gt;
&lt;br /&gt;
Please bear with me.  I am totally new at this and I am making my best effort to understand and learn. &lt;br /&gt;
&lt;br /&gt;
My problem is that when typing &amp;quot;# echo eject &amp;gt; /proc/acpi/ibm/bay&amp;quot; to eject my ultrabay and put another in, I see the power going off in the ultrabay LED, but then my PC freezes completely. &lt;br /&gt;
&lt;br /&gt;
I am running Fedora 6 Test 3, kernel 2.6.17-1.2647 and my notebook is a ThinkPad T42.&lt;br /&gt;
&lt;br /&gt;
Please help!  I have to constantly be changing my bay to use information in other hard drives, and I have to shutdown the system completely to not have any problems. &lt;br /&gt;
&lt;br /&gt;
Thanks,&lt;br /&gt;
&lt;br /&gt;
--Barny  09/21/2006@7:46PM EST&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Have the same problem on a T40p running SuSE 10.1. Also lt_hotplug module is of no help. Keep me informed in case you have a solution!&lt;br /&gt;
Thanks,&lt;br /&gt;
--[[User:Ays|Ays]] 19:49, 5 October 2006 (CEST)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
I have no problems with kernel 2.6.17-1.2187_1.fc5.cu from suspend2 on my T42p running Fedora Core 5. I have compiled the lt_hotswap module and every thing works fine. Since kernel 2.6.18-1.2200.fc5 my system freeez on loading the modul or on calling &amp;quot;echo eject &amp;gt; /proc/acpi/ibm/bay&amp;quot;.&lt;br /&gt;
Any ideas what has changed in the kernel?&lt;br /&gt;
&lt;br /&gt;
--CoolMischa 2006-11-06@13:24 CET&lt;br /&gt;
&lt;br /&gt;
== Second disk not seen correctly on reinsert (T43p) [solved] ==&lt;br /&gt;
&lt;br /&gt;
(update: see below for solution)&lt;br /&gt;
&lt;br /&gt;
I have followed the instructions on my T43p running Gentoo using 2.6.18. I have a second hard disk in the UltraBay, using ata_piix, so it is seen as /dev/sdb (as described in [[Problems with SATA and Linux#No_DMA_on_system_hard_disk|Problems with SATA and Linux]]). The eject works fine. When I reinsert it and issue the rescan command, Only the main /dev/sdb device reappears, but not the ones corresponding to the partitions (/dev/sdb1, etc.), so I cannot mount them, and fdisk /dev/sdb says that it cannot open the device.&lt;br /&gt;
&lt;br /&gt;
In dmesg, I see a bunch of errors like these, repeated multiple times:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sd 1:0:0:0: SCSI error: return code = 0x08000002&lt;br /&gt;
sdb: Current: sense key=0xb&lt;br /&gt;
    ASC=0x0 ASCQ=0x0&lt;br /&gt;
end_request: I/O error, dev sdb, sector 0&lt;br /&gt;
ata2: EH complete&lt;br /&gt;
ata2.00: speed down requested but no transfer mode left&lt;br /&gt;
ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0&lt;br /&gt;
ata2.00: tag 0 cmd 0x20 Emask 0x1 stat 0x51 err 0x4 (device error)&lt;br /&gt;
ata2: EH complete&lt;br /&gt;
ata2.00: speed down requested but no transfer mode left&lt;br /&gt;
ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0&lt;br /&gt;
ata2.00: tag 0 cmd 0x20 Emask 0x1 stat 0x51 err 0x4 (device error)&lt;br /&gt;
ata2: EH complete&lt;br /&gt;
ata2.00: speed down requested but no transfer mode left&lt;br /&gt;
ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0&lt;br /&gt;
ata2.00: tag 0 cmd 0x20 Emask 0x1 stat 0x51 err 0x4 (device error)&lt;br /&gt;
ata2: EH complete&lt;br /&gt;
ata2.00: speed down requested but no transfer mode left&lt;br /&gt;
ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0&lt;br /&gt;
ata2.00: tag 0 cmd 0x20 Emask 0x1 stat 0x51 err 0x4 (device error)&lt;br /&gt;
ata2: EH complete&lt;br /&gt;
ata2.00: speed down requested but no transfer mode left&lt;br /&gt;
ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0&lt;br /&gt;
ata2.00: tag 0 cmd 0x20 Emask 0x1 stat 0x51 err 0x4 (device error)&lt;br /&gt;
ata2: EH complete&lt;br /&gt;
ata2.00: speed down requested but no transfer mode left&lt;br /&gt;
ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0&lt;br /&gt;
ata2.00: tag 0 cmd 0x20 Emask 0x1 stat 0x51 err 0x4 (device error)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And at the end:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sdb: Current: sense key=0xb&lt;br /&gt;
    ASC=0x0 ASCQ=0x0&lt;br /&gt;
end_request: I/O error, dev sdb, sector 0&lt;br /&gt;
ata2: EH complete&lt;br /&gt;
SCSI device sdb: 117210240 512-byte hdwr sectors (60012 MB)&lt;br /&gt;
sdb: Write Protect is off&lt;br /&gt;
sdb: Mode Sense: 00 3a 00 00&lt;br /&gt;
SCSI device sdb: drive cache: write back&lt;br /&gt;
SCSI device sdb: 117210240 512-byte hdwr sectors (60012 MB)&lt;br /&gt;
sdb: Write Protect is off&lt;br /&gt;
sdb: Mode Sense: 00 3a 00 00&lt;br /&gt;
SCSI device sdb: drive cache: write back&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The situation is not cured by a reboot (I still see only /dev/sdb), I have to power cycle to get the devices back.&lt;br /&gt;
&lt;br /&gt;
Thanks for any ideas.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
(2006-10-10) As a followup to my note above, I have noticed that the DVD-RW drive works perfectly after hot-swapping it - it's just the second hard disk that doesg not get recognized properly. I can &amp;quot;scsiping&amp;quot; the /dev/sdb device and it seems to respond OK, I have tried restarting udevd without success, and I'm at a loss as to what to try next.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
It turned out to be an obvious problem - I had a disk password set on my second disk, so on reinsert it could not be accessed. I turned off the disk password, and now it works perfectly.&lt;br /&gt;
&lt;br /&gt;
== ultrabay_open: Problem when using /proc/mounts ==&lt;br /&gt;
&lt;br /&gt;
I am just working on a perl-free version of the ultrabay_open script. When the script reads the currently mounted devices from /proc/mounts, it may not find all the relevant device files. A file system mounted with a relative device path given to the mount command doesn't show up with the absolute device path in /proc/mounts. Example:&lt;br /&gt;
&lt;br /&gt;
{{cmdroot|cd /dev/; mount sdb5 /mnt}} results in the following line in {{path|/proc/mounts}}:&lt;br /&gt;
&lt;br /&gt;
{{cmdresult|sdb5 /mnt ext3 rw 0 0}}&lt;br /&gt;
&lt;br /&gt;
{{path|/etc/mtab}} contains the needed information:&lt;br /&gt;
&lt;br /&gt;
{{cmdresult|/dev/sdb5 /mnt ext3 rw 0 0}}&lt;br /&gt;
&lt;br /&gt;
However, /proc/mounts is the more reliable source of information IMHO. The absolute device path is needed to find out its major and minor numbers.&lt;br /&gt;
&lt;br /&gt;
Any suggestions?&lt;br /&gt;
&lt;br /&gt;
--[[User:Acolomb|MinioN]] 01:03, 28 December 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
== Can/t  mount CD after reinsert on X41 ==&lt;br /&gt;
&lt;br /&gt;
I did all the steps described on this page, and the drive ejects fine, and then when I&lt;br /&gt;
reinsert it the /dev/scd0 entry reappears, but when I insert a CD Gnome won't mount it&lt;br /&gt;
automatically, and when I try manually I ger this message:&lt;br /&gt;
&lt;br /&gt;
    mount: wrong fs type, bad option, bad superblock on /dev/scd0,&lt;br /&gt;
    missing codepage or other error&lt;br /&gt;
&lt;br /&gt;
and dmesg says:&lt;br /&gt;
&lt;br /&gt;
    isofs_fill_super: bread failed, dev=sr0, iso_blknum=16, block=16&lt;br /&gt;
&lt;br /&gt;
I have to reboot to use the drive again.&lt;br /&gt;
&lt;br /&gt;
P.S.  I discovered the following in dmesg when I boot:&lt;br /&gt;
&lt;br /&gt;
    ata2.01: qc timeout (cmd 0xa1)&lt;br /&gt;
    ata2.01: failed to IDENTIFY (I/O error, err_mask=0x4)&lt;br /&gt;
    ata2: failed to recover some devices, retrying in 5 secs&lt;br /&gt;
    ata2.01: qc timeout (cmd 0xa1)&lt;br /&gt;
    ata2.01: failed to IDENTIFY (I/O error, err_mask=0x4)&lt;br /&gt;
    ata2: failed to recover some devices, retrying in 5 secs&lt;br /&gt;
    ata2.01: qc timeout (cmd 0xa1)&lt;br /&gt;
    ata2.01: failed to IDENTIFY (I/O error, err_mask=0x4)&lt;br /&gt;
    ata2: failed to recover some devices, retrying in 5 secs&lt;br /&gt;
    ata2.00: configured for UDMA/33&lt;br /&gt;
&lt;br /&gt;
Is that relevant?&lt;br /&gt;
&lt;br /&gt;
== hdparm -Y /dev/&amp;lt;devnode&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
is the hdparm part in the ultrabay_eject script really necessary?&lt;br /&gt;
&lt;br /&gt;
It does not work with my dvdram drive (R60):&lt;br /&gt;
&lt;br /&gt;
 hdparm -Y /dev/sdb&lt;br /&gt;
 &lt;br /&gt;
 /dev/sdb:&lt;br /&gt;
 issuing sleep command&lt;br /&gt;
 HDIO_DRIVE_CMD(sleep) failed: Input/output error&lt;br /&gt;
&lt;br /&gt;
thanks,&lt;br /&gt;
&lt;br /&gt;
== problem with umount_rdev ==&lt;br /&gt;
&lt;br /&gt;
I tried out the ultrabay_eject script and get this error (debian lenny with kernel 2.6.22.3)&lt;br /&gt;
&lt;br /&gt;
 cat: /sys/class/scsi_device/1:0:0:0/device/block:*/*/dev: No such file or directory&lt;br /&gt;
&lt;br /&gt;
What is wrong? Why I need the output of $ULTRABAY_SYSDIR/block\:*/*/dev in &lt;br /&gt;
&lt;br /&gt;
 unmount_rdev `cat $ULTRABAY_SYSDIR/block\:*/dev    /&lt;br /&gt;
 $ULTRABAY_SYSDIR/block\:*/*/dev`  \&lt;br /&gt;
&lt;br /&gt;
?&lt;br /&gt;
== hotswap with kernel 2.6.24 and archlinux ==&lt;br /&gt;
Since I change to kernle 2.6.24 on my archlinux hotswap isn't working anymore. When I try to swap between harddisk and DVD-drive the system frezzes and the only way to get it back to work ist turn the power of.&lt;br /&gt;
Has anyone else the same problem? And is there a way to fix it?&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
Yes I stumbled today(6.Apr.) over this annoying regression: On my T42p 2373-KYG with Kubuntu 8.04 Hardy Heron&lt;br /&gt;
Kubuntu is freezing totally after only removing the DVD drive from the UltraBay slot.&lt;br /&gt;
This happens on a T42p upgraded from Gutsy and on another T42p with a clean and fresh Hardy install. (/Lophiomys)&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
I think I may know what is causing the issue:  Disable ACPI support on libata, or switch to thinkpad-acpi [deprecated] bay support.  The bay module is not able to load on 2.6.24+ if libata is compiled with ACPI support.&lt;br /&gt;
&lt;br /&gt;
--[[User:Hmh|hmh]] 06:30, 7 May 2008 (CEST)&lt;br /&gt;
&lt;br /&gt;
Could you help out with instructions for an interim workaround, how to disable ACPI support on libdata or switch to thinkpad-acpi? Thanks.&lt;br /&gt;
&lt;br /&gt;
--[[User:Lophiomys|lophiomys]] 19:13, 7 May 2008 (CEST)&lt;br /&gt;
&lt;br /&gt;
== Ultrabay Hotswap on ThinkPad X41 ==&lt;br /&gt;
&lt;br /&gt;
After several hours of debugging and trial+error, I managed to get hotswaping ultrabay devices working in Fedora 9. The kernels I tested were 2.6.25.11 and 2.6.25.14 from fedora updates. The bay.ko driver was not present in the kernel so I just used the ibm-acpi driver (works fine). You need to create only 4 files (/usr/sbin/ultrabay_insert; /usr/sbin/ultrabay_eject; /etc/acpi/events/ultrabay-insert and /etc/acpi/events/ultrabay-eject) available from the linnk here: [http://www.thinkwiki.org/wiki/How_to_hotswap_UltraBay_devices]. NOTE!! - DO NOT use the ultrabay_eject script from the link as it won't work. I have a modified version that works below. I have tested swapping dvdrw with an hdd and it works just fine. Make sure you restart acpid after adding the scripts. Hope this works for others..&lt;br /&gt;
&lt;br /&gt;
/usr/sbin/ultrabay_eject:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
ULTRABAY_SYSDIR='/sys/class/scsi_device/1:0:0:0/device'&lt;br /&gt;
shopt -s nullglob&lt;br /&gt;
&lt;br /&gt;
# Umount the filesystem(s) backed by the given major:minor device(s)&lt;br /&gt;
unmount_rdev() { perl - &amp;quot;$@&amp;quot; &amp;lt;&amp;lt;'EOPERL'  # let's do it in Perl&lt;br /&gt;
	for $major_minor (@ARGV) {&lt;br /&gt;
		$major_minor =~ m/^(\d+):(\d+)$/ or die;&lt;br /&gt;
		push(@tgt_rdevs, ($1&amp;lt;&amp;lt;8)|$2);&lt;br /&gt;
	}&lt;br /&gt;
        # Sort by reverse length of mount point, to unmount sub-directories first&lt;br /&gt;
        open MOUNTS,&amp;quot;&amp;lt;/proc/mounts&amp;quot; or die &amp;quot;$!&amp;quot;;&lt;br /&gt;
        @mounts=sort { length($b-&amp;gt;[1]) &amp;lt;=&amp;gt; length($a-&amp;gt;[1]) } map { [ split ] } &amp;lt;MOUNTS&amp;gt;;&lt;br /&gt;
        close MOUNTS;&lt;br /&gt;
        foreach $m (@mounts) {&lt;br /&gt;
                ($dev,$dir)=@$m;&lt;br /&gt;
		next unless -b $dev;  $rdev=(stat($dev))[6];&lt;br /&gt;
		next unless grep($_==$rdev, @tgt_rdevs);&lt;br /&gt;
		system(&amp;quot;umount&amp;quot;,&amp;quot;-v&amp;quot;,&amp;quot;$dir&amp;quot;)==0  or  $bad=1;&lt;br /&gt;
	}&lt;br /&gt;
	exit 1 if $bad;&lt;br /&gt;
EOPERL&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# Get the UltraBay's /dev/foo block device node&lt;br /&gt;
ultrabay_dev_node() {&lt;br /&gt;
	UDEV_PATH=&amp;quot;`readlink -e &amp;quot;$ULTRABAY_SYSDIR/block/&amp;quot;*`&amp;quot; || return 1&lt;br /&gt;
	UDEV_NAME=&amp;quot;`udevinfo -q name -p $UDEV_PATH`&amp;quot; || return 1&lt;br /&gt;
	echo /dev/$UDEV_NAME&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if [ -d $ULTRABAY_SYSDIR ]; then&lt;br /&gt;
	sync&lt;br /&gt;
	# Unmount filesystems backed by this device&lt;br /&gt;
	unmount_rdev `cat $ULTRABAY_SYSDIR/block/*/dev     \&lt;br /&gt;
	                  $ULTRABAY_SYSDIR/block/*/*/dev`  \&lt;br /&gt;
	|| {&lt;br /&gt;
		echo 10 &amp;gt; /proc/acpi/ibm/beep;  # error tone&lt;br /&gt;
		exit 1;&lt;br /&gt;
	}&lt;br /&gt;
        sync&lt;br /&gt;
        # Nicely power off the device&lt;br /&gt;
	DEVNODE=`ultrabay_dev_node` &amp;amp;&amp;amp; hdparm -Y $DEVNODE&lt;br /&gt;
        # Let HAL+KDE notice the unmount and let the disk spin down&lt;br /&gt;
	sleep 0.5&lt;br /&gt;
	# Unregister this SCSI device:&lt;br /&gt;
	sync&lt;br /&gt;
	echo 1 &amp;gt; $ULTRABAY_SYSDIR/delete&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# We really need a 3 sec pause here otherwise the system will freeze..&lt;br /&gt;
sleep 3&lt;br /&gt;
&lt;br /&gt;
# Turn off power to the UltraBay:&lt;br /&gt;
if [ -d /sys/devices/platform/bay.0 ]; then&lt;br /&gt;
	echo 1 &amp;gt; /sys/devices/platform/bay.0/eject&lt;br /&gt;
elif [ -e /proc/acpi/ibm/bay ]; then&lt;br /&gt;
	echo eject &amp;gt; /proc/acpi/ibm/bay&lt;br /&gt;
fi&lt;br /&gt;
# Tell the user we're OK&lt;br /&gt;
echo 12 &amp;gt; /proc/acpi/ibm/beep&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Zin</name></author>
		
	</entry>
</feed>