Swapping IDE Drives in Linux without Rebooting?
Hasufin writes "I've got quite a few of those removable IDE drive bays in my computers. I'd like to be able to swap these drives without the need of rebooting linux. I've searched quite a bit via google and other resources but haven't found a good how-to. Any pointers? I've seen few mentions to hdparm -U & -R and a script or two, but haven't had any luck using it w/ my promise udma/66 & udma/100 offboard pci controllers... :\ Any help appreciated!"
You do get hotswap IDE now, but obviously the OS needs to support it. As most modern OSs don't actually use the BIOS for disk accesses (past the kernel booting), the BIOS is a non-issue.
This is being discussed on the LKML right now!
Excessive forking causes un-wanted children.
'course, I could be wrong, but I'd imagine some of the comments in the linux kernel code might provide some hints as to how it finds the information.
I remember somewhere reading about unloading the ide module and reloading it. You might not be able to unload it unless you stop all the ide drives being used.
If disk gometry is the only reason that the HD can not be swapped, then assuming that you have a budget, but 2 or more identical drives to swap. That way the disk is physicaly the same and all you end up changing is the contents.
Just be sure to unmount the drive first and disconnect the power cable. Then disconnect the IDE ribbon. Reverse the process with the new drive, then mount it.
If you've already got a couple of drives without mission critical data on them, you could try this. I doubt if it would damage the drives as long as you're careful. I'm not sure how Linux gets the drive's parameters, but I would guess that it can get them during the mounting, perhaps with a few command-line options if needed.
Sig (appended to the end of comments you post, 120 chars)
I've had great luck with hot-swappable drives! The trick is to take your IDE devices and run over them with a large vehicle. Now make an emergency requisition of SCSI or FibreChannel devices, and all will work exactly as you were hoping.
...is to buy a SCSI RAID card and a hot swap SCSI enclosure.
If you try this kind of shit with IDE, prepare for Deep Hurting.
Sometimes (and I know this is going to really upset a lot of slashdroids) you need to spend money to get certain features.
- A.P.
"Remember when the U.S. had a drug problem, and then we declared a War On Drugs, and now you can't buy drugs anymore?"
Hot swap laptop IDE drives from the BeOS Tip Server
"read a recent man page for hdparm and you will see kernel allows remove/add ide interface. scripts with correct parameter usage are in contrib directory of hdparm source. IDE maintainer has code to electrically turn off (tristate) ide channels on most PC ide chips, but is waiting to demonstrate at an industry conference before releasing to public." -- Jeremy Jackson
Most IDE drive trays are NOT rated for hot swap, and neither are the controllers on the motherboard. To do ide hotswap the best way is an ide raid controller from either 3ware, Promise or Adaptec along with certified disk trays.
There are 4 boxes to use in the defense of liberty: soap, ballot, jury, ammo. Use in that order. Starting now.
I haven't tried any of these enclosures, but there are some out there that claim IDE-Hot-Swap.
See this Rackmountpro example.
-sid
If you are talking about swaping out a drive that is running your OS I'd say forget it. I don't think most IDE are made for that.
Only 'flamers' flame!
Obviously, if someone's actually done it that trumps my blathering, but I wouldn't expect this to work -even with SCSI- unless the drives were geometrically identical because I don't know of a controller (IDE OR SCSI) that can re-init the drive inteface to refresh its own internal "picture" of the drive geometry on the fly.
The best bet would be to get a USB/IDE external tray/case (because USB was designed for these kinds of hot-swap shennanigans). THAT would work. Serial ATA might also be able to do this when it hits the streets.
I can't even see how you'd do it with single drive array in a RAID controller/cabinet with hot-swap trays because even though the array config data is written on the drives themselves (so you can swap controllers), pulling one drive and plugging in another, the controller would still expect to see the same array, which it wouldn't. You'd have to get the controller to refresh itself with the new array data.
"Lawyers are for sucks."
- Doug McKenzie
I have one disk on the onboard (mobo) ide controller for my root drive.
Then a promise ide controller (fasttrack 100, not used for raid in hardware just as 2 extra ide buses).
Compile IDE support for the onboard controller in the kernel. Compile the promise support as a module.
To hotswap, umount the disks on that controller, and rmmod the module.
Make any changes
insmod the module, remount the drives.
Upon module load, it rescans the controller to get the new drive geometry data, so if disks change it all works.
Only problems are if you have a module that controls multiple IDE cards.
If your hotswapping a drive in and out without changing the drive, you dont even need to do that. just unmount and its good to go.
THe module thing is only needed if the drives gemetry changes (IE replaced with a different drive that isnt an identical modal)
OS support for hotswap IDE is shaky, cuz people that need that feature can generally spend the money on the right hardware to do it.
--Jon
You can get IDE to ieee1394 (firewire) adapters that plug into the back of your hard drive. Now, you just get a nice firewire controller and you have a hot swapable device.
I think that the last time I checked, these controllers were around $40-50... And firewire's very cool.
Does any such command exist for standard EIDE controllers/drives? Or even in any standard Unix (preferably FreeBSD) SCSI drivers for non-FCAL drives?
Without a spin-down and disconnect, hot-swap seems like it must pose some risk, however slight.
I do not deploy Linux. Ever.
...as long as the drive was physically identical there would be no problem.
Unless you're hot swapping just for the fun of it, you're only going to hot swap a bad drive that's part of an array that provides redundancy. Or at least one that might be bad, and will maybe end up going back into an array and thus being rebuilt to be part of that array.
Unless you're doing something bizarre, like using drives like removable storage, if you're pulling a drive, you're past the point of caring about the data.
Doesn't the BIOS need to know what each device is? I mean what about the BIOS Harddrive detection, it passes the data down to the os doesn't it?
A while back, I had to disconnect my floppy drive to do some work inside the case. Now the system is bak up and running, but guess what? I have the ribbon cable connected to the floppy drive but the power cable is not.
Is it safe to just plug it in or do I need to power-down the system? Powering-down is a last-resort seeing the system is a server.
I used to swap a 1.2 and a 400meg hdd out at school all the time. Just had to disable the ide controler and re-enable it after pluggint the other hdd in. Win2k had no problem going back and forth between drives. It went ape if you just swaped without reinitializing the controlers, tho. Everything showed up as garbage files. I believe had I told win2k they were dynamic disks I could have skipped the reinitializing, oh well.
yes, it's possible to shutdown an ide hard drive, although I have never tried it... see the hdparm man page:
-Y Force an IDE drive to immediately enter the lowest power consumption sleep mode, causing it to shut down completely. A hard or soft reset is required before the drive can be accessed again (the Linux IDE driver will automatically handle issuing a reset if/when needed). The current power mode status can be checked using the -C flag.
..you get the power supply cable in the right way. Yes, I know they have moulded plugs, but don't have it turned upside down and try and plug it in.
:)
I once tried to plug a drive in, out of laziness, without turning the system off. While fumbling around trying to get the cables in, I had the power the wrong way up, tried to put it in, and it got close enough to spark - blowing the drive. I got a sweet smell of burning chips (the silicon, not potatoe variety), and some nice 'bubbles' on one chip in particular.
Needless to say, I wasn't very happy, and always turn the PC off first now..
At the very beginning of the kernel boot process, the bios is completely deactivated. It in only used for the 'soft reboot' reature from then on.
I'm pretty sure it does this. What probably(I don't read kernelese :) happens is it goes thru all hardware ide drivers and has them probe. If they find a controller, they register with the master IDE driver. Else, they go dormant. Then the master controller scans for master/slave and queries for drive capabilities on each IDE controller, and registers the appropriate device major/minor and devfs entries. Then the partition thingie registers the appropriate partition devices. PCI is only one of many IDE drivers.
That would get the cache out of sync with the disc. You'd have to sync first, then find a way to empty the cache and not reread the hdd, then get it to reread the partition table.
Can't you use hdparm to tell the disk to power off? If you can then doing so should write all the data to the disk. It would also be required to unmount the partition (/mnt/hdd?) prior to removeing the drive so it should sync the data at that point.
If you use an external 1394/Firewire/iLink or USB hard disk, it's just an ATA disk inside. Both 1394 and USB support hot-plugging, and linux support (at least for generic devices like ATA disks) is fairly mature. As for performance, 1394 is supposedly 400 Mb (bits) per second and USB 2.0 is 480 Mb/s. You need to buy a USB 2.0 PCI card for your PC, but they aren't too much. USB 2.0 controllers are also called "EHCI". USB 2.0 devices work with USB 1.1 controllers at the standard 12 Mb/s. Search the web for "USB ATA enclosure" or "Firewire ATA enclosure" and you should find something. For portable disks, you're more likely to find USB ports on a PC, and I suspect 1394 devices are going to seem really overpriced compared to USB 2.0. But YMMV.
http://www.linux-usb.org
(you're on your own for 1394)
I know you spent money on those removable ATA caddies, but if all you want is a hot-swap ATA disk, there are other ways of getting there that are designed to do what you're after.
Democracy. Whiskey. Sexy. Pick any two.
hdparm? What's that?
I have a loud hd and a quiet one. I use the loud one just for occasional backups and stuff. When I want it, I just plug in the power and mount it... when I'm done, I unmount and kill the power. The ide cable just stays connected.
I've never had problems with power or data loss.
Spoon not. Fork, or fork not. There is no spoon.
aside from all the hardware issues involved, Familiar Linux, a distro for handheld computers like the iPaq, already does this. If you take out a compact flash card (IDE Device) it recognizes it, and unmounts it, and if you put one in, it mounts it and everything. I don't know how it works, exactly... just that it does. Check out http://familiar.handhelds.org/
samrolken