Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
×
Linux Software

Swapping IDE Drives in Linux without Rebooting? 77

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!"
This discussion has been archived. No new comments can be posted.

Swapping IDE Drives in Linux without Rebooting?

Comments Filter:
  • Check LKML (Score:2, Informative)

    by gantzm ( 212617 )
    This is being discussed on the LKML right now!
  • by xiox ( 66483 )
    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.
  • Try this... (Score:5, Informative)

    by PoiBoy ( 525770 ) <brian.poiholdings@com> on Thursday March 28, 2002 @11:33AM (#3241218) Homepage
    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.

    • Re:Try this... (Score:2, Informative)

      by Anonymous Coward
      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.
      • 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...

      • 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.
    • 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.
  • by mosch ( 204 ) on Thursday March 28, 2002 @11:43AM (#3241299) Homepage
    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.
  • by Wakko Warner ( 324 ) on Thursday March 28, 2002 @11:44AM (#3241308) Homepage Journal
    ...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.
    • by Anonymous Coward
      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.
  • From lkml (Score:4, Informative)

    by OrenWolf ( 140914 ) <ksnider@f[ ]n.com ['lar' in gap]> on Thursday March 28, 2002 @12:44PM (#3241712) Homepage
    "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
  • Warning! (Score:4, Informative)

    by afidel ( 530433 ) on Thursday March 28, 2002 @01:15PM (#3241925)
    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 [3ware.com], Promise [promise.com] or Adaptec [adaptec.com] along with certified disk trays.
    • Re:Warning! (Score:2, Informative)

      by pmsr ( 560617 )
      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
      • 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 haven't tried any of these enclosures, but there are some out there that claim IDE-Hot-Swap.

    See this Rackmountpro [rackmountpro.com] example.

    -sid
  • 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.

  • 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.
    • 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!

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

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

  • by ruckc ( 111190 )
    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?
    • 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).
  • 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.
    • 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

  • 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.
  • ..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 1394 or USB 2.0 (Score:3, Informative)

    by iankerickson ( 116267 ) on Friday March 29, 2002 @03:22PM (#3249101) Homepage
    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.

  • 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/

A penny saved is a penny to squander. -- Ambrose Bierce

Working...