Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Tagged as

SATA Hotplug : Add/Remove Sata HDD in a Jiffy

, 16 Sep 2012 CC (ASA 3U)
Rate this:
Please Sign up or sign in to vote.
Here is how to use your SATA HDD like an portable (plug-n-play) HDD...

Introduction

It's 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 

echo "- - -" > sudo tee /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.
You can find more information here.

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 and 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

echo 1 > sudo tee /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

That's it! That's how one can use the hotplug feature of SATA HDDs to effectively use them as portable external HDDs.

License

This article, along with any associated source code and files, is licensed under The Creative Commons Attribution-Share Alike 3.0 Unported License

Share

About the Author

TheCodeArtist
Software Developer (Senior) Nvidia Corporation
India India
Chinmay V S (a.k.a TheCodeArtist) is a Senior software engineer at NVIDIA Corporation - India. With more than 4 Years of hands-on experience in Linux Kernel and Android BSP development, he has been actively involved in developing and integrating drivers for the Linux-kernel and hardware abstraction layers for OMAP4 based Android smartphones, automotive navigation and infotainment devices.
 
In his spare time, he can be seen lurking in the shadows on StackOverflow and various Linux kernel mailing-lists. He enjoys sharing his experiences with technology as TheCodeArtist on his blog.
Follow on   Twitter   Google+

Comments and Discussions

 
GeneralMy vote of 2 Pinmembernot_starman17-Sep-12 13:01 
GeneralRe: My vote of 2 PinmemberTheCodeArtist17-Sep-12 18:54 
GeneralRe: My vote of 2 PinmemberMember 40541004-Nov-12 6:05 
GeneralRe: My vote of 2 PinmemberMember 40541004-Nov-12 6:06 
GeneralRe: My vote of 2 PinmemberJohn B Oliver9-Oct-12 12:31 
GeneralMy vote of 2 PinmemberАslam Iqbal16-Sep-12 18:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141223.1 | Last Updated 16 Sep 2012
Article Copyright 2012 by TheCodeArtist
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid