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!"
IIRC, unless your hardware can support hot-swapping, you might be SOL on the whole thing. Most hardware setups dont allow one the ability to unplug one disk and plug in another. Usually it's the BIOS at startup that demands to know where all the drives are before launching an OS. SCSI is what you're looking for if you want hot-swapness.
This is being discussed on the LKML right now!
Excessive forking causes un-wanted children.
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.
BeOS could do this automatically
Your BIOS might freak, especially on an older computer.
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
A customer called me about their Cirix server behaving strangely. I connected to it and after about a minute I determined that one of the drives had failed. The drives were mirrored by software under NT.
:^)
I instructed the person on the phone to pull out the drive and replace it with one from the shelf. Unfortunately, they pulled out the wrong, working, drive. This made the Citrix server become miserably slow with the 63 users that were using it. I informed the person on the phone that they had pulled the wrong drive. I told them to pull the other, failed drive out. They did this leaving the server with no, as in zero, drives in it. They then plugged the original good drive back in to the server but, placed it into the first slot, instead of the second slot that it originally had been. The server's performance returned to normal after about 45 seconds and there were still 63 users on it.
A new drive was then plugged into the second slot. I remirrored the working drive to the new drive and all was well. I was impressed that the server was able to function, albeit very slowly, with no drives in it at all. Any way, the point is that I was able to plug dives in and out and re-arrange them on the fly without any serious difficulty.
Oh, wait. That was a Compaq server with SCSI drives. Hope this helps.
"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
ide raid cards with hot swap functionality.
i thought most motherboards didn't support ide hot swap and it didn't matter what os you were using. swapping ide's can easily induce a hard stop on the hardware.
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.
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..
Use promise FastTrack and/or Ultra 100 card and superswap enclosure.
In fact the FastTrak 100 PRO comes w/ 2 enclosures works great.
I just did this too, but I was lucky enough not to fry anything, the power supply just shut off. Scared the crap outta me though, and my buddy at work thought it was pretty funny.
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.
is to install Windows 2000 or Windows XP and forget that no-intuitive spaghetti-code Linux bullshit.
/fuck-this _crap" ever again.
Then you can plug in or unplug any damn thing you want to, get work done, and never have to type "umount -bullshit
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.
from man hdparm :
-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.
IMHO, that would be a command one should use before doing a hot-swap of a harddrive.
Probably also this one:
-U Un-register an IDE interface. Dangerous. The companion for the -R option. Intended for use with hardware made specifically for hot-swapping (very rare!). Use with knowledge and extreme caution as this can easily hang or damage your system. The hdparm source distribution includes a 'contrib' directory with some user-donated scripts for hot-swapping on the UltraBay of a ThinkPad 600E. Use at your own risk.
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