Slashdot Mirror


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!"

77 comments

  1. power? by Anonymous Coward · · Score: 0

    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.

    1. Re:power? by larien · · Score: 4, Informative

      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.

    2. Re:power? by Anonymous Coward · · Score: 0

      ok, but doesnt the OS need to contact the bios in order to get the disk information (like it's geometry)?

    3. Re:power? by larien · · Score: 3, Informative
      I'm not particularly au fait with this, but I'd imagine that the kernel finds the hd controller on the PCI bus and 'walks' the IDE bus looking for the information and probes the drive for info.

      '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.

    4. Re:power? by dfreed · · Score: 2, Insightful

      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.

    5. Re:power? by Anonymous Coward · · Score: 0

      It shouldn't need to. I've successfully hot-swapped different makes/models of IDE hard drives on a Windows machine without problems so I didn't see why Linux should care what the BIOS is claiming.

    6. Re:power? by Anonymous Coward · · Score: 0

      On the kernel list it was brought up that Linux doesn't yet support rescanning the drives.

    7. Re:power? by 42forty-two42 · · Score: 1

      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.

    8. Re:power? by 42forty-two42 · · Score: 1

      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.

    9. Re:power? by dfreed · · Score: 1

      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.

    10. Re:power? by 42forty-two42 · · Score: 1

      hdparm? What's that?

  2. Check LKML by gantzm · · Score: 2, Informative

    This is being discussed on the LKML right now!

    --


    Excessive forking causes un-wanted children.
    1. Re:Check LKML by Anonymous Coward · · Score: 4, Informative

      Here is the start of the thread, and here is the complete listing of the thread (scroll down to "IDE and hot-swap disk caddies").

  3. Hmmm... by xiox · · Score: 1

    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.

  4. BeOS by capoccia · · Score: 0, Troll

    BeOS could do this automatically

    1. Re:BeOS by Anonymous Coward · · Score: 0

      No it couldn't, you're talking out of your ass. Sorry, you just aren't going to work around limitations of the architecture, no matter how much you fancy your dead OS.

  5. Might not work by qurob · · Score: 0, Offtopic


    Your BIOS might freak, especially on an older computer.

    1. Re:Might not work by randal_hicks · · Score: 1

      ...as long as the drive was physically identical there would be no problem.

    2. Re:Might not work by 42forty-two42 · · Score: 1

      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.

  6. Try this... by PoiBoy · · Score: 5, Informative
    I've never swapped an IDE hard drive, but I have hot-swapped IDE CD-ROM's out of shear laziness.

    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)
    1. Re:Try this... by Anonymous Coward · · Score: 2, Informative

      Backwards. Pull the data cable THEN the power cable. As per one of Andre's posts, some drives will suck power down the data cable, ruining controller and host, if you pull the molex out first.

    2. Re:Try this... by RabidMonkey · · Score: 1

      yes .. but if you pull the cable while the drive is still spinning/powered you could get power surges and/or data loss.

      seems like a big risk to take...

      --
      We emerge from our mother's womb an unformatted diskette; our culture formats us. - Douglas Coupland
    3. Re:Try this... by Anonymous Coward · · Score: 0

      Then sync your caches, and power down the drive.

      And yes, not hot-swapping at all is the true answer.

    4. Re:Try this... by omega9 · · Score: 2

      And yes, not hot-swapping at all is the true answer.

      No kidding. Read this thread and tell and tell me how confident it would make anyone trying to hotswap IDE.

      --
      I'm against picketing, but I don't know how to show it.
    5. Re:Try this... by inburito · · Score: 2

      Actually promise's controllers are protected against this. So if you have your drive attached to an additional ide-controller card, more than likely the data lines are buffered.

      This is a sure way to fry an onboard ide-controller, however.

    6. Re:Try this... by 42forty-two42 · · Score: 1

      What about hotswpping firewire/usb? That could solve his "problem".

    7. Re:Try this... by omega9 · · Score: 2

      You can nix USB off the bat, as transfer rates are far to slow. Firewire I may not trust enough as most of that subsystem is still in development.

      It's all about tradeoffs.

      --
      I'm against picketing, but I don't know how to show it.
    8. Re:Try this... by 42forty-two42 · · Score: 1

      USB 2.0 goes up to 480 Mbits/sec.

      That fast enough for you?

    9. Re:Try this... by omega9 · · Score: 2

      Yes, that's fast, but that is a sustained transfer rate. What you have to pay attention to, though, is access times. How fast can it perform random read/wite I/O in small bursts?

      Granted, it is vastly improved over USB 1.0, USB has caught up with IEEE1394, and there are IEEE1394 HDD's. But I still don't think they're worth holding anything other then "dumb data", things like video, mp3, etc... .

      *BUT*, if being hot-swappable is worth a drop in access times, then I agree that this would be a good fix.

      --
      I'm against picketing, but I don't know how to show it.
    10. Re:Try this... by Anonymous Coward · · Score: 0

      "Yes, that's fast, but that is a sustained transfer rate. What you have to pay attention to, though, is access times. How fast can it perform random read/wite I/O in small bursts?"

      Unless you're talking to initial latency on the transfers, then access times would be dependent on the media, not the transfer method.

  7. hot-swapping by mosch · · Score: 5, Funny

    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.

  8. The correct procedure... by Wakko+Warner · · Score: 5, Informative

    ...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?"
    1. Re:The correct procedure... by Anonymous Coward · · Score: 1, Informative

      But often you can spend less by being smarter.

      3ware has some excellent cards and hotswap enclosures. And a RAID5 with 3ware is more reliably, because a single cable problem can only take out one drive, instead of the whole chain.

    2. Re:The correct procedure... by Anonymous Coward · · Score: 0
      Did you read the documentation that came with your end-of-lifed 3ware drive enclosure? Those are cold-swap enclosures, not hot-swap enclosures.

      fucking retard.

  9. Hate to respond to an anonymous coward, but... by capoccia · · Score: 1
    1. Re:Hate to respond to an anonymous coward, but... by Anonymous Coward · · Score: 0

      Laptop. Very different story on those. The hardware is designed to do it.

    2. Re:Hate to respond to an anonymous coward, but... by Anonymous Coward · · Score: 0

      You're such a fucking prick. The questioner was specifically talking about hardware designed to support IDE hot-swap. He's not just yanking drives off the ribbon or something.

  10. Yesterday by Anonymous Coward · · Score: 0

    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. :^)

    1. Re:Yesterday by Anonymous Coward · · Score: 0

      bullshit. if there are no drives on the system there is no way to pull data off so the server wont work at all...not slowly as you claim. with 63 users thats too much data to cache in memory.

    2. Re:Yesterday by Anonymous Coward · · Score: 0

      Ever heard of a network? Perhaps the OS was the only thing on the drives. A short period without swap space may cause some errors but it wouldn't stop the system.

      Also, do you know how much memory was in the box? How can you be sure that there wasn't enough memory to support 63 users? 1 Gig of RAM could easily handle 63 users.

    3. Re:Yesterday by Anonymous Coward · · Score: 0

      Any period with a swap that was once there suddenly disappearing is going to completely fry your virtual memory manager and with it everything running. So if there was swap space in use on the drive, even if only one page was used, programs would begin crapping out. For a similar result, try yanking a DIMM out of a running computer.

  11. From lkml by OrenWolf · · Score: 4, Informative

    "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

  12. Warning! by afidel · · Score: 4, Informative

    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.
    1. Re:Warning! by pmsr · · Score: 2, Informative

      3ware controllers worked best for me, been using them for two years now. With the 3ware 3DM software you can add and remove disks, and rebuild the array(s) at will, even with standard disk trays. Just make sure the trays you use really cut the power to the disk when your turn the key to pull the drawer. Some drawers don't do that. Also, some drawers with included fans seem to have a issue where they suck too much power from the drive electronics, and under stress may have problems. To solve it, i removed those fans making sure the air flow inside the machine was optimum. At $99 for a 3ware escalade 6400 (4 ports), with real hardware RAID5 and supporting the latest ATA drivers, they are a complete steal.

      /Pedro

    2. Re:Warning! by unitron · · Score: 2

      As long as you're hot-swapping the drives and not the drive bays, why not run a separate power feed to the fan on the drive bay?

      --

      I see even classic Slashdot is now pretty much unusable on dial up anymore.

    3. Re:Warning! by Anonymous Coward · · Score: 0

      Spend the extra for the 7xxx series.

      With my 6400 it was actually significantly faster to configure it in JBOD mode, and use Linux's RAID5 code. The 7xxx has far better RAID5 performance.

      6xxx series rock for 0, 1 and 0+1 though.

  13. IDE Enclosures that claim "hot swap" by sid+crimson · · Score: 2, Informative

    I haven't tried any of these enclosures, but there are some out there that claim IDE-Hot-Swap.

    See this Rackmountpro example.

    -sid

  14. swaping the OS or just a mount? by josepha48 · · Score: 2
    If you are talking about swaping out a mount drive you should be able to do that, by just umounting the drive. You'll have to shut off the services and programs that are using that drive.

    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!

  15. Would this even work? by Asprin · · Score: 1, Flamebait

    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
    1. Re:Would this even work? by ActiveSX · · Score: 0

      I know for a fact that this does work for SCSI. I've impressed more than a few people by swapping in SCSI Mac (!) hard disks. Read the SCSI-Programming-HOWTO, it has the instructions for doing this.

    2. Re:Would this even work? by Anonymous Coward · · Score: 0

      on *drive* power on or drive connection the drive geometry "picture" is automatically refreshed/updated on SCSI as well as IDE controllers (when its off tristated mode). youre spouting bullshit.

    3. Re:Would this even work? by mosch · · Score: 1
      You're blathering, and you're fucking wrong.

      SCSI and Fibre Channel controllers are designed to handle just this sort of thing, no problem. Real Operating Systems can start or stop a device live, rescan a bus to see if something new showed up or something old went away, they can do pretty much everything live.

      IDE on the other hand is a steaming pile of shit. I love the way that great IDE advancements are all just implementations of long-standing SCSI features. Five more years, and IDE will have the entire SCSI command set. Way to innovate, IDE!

  16. One way to do it by dissy · · Score: 1

    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

  17. doesn't 3ware support this? by Anonymous Coward · · Score: 0

    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.

  18. IDE isn't, but Firewire is... by GreenKiwi · · Score: 2, Interesting

    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.

  19. A "spin down" command for IDE? or even for SCSI? by Nonesuch · · Score: 2
    With FC-AL drives (at least on modern Sun systems) there is a command to 'spin down' and disconnect a drive in preparation for hot-swap.

    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.

  20. Not really a danger by ShaggyZet · · Score: 1

    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.

  21. BIOS by ruckc · · Score: 1

    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?

    1. Re:BIOS by 42forty-two42 · · Score: 1

      Yes, however Linux uses its own IDE driver, which performs its own brand of autodetection. The BIOS is only needed for the bootloader, which runs in 16-bit mode and w/o the help of the IDE drivers. The bootloaders all use BIOS interrupt calls to load data; if Linux used this ALL apps would hang for the data to come, whereas with a builtin driver only the app reading/writing would hang(sleep, actually).

  22. Floppy Drives by AnimeFreak · · Score: 2

    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.

    1. Re:Floppy Drives by toast0 · · Score: 2

      do you need the floppy drive to have power?

      unless you have an urgent need for it, i'd leave it disconnected, but put a note on the front, and maybe one on the os too.. that lets anybody who would be shutting it down or rebooting it know, that while its down, they may as well hook up the floppy power cable

  23. It works on Win2k Pro... by Daniel+Wood · · Score: 1

    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.

    1. Re:It works on Win2k Pro... by BenTheDewpendent · · Score: 1

      so it only partly worked cause everything showed up as garbage.

    2. Re:It works on Win2k Pro... by prophase_j · · Score: 1

      I have had a method similar to this work under linux... just make the ide subsystem a mod and remove it (disable the conroller) and swap, and insmod :)

  24. Re:A "spin down" command for IDE? or even for SCSI by leiz · · Score: 2

    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.

  25. If you're plugging them in by hand, make sure.. by Gossy · · Score: 1

    ..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.. :)

  26. Use a Fasttrak100 or Ultra 100 card by Anonymous Coward · · Score: 0

    Use promise FastTrack and/or Ultra 100 card and superswap enclosure.

    In fact the FastTrak 100 PRO comes w/ 2 enclosures works great.

  27. Haha by Anonymous Coward · · Score: 0

    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.

  28. Use 1394 or USB 2.0 by iankerickson · · Score: 3, Informative

    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.
  29. The correct procedure... by Anonymous Coward · · Score: 0

    is to install Windows 2000 or Windows XP and forget that no-intuitive spaghetti-code Linux bullshit.

    Then you can plug in or unplug any damn thing you want to, get work done, and never have to type "umount -bullshit /fuck-this _crap" ever again.

  30. what's the big deal? by chocolatetrumpet · · Score: 1

    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.
  31. Re:A "spin down" command for IDE? or even for SCSI by Anonymous Coward · · Score: 0

    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.

  32. Familiar Linux may teach you a lesson... by samrolken · · Score: 1

    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