2

I am trying to safely remove my Kindle from the command line but, so far, all my attempts have left the Kindle in "USB Drive Mode". This is not the case when I have safely removed the Kindle via the Nautilus file manager.

My first attempt:

#!/bin/bash

sync
udisks --unmount /dev/sdb1

If I follow through with this command:

udisks --detach /dev/sdb

then I get this error:

Detach failed: Error detaching: helper exited with exit code 1: Detaching device /dev/sdb
USB device: /sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2)
SYNCHRONIZE CACHE: OK
STOP UNIT: FAILED: No such file or directory

Instead of udisks, I have also tried eject:

#!/bin/bash

eject /dev/sdb1

but I get this error:

eject: unable to open `/dev/sdb'

and the Kindle gets disconnected, but stays in "USB Drive Mode".

  • what does "umount -v /dev/sdb" or "umount -v /dev/sdb1" do for you? oh... wait, "gets disconnected, but not powered off" ? behavior of a device upon dismounting from a host is a matter left up to the device, and i believe a kindle actually "lights up" upon being dismounted. – Theophrastus Mar 3 '16 at 0:26
  • umount -v /dev/sdb fails with umount: /dev/sdb: not mounted, whereas umount -v /dev/sdb1 achieves the same partial unmount as udisks. – Elena Mar 3 '16 at 0:43
  • i've never heard of a partial dismount. i humbly suspect that your "partial unmount" is as unmounted as your host computer can manage. (and we now 'know' that your kindle has at least one partition). besides, do we ever or often "power off" a kindle? it does that itself after some period of time. – Theophrastus Mar 3 '16 at 0:49
  • By "partial", I meant that the system unmounts the Kindle, but the Kindle stays in "USB Drive Mode". If I eject the Kindle from Nautilus, the Kindles leaves "USB Drive Mode". Therefore Nautilus does something more than simply unmounting the Kindle. – Elena Mar 3 '16 at 0:58
  • well i've hereby received some education. there is at least one odd difference between umount and eject even for a usb device (eject originally meant open the optical CD tray afterwards, but what should that mean to a usb device?): it sends a SCSI eject signal even to USB, and some devices - including a kindle (?) respond to that. so: eject /dev/sdb1 should maybe do what Nautilus does (maybe) – Theophrastus Mar 3 '16 at 6:00
1

I'm not sure why it didn't work for you, but

eject /dev/sdb1

worked fine for me. You may need to run it as root.

It seemed to unmount it as well.

0
diskutil eject /volumes/kindle

works very well for me. (Using the /volumes/DeviceName format avoids having to do a complicated script to extract the actual specifier from /dev.)

  • AFAIK, diskutil is an OS X program. Is it available for Linux, too? which diskutil returns nothing, and so does apt-cache search diskutil (the latter command searches into Debian's repositories). – Elena Jan 3 '17 at 3:02
  • You are correct that diskutil is an Apple program (per commandlinemac.blogspot.com/2008/12/using-diskutil.html . I don't have access to Linux, but the eject command does look like the right thing to try. Sorry I can't help more. – Irl Concord Jan 16 '17 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.