View Single Post
Old 07-20-2011, 07:40 PM   #17
yifanlu
Kindle Dissector
yifanlu ought to be getting tired of karma fortunes by now.yifanlu ought to be getting tired of karma fortunes by now.yifanlu ought to be getting tired of karma fortunes by now.yifanlu ought to be getting tired of karma fortunes by now.yifanlu ought to be getting tired of karma fortunes by now.yifanlu ought to be getting tired of karma fortunes by now.yifanlu ought to be getting tired of karma fortunes by now.yifanlu ought to be getting tired of karma fortunes by now.yifanlu ought to be getting tired of karma fortunes by now.yifanlu ought to be getting tired of karma fortunes by now.yifanlu ought to be getting tired of karma fortunes by now.
 
Posts: 662
Karma: 475607
Join Date: Jul 2010
Device: Amazon Kindle 3
Quote:
Originally Posted by DickeFix View Post
Yifanlu, thank you for another great Kindle hack! It feels great to have a backup of the Kindle 3 and possibility to recover if necessary.

However, I would like to better understand the Kindle file system. Could you please let me know if the following is correct?

Partition 1 (650 MB): Is this the entire operative system? I guess this corresponds to rootfs.img that one obtains running your prepare_kindle.bin on system 2.5.8 on DXG. As you have pointed out before it is larger (650 MB) on Kindle 3 compared to Kindle 2/DX/DXG (400 MB)

Partition 2 (24 MB): Is this the current values of the local variables? Is it necessary to backup this or are these variables initialized automatically if they are missing?

Partition 3 (8 MB): Is this the kernel that is used for booting and recovery?

Partition 4 (>3GB): Is this identical with the USB-partition you see when you plug it in?

I have also two questions how one can edit the content of these partitions on a Windows computer.

1. I have not yet tried USB networking. Does it give full control with possibility to read and write on all four partitions?

2. Another method is to take a partition, modify it on the computer and send it back to the device. Why canīt this be done directly as an .img file? Why is it necessary to first compress it, sign it and transfer it as an upgrade .bin file?

I am a real newbie in Linux but found a nifty freeware Windows program Explore2fs that allows you to explore the file system and read the content on partition 1 and 2 (by right-clicking on the file and View it in e.g. Wordpad). Do you know a Windows program that can mount the image files for both read and write?
Partition 1 is the linux filesystem (mounted at /). Aka, OS files & tools, the framework that you see, and all the hacks you install are here.
Partition 2 is mounted at /var/local and is all the settings for your kindle. In addition, your Kindle certificate (what identifies your kindle and is the thing that gets sent to amazon when you buy a book, not a password), ads, etc. It's the thing that makes your Kindle unique (other then your books). Doing a "reset" literally just formats this partition.
Partition 3 does not exist on all kindles (some only have 1,2,4). It's the linux swap space (I'm 99% sure of that).
Partition 4 is vfat, and where all your books are.

The kernel and bootloader are stored on the nand, but are not mounted as partitions. /dev/mmcblk0 starts late in the nand. The first few bytes of the raw nand is your serial number and boardid and stuff. Then some space for the bootloader (and second bootloader on the K2/DX). Then the kernel and second kernel (on k2/dx) and so on. So, if you nuke /dev/mmcblk0, you won't destroy the kernel nor the bootloader. So basically, the only way to truly brick the kindle is to erase the first thousand or so bytes of the nand, and I don't know if you can do that from linux.

If you use usbnetworking, you can use putty to SSH into the Kindle. Then you have a linux shell that you can do stuff like "dd if=/dev/mmcblk0p2 of=/mnt/us/vars.img bs=1024" to backup your /var/local partition. You can also access the partition directly by cd-ing to /var/local, as that's where partition 2 is mounted.

Sending an .img ONLY works with Partition 1 (rootfs). It works because Amazon's recovery script is designed to do so. When the Kindle is fresh out of the press, I'm pretty sure only the bootloader and kernel is pre-flashed on the device. Before shipping, or sometime before that, Amazon loads the OS as a recovery bin. That way, you get the most up-to-date firmware. However, this bin has to be signed. I just replaced the signature with the jailbreak signature, so we can sign our own recovery packages. It's a package because it can also flash/update the bootloader and kernel, but we don't want to touch those.

If you're having trouble access the partition on Windows, it's pretty easy to burn a linux live cd or live USB stick. Damn small linux is like 50MB if you don't want to download an entire cd.
yifanlu is offline   Reply With Quote