5

Is there any way to safely remove any external disk connected via eSATA? Disks make an ugly noise when unplugged, even if there are no mounted partitions I found this little command somewhere, and it seems to shutdown the disk.

sdparm --flexible --command=stop /dev/sdb &>/dev/null

But, just when it powers off, it starts working again.

Any clue?

cocomac
  • 3,043
  • 3
  • 16
  • 49
Padlite
  • 103
  • 6
  • The problem is present also on USB disks as well. My "solution" is timing. Click "Eject" and the moment I hear the drive spinning down, I detach the cable. Not a nice solution, but there's no ugly noise like that. – To Do Jan 03 '13 at 10:31
  • I try doing that using this command.. I think "Eject" does the same.. But I can't find it anywhere (that's a Nautilus context-menu option, right?) – Padlite Jan 04 '13 at 02:29
  • Actually there used to be an "Eject" option. Now there's only "Unmount". Actually "Eject" was intended for media that can be ejected (CD/DVD). Unmount saves any data which is waiting to be written but does not power off the device, unfortunately. – To Do Jan 04 '13 at 09:05

2 Answers2

8

Try echo 1 > /sys/block/<disk>/device/delete. You'll need to be root to do this.

On my system, this powers off the eSATA disk and deallocates its block device. The disk stays powered off and I can disconnect it at my leisure.

Note: make sure you have unmounted any filesystems first to prevent data loss!

Robie Basak
  • 15,524
  • 4
  • 61
  • 86
  • Thanks. This works great except the disk then won't be reattached until reboot. Is there a quicker way to replug after writing 1 to the delete file? – Petr Skocik Mar 26 '23 at 13:50
  • Figured it out: https://askubuntu.com/questions/561896/esata-hotplugged-drive-not-recognized : sudo rescan-scsi-bus – Petr Skocik Mar 26 '23 at 13:54
1

There is a procedure when you want to remove SATA disks.

First umount any partitions, and then flush the I/O buffer by entering

blockdev --flushbufs /dev/sd?

then remove the drive by entering

echo 1 > /sys/block/sd?/device/delete

I guess it can work for eSATA as well.

A question still remains in my mind: are the heads are safely parked in the landing zone with this procedure?

ianinini
  • 130
  • 6