Hi all

I just bought an external 60GB HDD I cant say what brand name as it doesn't have one written on it.
I know there are problems unmounting HDD's and then they do not spin down and I am having the same problem.
It is in /dev/sdc and the ntfs partition is in sdc1
I mount it in /media/portablehdd
I have tried the following script to unmount and spindown the drive and the script runs but the drive remains on with lights and spinning.

#!/bin/sh
pumount /dev/sdc1
#wait for mtab to be updated
sleep 3
#we search an occurency of our harddrive in mtab
UMOUNT=`grep '/dev/sdc1' /etc/mtab | wc -c`
if [ $UMOUNT -eq 0 ]
then
   #we sync the harddrive
   sdparm --command=sync /dev/sdc1
   #we can spindown the hardrive
   sdparm --command=stop /dev/sdc1
   zenity --info --title="Info" --text="You can unplug your Hardrive !"
else
   zenity --error --title="Info" --text="It seems your harddrive isn't unmounted , unmount it then try again"
fi

But the drive still keeps spinning. Can someone please help me as I am getting worried about just pulling the drive out and possibly losing data.


Many thanks

HLA91

Dani AI

Generated

Unmounting a filesystem only tells the OS to stop using that filesystem — it does not guarantee the enclosure will spin the platter down or cut power. Many USB-to-SATA bridge firmwares do not forward ATA/SCSI power-off or standby commands, so the drive can remain powered (lights on, motor spinning) even after a clean unmount.

A practical troubleshooting sequence:

# verify no mountpoints or open handles (replace sdX / mountpoint)
lsblk -o NAME,MOUNTPOINT
lsof /dev/sdX
fuser -m /mount/point

# prefer the desktop "eject" if available (convenient for non-root users)
# on modern systems:
udisksctl unmount -b /dev/sdX1
udisksctl power-off -b /dev/sdX

# low-level attempts (only if the enclosure passes commands through)
hdparm -C /dev/sdX           # check power state
hdparm -Y /dev/sdX           # request standby (may fail on USB bridges)
sg_start --stop /dev/sdX     # sends SCSI STOP UNIT (sg3_utils)

Key points and cautions:

  • Always target the whole block device (e.g., /dev/sdX) for power/stop commands, not a partition node.
  • Confirm no processes hold the device before forcing power-off; unmount first and check lsof/fuser.
  • Many enclosures ignore ATA/SCSI passthrough; failure of hdparm/sg_start does not mean something is wrong with the drive.
  • If device does not power off electronically, unplugging after a verified unmount and completed sync is generally safe, but avoid doing so while mounted or if write activity is present.

As noted, the file-manager eject is the user-friendly first step. If that doesn’t spin the disk down, try the checks above and, if you need reliable spin-down/power-off, consider a different enclosure or a dock that explicitly supports USB power-off passthrough. This avoids relying on firmware behavior you can’t change.

Sorry forgot to mention its Ubuntu 9.04

assuming this is desktop edition, there should be an eject icon next to the device in the file explorer (can't remember what it is called). whenever i used my portable hdd with ubuntu 9.04 i used this, and it hasn't lost data.

hope that helps.

Ok thanks, I was just worried as it wasn't spinning down but I just tried it on Win XP and it still doesn't spin down after 'safely removing' it. It only stops spinning once you unplug it.

Cheers

HLA91

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.