1

In Ubuntu 16.04, I try to safely remove the flash disk from the command line. When I run the following script (from the Eject / safely remove vs umount):

udisksctl unmount -b /dev/sdb1
udisksctl power-off -b /dev/sdb1

It says:

Error powering off drive: Error opening /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/remove: No such file or directory (udisks-error-quark, 0)

When I type these commands from the keyboard, I don't get the error.

Why, and how should I make the script running?

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
user31264
  • 129
  • 4

1 Answers1

0

The difference between the script and the manual typing might be a timing issue. If so, add a delay between the two commands.

udisksctl unmount -b /dev/sdb1
sync
sleep 1
udisksctl power-off -b /dev/sdb1
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Yaron
  • 4,229
  • 2
  • 20
  • 33
  • 1
    If the problem is timing, then `&&` doesn't make any difference. The difference between `;` (or newline, they're different ways of writing the same thing) and `&&` is that with `&&`, the second command is executed only if the first succeeded. The timing of the commands is not affected. – Gilles 'SO- stop being evil' Jun 14 '17 at 23:24
  • `&&` did not help – user31264 Jun 15 '17 at 22:03
  • ,@user31264 did you try the commands above with the sync and sleep? – Yaron Jun 16 '17 at 03:43