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?

3
  • 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 3, 2013 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 4, 2013 at 2: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 4, 2013 at 9:05

2 Answers 2

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!

2
  • 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? Mar 26, 2023 at 13:50
  • Figured it out: askubuntu.com/questions/561896/… : sudo rescan-scsi-bus Mar 26, 2023 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?

1
  • Correct, this does indeed work for eSATA.
    – ianinini
    May 13, 2020 at 12:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .