umount and turn off usb-hdd

Asked by Anton Yakutovich on 2009-03-05

Hi there!
Could you add an option turn off for external hdd?
Now I use shell script to do it:
exec 2>&1
pumount $1 || umount $1
sdparm --command=sync $1
sdparm --command=stop $1

thanks for attention

Question information

English Edit question
Ejecter Edit question
No assignee Edit question
Solved by:
Federico Pelloni
Last query:
Last reply:
Best Federico Pelloni (fredp) said : #1

I think this should be implemented at Gtk/Gio level, so it would be available system-wide (e.g. unmounting from nautilus would have the same effect). You could try asking the gtk+ development team.

Thanks for reply, Federico.

Thanks Federico Pelloni, that solved my question.

growingneeds (growingneeds) said : #4

Hi all,

I'm really not too certain about whether external hard disks should be formatted as ext3. But I do want to delve deeper into Linux. And so I did.

Right-clicking an external USB HDD and selecting unmount still resulted in a spinning HDD with LED lights on. What I do now (in a terminal) is this:

1. umount /dev/sdb1
2. sudo sdparm --command=sync /dev/sdb1
3. sudo sdparm --command=stop / dev/sdb1

This finally spins down the HDD and allowed me to disconnect the USB HDD. Now my main concern is that I might forget how to issue the 3 commands each time I disconnect the drive. They are rather lengthy commands to be issued... =)


jazz1982 (jazz1982) said : #5

 Hello all,

  I installed Jaunty (amd64) yesterday and noticed one strange thing about unmounting and powering-off (spinning down) my external USB drive (Transcend StoreJet). While everything was ok in Intrepid (unmounting and THEN doing sdparm syncing + stopping), Jaunty won't do it properly; drive is still spinning after the 'stop' command. Strangely enough, if I do not unmount it and commit the sdparm stop, it spins down, but the drive still appears to be mounted (and spins back on if I either doing the unmount or accessing the folder).

 My question is, can I (relatively safely) ommit the regular unmount procedure and go straight with the --command=sync& --command=stop before I unplug the cord? Anything I could try in the meantime, some other command or so? Thanks in advance!


I have the same bug with spin in Jaunty.

jazz1982 (jazz1982) said : #7

   I suspect that the new kernel might be responsible. Tested with the that comes with Parted Magic 3.6 micro distribution and everything works as it should (unmount-->sync--->stop). I'm not sure where and how to submit the possible bug in current jaunty kernel, but I hope someone will notice this message :)


jazz1982 (jazz1982) said : #8

   Or maybe it's not for the kernel... I just realized that the new Parted Magic version (4.0) also sports the kernel but with no luck in spinning the drive down... (same symptoms as with the Jaunty) No difference in output whatsoever, between the 3.6 (working) and 4.0 (not working):

root@PartedMagic:~# sdparm -V
version: 1.03 20080623
root@PartedMagic:~# umount /dev/sdd1
root@PartedMagic:~# sdparm --command=sync /dev/sdd1 -vvv
>>> about to open device name: /dev/sdd1
open /dev/sdd1 with flags=0x802
    inquiry cdb: 12 00 00 00 24 00
    /dev/sdd1: StoreJet Transcend
    synchronize cache(10) cdb: 35 00 00 00 00 00 00 00 00 00
      duration=0 ms
root@PartedMagic:~# sdparm --command=stop /dev/sdd1 -vvv
>>> about to open device name: /dev/sdd1
open /dev/sdd1 with flags=0x802
    inquiry cdb: 12 00 00 00 24 00
    /dev/sdd1: StoreJet Transcend
    Start stop unit command: 1b 00 00 00 00 00
      duration=15 ms

   Maybe it's something else, but I don't have a clue :( Any suggestions? Thanks!


svd (le8) said : #9

After upgrade from Intrepid to Jaunty following commands stopped working (i.e. in Intrepid they stopped external hdd properly, but on Jaunty these commands fail to stop drive despite exit codes equal to zero):

sudo sdparm --command=sync /dev/sdXY
sudo sdparm --command=stop /dev/sdXY

Pls fix this cause the only workaround (sdparm commands) to stop external drives properly which worked in Intrepid is now broken.

See here for details about "development" of workaround:

Mircea (tramir) said : #10

Works for me in Jaunty...

Anyways,question for OP (Anton Yakutovich): did you ever get to make the script be run system-wide, as suggested by Federico Pelloni? If so, would you mind sharing with us how? Thanks.

ssergeje (ssergeje) said : #11

Refer to bug #117713 for unmounting and for sdparm problems in Jaunty.