How to hotswap Ultrabay devices

From ThinkWiki
Revision as of 23:36, 10 May 2006 by Thinker (Talk | contribs) (When using the <tt>ata_piix</tt> driver: - clarified)
Jump to: navigation, search

The following discusses hotswap (AKA "hotplug") of devices in the UltraBay.

When using the ide-disk driver

The following applies if you use the ide-disk driver for the UltraBay device.

Hotswapping is supposed to be supported as well, using either hdparm/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.

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.

The ibm-acpi kernel module has an eject function (# echo eject > /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. # cat /proc/acpi/ibm/bay shows "unoccupied" unless an IDE device is present, but the eject function still works and should still be used.

To unregister the device, you can either use the Debian hotswap package, or lt_hotswap.

Debian hotswap also allows the drive to be swapped as a normal user by default, which is useful. You should use hotswap to unregister the device and then # echo eject > /proc/acpi/ibm/bay. However, if you use this method on a 2.6 kernel, you will loose 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_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 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 ata_piix driver for disk DMA support).

When using the ata_piix driver

The following applies when using the ata_piix driver, which is necessary for many recent ThinkPad models that use an Intel ICH6M controller. See also Problems with SATA and Linux.

You can safely shut down the drive by issuing the following:

# echo 1 > /sys/class/scsi_device/1\:0\:0\:0/device/delete
# echo eject >  /proc/acpi/ibm/bay

The drive can now be ejected.

Mainline kernels cannot yet reliably recognize newly (re-)inserted UltraBay drives without a reboot. Once support is added, it can be invoked by issuing the following after inserting an UltraBay drive:

# echo 0 0 0 >  /sys/class/scsi_host/host1/scan

See this thread for an experimental kernel that adds hotplug support. It was confirmed to work on a ThinkPad T43.

The above commands can be issued automatically when the UltraBay eject level is released or inserted, by hooking them to the corresponding ACPI events ("ibm/bay MSTR 00000003 00000000" for lever eject and "ibm/bay MSTR 00000001 00000000" for lever insertion).