Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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".
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.
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 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
Distribution: Switched to regualr Ubuntu, because I don't like KDE4, at all. Looks like vista on crack.....
Posts: 675
Rep:
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.