LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Safe removal of external USB HDD (https://www.linuxquestions.org/questions/linux-hardware-18/safe-removal-of-external-usb-hdd-616410/)

<Ol>Origy 01-26-2008 06:52 AM

[Solved]Safe removal of external USB HDD
 
How do I safely remove my external USB HDD in linux?

Okay so perhaps I wasn't being clear enough with that question. I am mostly using Ubuntu 7.10 and I recently purchased a WD Passport external USB HDD. Now with a little bit of disk use I can't help myself not to notice that the removal of the HDD in linux differs from the procedure WinXP. What bothers me here is not the fact that it does differ, but rather how it differs. In Windows XP I normally choose to safely remove the device in the tray icon and that's it. The device powers down and I remove it - I can tell this because I feel it stops vibrating when I hold it in my hand.

Linux tells a different story. Whenever I plug it in it will power up normally and linux will auto-mount the drive. Everything okay and nice. However I'm not so sure about drive removal. When I tell linux to unmount the volume (the disk has a single NTFS partition) it will only remove the mount point, but will not power down the device - the disk is still spinning. If I pull the plug at this point I can hear the hard shutdown of the HDD. I read somewhere that this kind of removal is rough on the device and shortens its lifetime. I've been a bit paranoid about this method of removal since I'd like to handle my components with care... Until now I had to leave the disk alone for a while until it self-powered down due to idle time, but I'm looking for a quicker way to do this.

Is there a way to power off the disk motor in linux (perhaps a console command) so it can be safely removed?

~Ol

budword 01-26-2008 07:39 AM

What desktop are you using ? In KDE you can right click the desktop icon for the drive, and chose "Safely Remove" from the drop down menu.

David

<Ol>Origy 01-26-2008 08:10 AM

I'm using Gnome :s

budword 01-26-2008 08:41 AM

I don't use gnome, but it looks like it's the same sort of deal....

http://www.linuxquestions.org/questi...-drive-186194/

You could always open /media or /mnt or wherever you have it mounted in gnomes file browser (nautilus ?), right click it there, and select "Safely Remove".

Hope that helps....

David

<Ol>Origy 01-26-2008 10:27 AM

Yeah well I kind of can't find the "safely remove" option ;)

http://img405.imageshack.us/img405/6...memenu1xf4.png
http://img141.imageshack.us/img141/6...memenu2af6.png

If I use that unmount option, the disk will keep spinning.

budword 01-26-2008 12:14 PM

Have you thought about trying KDE ?

David

P.S.

:D

<Ol>Origy 01-26-2008 12:31 PM

Well I was hoping for an universal solution (e.g. console command) that works in many linux distros, not just the one I'm using on my laptop (Ubuntu 7.10). I'm not sure if the fact that I cannot safely remove some hardware should be considered the sole reason to change my desktop. What about my other PC's that have XFCE/Fluxbox/(insert your window manager here) or don't have gdm at all?

I'll do some more digging and see if I can find something.

EDIT: Ahaha. I found the link back to this very thread on Google. It appeared second in line.
EDIT2: https://bugs.launchpad.net/ubuntu/+bug/117713

<Ol>Origy 01-26-2008 12:46 PM

Okay apparently this seems to be ubuntu-related bug according to the link above. I must admit that I did not yet get a chance to test the HDD on other linux distros as the drive is relatively new. I'll experiment a bit with my findings and report back later.

EDIT: Works :D Here's the code:
Code:

#!/bin/sh
WD=/dev/sdb1
sudo umount $WD
if [ $? -eq 0 ]
then
 echo Stopping heads
        #Stop properly the heads and cylinders
 sdparm --command=stop $WD
else
 echo Unmount Failed !
fi

~Ol

budword 01-26-2008 01:10 PM

Linux is soo cool. Someone else had the same problem, and wrote a script for everyone else to use to solve this problem until the people who do the real coding for Linux can fix it. Then someone else comes along and improves the script, because he usually has a few other devices hooked up, and doesn't want to unmount the wrong device, and he gives that script away to everyone else too. And on top of that, we use Google to find the answer, which was served to us with...yup.... Linux.

So does that updated script work ? I was just goofing off about the KDE comment, because of the gnome vs. kde war that breaks out once in a while. I have trouble using gnome, because I like to tweak every little thing, and I can't do that in gnome, which drives me a little nuts. When it comes to my OS, I want things to be set up exactly how I want them. Gnome sets it up the way THEY want it.

Anyway, let us know how it went...

David

mazinoz 01-27-2008 06:30 PM

Safe removal of USB hard drive
 
I think there are two issues here, the unmounting which has been mentioned and the power down of the device. Pulling the power on a spinning hard drive is not a good idea!! What I do is unmount and shutdown.

Then I unplug the USB cable from both hdd and PC. Shortly after this I can hear the hard drive stopping. Then I turn off hdd power switch and unplug power cable.

To mount it I wait till PC has booted, then attach power cable, attach the USB cables, TURN ON the external hard drive. This way linux doesn't get confused as it would if hard drive is spinning, and the hard drive isn't crashed or damaged. This is the sequence of steps stated by the manufacturer.


All times are GMT -5. The time now is 12:03 PM.