LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-09-2009, 06:39 AM   #1
Toods
Member
 
Registered: Dec 2005
Location: UK
Distribution: Slackware 12.1
Posts: 249

Rep: Reputation: 32
Safely Remove USB External Hard Drive


I have just started to use a Western digital USB external hard drive on my Slackware 12.1 box.

It mounts as expected when powered up and plugged in.

My main concern is a 'safe-removal' of the drive.

If I right-click on the drive in KDE the drive is definitely unmounted as confirmed by disappearance from 'etc/mtab', but the drive does not spin-down. Same result if I issue 'umount /dev/sda1' from terminal window.

I feel uneasy about pulling out and disconnecting the drive whist it still spins. I can of course spin it down by issuing 'hdparm -y /dev/sda1'

what is the best / correct way to unmount and remove these drives?.

Thanks,

Bill.
 
Old 02-09-2009, 06:44 AM   #2
mcnalu
Member
 
Registered: Dec 2006
Location: Glasgow, UK
Distribution: Slackware current
Posts: 423

Rep: Reputation: 73
Bill

I've got an external WD USB drive and it spins down if you remove the usb cable,
or if you just wait for a few minutes after it's been unmounted and idle.

I usually do the former and it hasn't caused any problems to date.
 
Old 02-09-2009, 07:28 AM   #3
Toods
Member
 
Registered: Dec 2005
Location: UK
Distribution: Slackware 12.1
Posts: 249

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by mcnalu View Post
Bill

I've got an external WD USB drive and it spins down if you remove the usb cable,
or if you just wait for a few minutes after it's been unmounted and idle.

I usually do the former and it hasn't caused any problems to date.
Yes, I too noticed that it powered-down when removing the USB cable, but it certainly wasn't such a 'quite' power-down as when I issued the 'hdparm
-y /dev/xxx' command to put it in 'Standby'. It is causing an 'emergency' head-park?.

I just wonder if something extra is needed to get the same kind of unmounting that one gets with Windows XP 'safely remove hardware'

Bill.
 
Old 02-09-2009, 07:54 AM   #4
mrgreedy
LQ Newbie
 
Registered: Sep 2008
Location: England
Distribution: Slackware
Posts: 15

Rep: Reputation: 0
I have a similar issue, which is probably related. When using a USB stick on Windows and doing "safely remove the device" from the windows menu, the LED on the USB stick switches off - so I know it's definitely dismounted. However, in Linux, when I umount a USB stick the LED stays on. Now I'm sure it's safely dismounting, but I'm curious why it doesn't get switched off.
 
Old 02-09-2009, 08:26 AM   #5
Toods
Member
 
Registered: Dec 2005
Location: UK
Distribution: Slackware 12.1
Posts: 249

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by mrgreedy View Post
I have a similar issue, which is probably related. When using a USB stick on Windows and doing "safely remove the device" from the windows menu, the LED on the USB stick switches off - so I know it's definitely dismounted. However, in Linux, when I unmount a USB stick the LED stays on. Now I'm sure it's safely dismounting, but I'm curious why it doesn't get switched off.
Yes, I see this same thing with my USB Flash Drive.

I've got into the habit now of running 'mount' after 'safely removing' on Linux just to make sure it really is not still mounted.

I can obviously continue to issue the 'hdparm -y' command to manually spin-down my USB HDD drive, but I just wondered if there is a more elegant way of doing it in Slackware.

Bill.
 
Old 02-09-2009, 08:27 AM   #6
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
You might try using the eject command instead of umount. But, many drives will not 'disconnect' (I mean where the light goes out and drive becomes inactive) in an orderly fashion the way they do under windows.
 
Old 02-09-2009, 12:39 PM   #7
mrgreedy
LQ Newbie
 
Registered: Sep 2008
Location: England
Distribution: Slackware
Posts: 15

Rep: Reputation: 0
Quote:
Originally Posted by gnashley View Post
You might try using the eject command instead of umount. But, many drives will not 'disconnect' (I mean where the light goes out and drive becomes inactive) in an orderly fashion the way they do under windows.
Great, the eject command worked! The LED switched off properly. I just need to change my alias to this instead. Thanks.

This should work for your flash drives as well, Toods.

Last edited by mrgreedy; 02-09-2009 at 12:41 PM.
 
Old 02-09-2009, 02:44 PM   #8
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
"This should work for your flash drives as well" -what I meant is that not all drives will do this -some wil, but others won't(which do disconnect under windows). The USB kernel drivers are still in flux -maybe someday they'll get it right and keep it that way.
 
Old 02-09-2009, 03:43 PM   #9
mcnalu
Member
 
Registered: Dec 2006
Location: Glasgow, UK
Distribution: Slackware current
Posts: 423

Rep: Reputation: 73
Hmm, perhaps my method of removing my all-important backup disk wasn't as safe as I assumed

Unfortunately eject doesn't seem to do anything other than unmount my WD external disk. From now on I'll just wait until it spins down or use hdparm.

EDIT: Actually hdparm -y /dev/sd.. resulted in the same clunk, whizz as pulling the usb cable.

Intererestingly, windows XP refused to safely "stop" the same disk connected to the same laptop - said some process was busy using it.

Last edited by mcnalu; 02-09-2009 at 03:48 PM.
 
Old 02-09-2009, 05:25 PM   #10
Toods
Member
 
Registered: Dec 2005
Location: UK
Distribution: Slackware 12.1
Posts: 249

Original Poster
Rep: Reputation: 32
Several useful suggestions made in this thread. Many thanks.

An interesting observation I made:

I can 'right-click' on my mounted corsair USB pen drive and it is unmounted and the entry disappears from the KDE 'storage Media directory'. When I try the same with the WD external USB drive, it is certainly unmounted (disappears from mtab) but the icon remains in the KDE 'storage Media directory'. Moreover, if I click the mouse on the icon it re-mounts.

Anyone know why these two USB mass-storage devices should be treated differently in this way?,

On the subject of quietly disconnecting my WD USB drive, I found the most 'comforting' and quiet way is to first 'unmount' in KDE then run the following bash script:
Code:
#!/bin/bash
echo "Sync and Flush cache"
hdparm -f /dev/sda
sleep 2
echo ""
echo "Now Drive to Stand-by"
hdparm -y /dev/sda
Bill.
 
Old 02-09-2009, 05:37 PM   #11
jazzor
Member
 
Registered: Apr 2007
Posts: 41

Rep: Reputation: 16
Is it not true that when you "safely remove hardware" in windos you cannot get the drive back until you unplug and replug??

If I am right (and I might be wrong since i have not used such operating system for a long time), then in the case of the umount command, it does not power down because it expects that you will mount it back again (either through gui double click or mount command) without you having to take the usb out and in??
 
Old 02-10-2009, 01:53 AM   #12
alMubarmij
Member
 
Registered: Dec 2005
Posts: 140
Blog Entries: 1

Rep: Reputation: 16
Code:
#!/bin/bash
echo "Sync and Flush cache"
hdparm -f /dev/sda
sleep 2
echo ""
echo "Now Drive to Stand-by"
hdparm -y /dev/sda
Thanks Toods for this good script.
 
Old 02-10-2009, 02:57 AM   #13
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
If you want to be extra safe, you could run 'sync' before unmounting or ejecting. Both umount and eject should do this, but it doesn't hurt anything to do it manually. If you have ever noticed that it takes a while for umount to finish, it is because it is running sync before unmounting. And, eject runs the umount command before doing an 'eject'. If you have run sync and allowed it to finish flushing the write buffer, you should be able to simply unplug the device without harming it -but I wouldn't do that on purpose. The device would still show to be mounted even when physically removed.
The difference in the way different drives react to the commands has to do with the nature of the device. Real hard drives may not register as removable devices, whereas FLASh devices usually will. Also, if you are using a card-reader, insert and remove eventy are not sent to the driver and the same may happen if using an extra hub between the device and the computers' USB port.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
safely remove external hard-drive vashsna Linux - Hardware 4 11-16-2008 04:01 PM
How to avoid GRUB error 21 when I remove external hard drive blee37 Linux - General 4 12-30-2006 07:40 AM
external enclosure for an internal hard drive vs external USB hard drive powah Linux - Hardware 1 03-10-2006 09:03 AM
Installing grub to external USB hard drive for later use as internal hard drive dhave Linux From Scratch 2 12-10-2005 08:48 AM
Safely remove USB Flash drive? Guitarist88 Linux - Newbie 3 05-26-2004 03:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration