2

I'm connected via ssh to a Debian computer. What I need to to do is to safely remove the external usb storage device.

I have found this answer to a comparable question. One of the recommendations is just to eject or unmount by doing sudo eject /dev/sda. Now my problem is that I don't have a /dev/sd*. So the next proposed solution is by echo

'offline' > /sys/block/sdb/device/state
echo '1' > /sys/block/sdb/device/delete

Now my problem is another one. How do I now the my usb hard drive is sdb and not sda, sdc or sdd?

lsusb `just shows me` Bus 002 Device 008: ID 1058:25a2 Western Digital Technologies, Inc. Elements 25A2

Do you have any ideas? Thanks in advance

2 Answers2

3

What you're doing is too compilcated. ;-)

Usually it suffices to do the following:

  1. umount the mounted media (if the device has multiple partitions then do that for all of them).
  2. Execute eject /dev/sdN (or whatever /dev/disk/by-id/... is more useful for you; or a device from another hierarchy under /dev/disk).

You might intersperse a call to sync between those two but I'd say it's for truly paranoid persons as eject should take care of forcing the kernel to push any buffered data to the device. See eject(1).

kostix
  • 2,976
1

These worked for my debian11 system:

To unmount a mounted device /dev/sdb1:

udisksctl unmount   --block-device /dev/sdb1

To Power off (ie safely remove) the device /dev/sdb:

udisksctl power-off --block-device /dev/sdb
Nishant
  • 103