Page 1 of 2 12 LastLast
Results 1 to 10 of 37

Thread: Proper way to plug/unplug an eSATA hard disk?

Hybrid View

  1. #1

    Question Proper way to plug/unplug an eSATA hard disk?

    For my Linux hardware problems, Google is often my friend. Unfortunately with regard to SATA hot-plug (or hot-swap) support under Linux, all the links I've come across refer to solutions several kernel releases out-of-date.

    The problem: what is the proper procedure (on the software/OS side) to follow when plugging or unplugging an (e)SATA drive? Is a simple "umount /dev/sd[:alpha:][:digit:]" enough?

    Among the "obsolete" solutions I've come across is to use a program called "scsiadd":

    /usr/sbin/scsiadd -s
    scsiadd:scsiadd(): could not open /proc/scsi/scsi (w): No such file or directory

    Also SATA hot-plugging is as yet unsupported by the wonderful new devkit framework. To unplug a USB drive, I use "devkit-disks --detach /dev/sd[:alpha:]" or its GUI "safely remove hardware" equivalent. This doesn't work with the eSATA interface of my external hard disk enclosure.

    To be sure, an examination of the contents of /dev/ shows Linux gracefully removing the nodes (both disk and partition) for an unplugged eSATA drive. This is confirmed by the dmesg output.

    (Note: I have enabled AHCI and disabled IDE mode for SATA in the motherboard BIOS, so SATA device recognition is not the issue. I'm looking for the proper or most elegant way to unplug/replug an eSATA drive.)

  2. #2
    Join Date
    Feb 2008
    Location
    Linuxland
    Posts
    5,187

    Default

    I'm not completely sure on how devkit-disks does it, but have you tried eject -s /dev/sdX? A scsi eject might be the proper way.

  3. #3
    Join Date
    Oct 2009
    Posts
    2,122

    Default

    Unmount, then pull wire.

  4. #4

    Default

    Quote Originally Posted by droidhacker View Post
    Unmount, then pull wire.
    What I've read thus far says it should be power down first before pulling off wire.

  5. #5
    Join Date
    Jul 2008
    Location
    Greece
    Posts
    3,798

    Default

    I see you said "(e)SATA" and not "eSATA". If you're under the impression that all normal SATA drives can be unplugged, you're wrong. Your SATA controller has to specifically support this. If it doesn't say anything about SATA hotplugging, then it's not supported. Trying it should be safe, but there's always a chance of hardware damage.

    eSATA is always hotpluggable.

  6. #6

    Default

    Quote Originally Posted by RealNC View Post
    eSATA is always hotpluggable.
    What then do you do on the software side before unplugging? Is it a simple "umount /dev/sd"[drive letter]?

  7. #7
    Join Date
    Jul 2008
    Posts
    29

    Default

    Quote Originally Posted by An(noymous)droid View Post
    What then do you do on the software side before unplugging? Is it a simple "umount /dev/sd"[drive letter]?
    after unmounting the device, to "power off" (or sleep) the unit:

    Code:
    hdparm -Y /dev/sdX
    (where X represents the device you wish to power off. for example: /dev/sdb)

    this will power the drive down allowing for it's removal w/o risk of voltage surge.

  8. #8
    Join Date
    Jul 2008
    Location
    Berlin, Germany
    Posts
    836

    Default

    All SATA and eSATA hardware is physically able to be hotplugged (ie. not damaged if you insert/pull the plug).

    How the chipset and driver handles this is another question. Some driver/chipset combinations do not properly handle hotplugging and need a warmplug command such as the following one:
    Code:
    echo 0 - 0 > /sys/class/scsi_host/hostX/scan
    Replace X with the appropriate number for your SATA/eSATA port.

  9. #9
    Join Date
    Jan 2009
    Location
    Vienna, Austria; Germany; hello world :)
    Posts
    640

    Default

    @justsumdood:

    that was the exact same way I did it - up until NOW


    with kernel 3.3 rc3 & rc4 (afaik it worked with 3.2)

    I only get the following:

    [ 2093.960134] ata8: exception Emask 0x10 SAct 0x0 SErr 0x990000 action 0xe frozen
    [ 2093.960139] ata8: irq_stat 0x00400000, PHY RDY changed
    [ 2093.960144] ata8: SError: { PHYRdyChg 10B8B Dispar LinkSeq }
    [ 2093.960151] ata8: hard resetting link
    [ 2094.681797] ata8: SATA link down (SStatus 0 SControl 300)
    [ 2099.673242] ata8: hard resetting link
    [ 2099.977646] ata8: SATA link down (SStatus 0 SControl 300)
    [ 2099.977660] ata8: limiting SATA link speed to 1.5 Gbps
    [ 2104.969034] ata8: hard resetting link
    [ 2105.273515] ata8: SATA link down (SStatus 0 SControl 310)
    [ 2105.273528] ata8.00: disabled
    [ 2105.273544] ata8: EH complete
    [ 2105.273553] ata8.00: detaching (SCSI 7:0:0:0)
    [ 2105.274064] sd 7:0:0:0: [sde] Synchronizing SCSI cache
    [ 2105.274094] sd 7:0:0:0: [sde] Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK
    [ 2105.274100] sd 7:0:0:0: [sde] Stopping disk
    [ 2105.274108] sd 7:0:0:0: [sde] START_STOP FAILED
    [ 2105.274111] sd 7:0:0:0: [sde] Result: hostbyte=DID_BAD_TARGET driverbyte=DRIVER_OK


    that means when after that I plug in another harddrive and power it up - it won't be recognized

    the controller is the (in)famous Jmicron 36x (dunno 368 or 363, something)


    the same happens when stopping via sdparm and remounting read-only (sdparm -C stop -r /dev/foo )


    any idea how to get it recognize the new disk ?
    Last edited by kernelOfTruth; 02-22-2012 at 10:02 AM.

  10. #10
    Join Date
    Sep 2007
    Location
    Connecticut,USA
    Posts
    965

    Default

    Quote Originally Posted by An(noymous)droid View Post
    What then do you do on the software side before unplugging? Is it a simple "umount /dev/sd"[drive letter]?
    I'd say the safest way would be to first issue a umount to the (e)SATA device you want to remove...this will ensure all data has been written to the device and the inodes are updated so the device has a "clean" filesystem. Once that's done you can then power off the device and unplug it.

    This should be applicable to USB sticks as well but as there's no need to power them off you can unplug after unmounting them.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •