Search TheCodeArtist

SATA hotplug : Add/Remove sata HDD in a jiffy

Its not common knowledge that SATA HDDs are capable of being hot-plugged into almost any modern PC. However using them in a plug-n-play manner like portable external USB-HDDs is still not common.

Here is how to use your SATA HDD like an portable HDD.

Tested on:
- Ubuntu 11.10
- DELL Optiplex 380
- Seagate Barracuda 1TB (SATA).

1. Connect the SATA HDD to host PC. (sata-bus + power)


2. Scan for new devices on SCSI host

sudo echo "- - -" > /sys/class/scsi_host/hostN/scan
where N is the host port number on your host PC to which you have plugged-in the SATA HDD. Usually N=1, assuming the primary HDD on host PC is connected on SATA0.

"- - -" stands for wildcards in place of the
channel number, SCSI target ID, and LUN. More Info

3. Mount the newly detected device locally

sudo mount /dev/sdX /media/temphdd
where X is a/b/c/d etc. Usually X=b, assuming the primary HDD on host PC is enumerated as sda an there are no other block devices.

4. Copy all your data to/from the HDD present at /media/tempHDD.


5. Once finished, unmount the device

sudo umount /media/temphdd

6. Powering down the SATA HDD

sudo echo 1 > /sys/block/sdX/device/delete
Ensure that you refer to the proper device (sdb, sdc etc.) as above in step 3.

7. Disconnect the SATA HDD from host PC.

Thats it! Thats how one can use the hotplug feature of SATA HDDs to efectively use them as portable external HDDs.

1 comment :

  1. not common knowledge

    very few manufacturers can be bothered to properly- and FULLY implement sata spec in controllers

    ReplyDelete