Monday, November 28, 2011

How to eject an usb storage device like kindle from command line

If you are working with a kindle, trying to convert some books into kindle format, it's frequent to plug and unplug the device to check if the file is rendered correctly.
Doing this with the graphical interface is of course annoying.
Luckily you can easily use the command line (and maybe automate the conversion and copy with a command line application).
First of all you have to find the name of your device using
sudo fdisk -l
You will see an output like this one
Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c83e7
Device Boot      Start         End      Blocks   Id  System
/dev/sda2               1       29179   234374145    5  Extended 
...
Partition table entries are not in disk order
Disk /dev/sdb: 3282 MB, 3282272256 bytes
4 heads, 16 sectors/track, 100167 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      100167     3205336    b  W95 FAT32
Of course the device is sdb1: now you can eject typing
sudo eject /dev/sdb
 to "uneject" a trick is to use the command
sudo eject -t /dev/sdb
which sends a tray close cdrom command, that actually reconnects the kindle. 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.