umount and turn off usb-hdd

Asked by Anton Yakutovich

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

thanks for attention

Question information

Language:
English Edit question
Status:
Solved
For:
Ejecter Edit question
Assignee:
No assignee Edit question
Solved by:
Federico Pelloni
Solved:
Last query:
Last reply:
Revision history for this message
Best Federico Pelloni (fredp) said :
#1

Hello
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.

Revision history for this message
Anton Yakutovich (dr-akulavich) said :
#2

Thanks for reply, Federico.

Revision history for this message
Anton Yakutovich (dr-akulavich) said :
#3

Thanks Federico Pelloni, that solved my question.

Revision history for this message
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... =)

Alvin

Revision history for this message
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!

jazz1982

Revision history for this message
Anton Yakutovich (dr-akulavich) said :
#6

I have the same bug with spin in Jaunty.

Revision history for this message
jazz1982 (jazz1982) said :
#7

   I suspect that the new kernel might be responsible. Tested with the 2.6.28.5 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

Revision history for 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 2.6.28.5 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
root@PartedMagic:~#

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

jazz1982

Revision history for this message
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: https://bugs.launchpad.net/ubuntu/+bug/117713

Revision history for this message
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.

Revision history for this message
ssergeje (ssergeje) said :
#11

Refer to bug #117713 for unmounting and https://bugs.launchpad.net/ubuntu/+bug/117713/comments/49 for sdparm problems in Jaunty.