Kindle 3’s FLASH file system layout

This post briefly summarises my findings when poking around the file systems on the FLASH of my Kindle 3.

Overall layout

With USB networking enabled, it is easy enough to login remotely and poke around. The entire internal FLASH drive is /dev/mmcblk0, so we can use fdisk to print the partition table.

[root@kindle tests]# fdisk /dev/mmcblk0

The number of cylinders for this disk is set to 122112.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): m
Command Action
a       toggle a bootable flag
b       edit bsd disklabel
c       toggle the dos compatibility flag
d       delete a partition
l       list known partition types
n       add a new partition
o       create a new empty DOS partition table
p       print the partition table
q       quit without saving changes
s       create a new empty Sun disklabel
t       change a partition's system id
u       change display/entry units
v       verify the partition table
w       write table to disk and exit
x       extra functionality (experts only)

Command (m for help): p

Disk /dev/mmcblk0: 4001 MB, 4001366016 bytes
4 heads, 16 sectors/track, 122112 cylinders
Units = cylinders of 64 * 512 = 32768 bytes

        Device Boot      Start         End      Blocks  Id System
/dev/mmcblk0p1   *         121       20921      665628  83 Linux
/dev/mmcblk0p2           20922       21689       24576  83 Linux
/dev/mmcblk0p3           21690       21945        8192  83 Linux
/dev/mmcblk0p4           21946      122112     3205344   b Win95 FAT32

Command (m for help): q

[root@kindle tests]#

So, this is a 4GB FLASH drive, with ~1GB for the Linux firmware (mostly /dev/mmcblk0p1) and 3G for a FAT32-formatted partition (/dev/mmcblk0p4) that holds user content. /dev/mmcblk0p4 is exposed to the outside world when the K3 is acting as a USB mass storage device.

The contents of /etc/fstab reveals how the file systems are intended to be established each time the K3 boots.

[root@kindle tests]# more /etc/fstab
# /etc/fstab: static file system information.
# <file system>   <mount pt>    <type> <options>                                         <dump>  <pass>
/dev/mmcblk0p1    /             ext3   suid,exec,auto,nouser,async,rw,noatime,nodiratime 0      1
proc              /proc         proc   defaults                                          0      0
sysfs             /sys          sysfs  defaults                                          0      0
devpts            /dev/pts      devpts defaults,gid=5,mode=620                           0      0
usbfs             /proc/bus/usb usbfs  defaults                                          0      0
/dev/loop/0       /mnt/base-us  vfat   defaults,noatime,nodiratime,utf8,noexec,shortname=mixed              0      0
/dev/mmcblk1p1    /mnt/base-mmc vfat   defaults,noatime,nodiratime,utf8,noexec,shortname=mixed              0      0
fsp#/mnt/base-us  /mnt/us       fuse   rw,max_write=65536,max_readahead=65536,noatime,exec,nosuid,nodev     0      0
fsp#/mnt/base-mmc /mnt/mmc      fuse   rw,max_write=65536,max_readahead=65536,noatime,exec,nosuid,nodev     0      0
[root@kindle tests]#

mounted file systems
The firmware primarily resides on /dev/mmcblk0p1, with /dev/mmcblk0p2 used for /var/local

[root@kindle root]# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/mmcblk0p1          646.8M    483.5M    137.4M  78% /
tmpfs                   125.3M     20.0k    125.2M   0% /dev
rwfs                     32.0M    216.0k     31.8M   1% /mnt/rwfs
shm                     125.3M         0    125.3M   0% /dev/shm
rwfs                     32.0M    216.0k     31.8M   1% /var
/dev/mmcblk0p2           23.2M      1.5M     20.6M   7% /var/local
fsp                       3.1G    775.2M      2.3G  25% /mnt/us
/dev/loop/0               3.1G    775.2M      2.3G  25% /mnt/base-us
[root@kindle root]#
[root@kindle root]# mount
rootfs on / type rootfs (rw)
/dev/root on / type ext3 (ro,noatime,nodiratime,data=ordered)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
tmpfs on /dev type tmpfs (rw,mode=755)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
rwfs on /mnt/rwfs type tmpfs (rw,size=32768k)
shm on /dev/shm type tmpfs (rw)
rwfs on /var type tmpfs (rw,size=32768k)
/dev/mmcblk0p2 on /var/local type ext3 (rw,sync,errors=continue,data=ordered)
fsp on /mnt/us type fuse.fsp (rw,nosuid,nodev,noatime,user_id=0,group_id=0)
/dev/loop/0 on /mnt/base-us type vfat (rw,noexec,noatime,nodiratime,fmask=0022,dmask=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8)
[root@kindle root]#

Backups of the two main partitions

Just in case I bork something, make backups of the two main firmware disk partitions using dd onto the FAT32 partition.

[root@kindle root]#
[root@kindle root]# dd if=/dev/mmcblk0p1 of=/mnt/us/mmcblk0p1.dd bs=1M &
[root@kindle root]#
[root@kindle root]# dd if=/dev/mmcblk0p2 of=/mnt/us/mmcblk0p2.dd bs=1M &
[root@kindle root]#

I could have now ejected the K3, remounted it as a mass storage device and copied the two .dd files off. However, rsync is installed by the USB Networking (usbnet) hack:

[root@kindle root]# ls -al /usr/bin/rsync
lrwxrwxrwx    1 root     root           24 Nov  3  2010 /usr/bin/rsync -> /mnt/us/usbnet/bin/rsync
[root@kindle root]#

So it seemed easier to simply rsync the files back to my main desktop:

[gja@gjadesktop]/home/gja(111)% rsync -av --progress root@ kindle-mmcblk0p2.dd

Welcome to Kindle!

root@'s password:
receiving incremental file list
    25165824 100%    1.01MB/s    0:00:23 (xfer#1, to-check=0/1)

sent 30 bytes  received 25168978 bytes  853186.71 bytes/sec
total size is 25165824  speedup is 1.00


[gja@gjadesktop]/home/gja(112)% rsync -av --progress root@ kindle-mmcblk0p1.dd

Welcome to Kindle!

root@'s password:
receiving incremental file list
   681603072 100%    1.86MB/s    0:05:49 (xfer#1, to-check=0/1)

sent 30 bytes  received 681686358 bytes  1830030.57 bytes/sec
total size is 681603072  speedup is 1.00

The larger image (mmcblk0p1.dd) allowed the rsync to achieve a higher overall goodput (1.86MByte/sec).


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: