particiones tablet

Upload: kpocha2009

Post on 04-Jun-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 Particiones Tablet

    1/13

    Partitions - detailed look at each one

    Jump to section:

    Introduction - dumping partitionsFile and partition sizesReferencesMounting an image

    /dev/block/nanda - bootloader /dev/block/nandb - env /dev/block/nandc - boot /dev/block/nandd - system /dev/block/nande - data /dev/block/nandf - misc /dev/block/nandg - recovery /dev/block/nandh - cache /dev/block/nandi - emmc (a.k.a. databk) /dev/block/nandj - sdcard

    Introduction - dumping partitions

    This is a ll done on Mum's tablet , which has the original firmware on it. I had been using it for awhile, so there will be additional applications and data present. First, let's dump each partition fromthe devic e on to an SD card. Insert a blank SD card (at least 4GB - this will take up a lot of space),boot up i nto Android, connect to the c omputer, then run the following ADB commands:

    adb kill-serveradb devicesadb shell "cat /dev/block/ nanda > /mnt/extsd/nanda.img"adb shell "cat /dev/bloc k/nandb > /mnt/extsd/nandb.img"adb shell "cat /dev/blo ck/nandc > /mnt/extsd/nandc.img"adb shell "cat /dev/block/nan dd > /mnt/extsd/nandd.img"adb shell "cat /dev/ block/nande > /mnt/extsd/nande.img"adb shell "ca t /dev/block/nandf > /mnt/extsd/nandf.img"adb shell "cat /dev/blo ck/nandg > /mnt/extsd/nandg.img"adb shell "cat /dev/block/nandh > /mnt/extsd/nandh.img"adb shell "cat /dev/block/nandi > /mnt/extsd/nandi.img"adb shell "cat /dev/block/nandj > /mnt/extsd/nandj.img"

    (These commands could be put into a batch file.) After 5-10min, you should now have image filescorresponding to each of the 10 partitions. Transfer these over to a USB stick - more useful later.

    File and partition sizes

    Here's the contents of /proc/partitions on the tablet. The sizes are in blocks , where on block = 1024bytes.

    major minor #blocks name 93 0 16384 nanda 93 8 16384 nandb 93 16 32768 nandc 93 24 524288 nandd

    http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-http://-/?-
  • 8/13/2019 Particiones Tablet

    2/13

    93 32 1048576 nande 93 40 16384 nandf 93 48 32768 nandg 93 56 262144 nandh 93 64 131072 nandi 93 72 1809408 nandj

    Next, here's the sizes (in bytes) of each of the image files, obtained using ls -l on Linux:

    lindsay@lindsay-Vostro1310:~$ ls -ltotal 3983540224-rw-r--r-- 1 lindsay lindsay 16777216 Jan 4 12:43 nanda.img-rw-r--r-- 1 lindsay lindsay 16777216 Jan 4 12:43 nandb.img-rw-r--r-- 1 lindsay lindsay 33554432 Jan 4 12:43 nandc.img-rw-r--r-- 1 lindsay lindsay 536870912 Jan 4 12:46 nandd.img-rw-r--r-- 1 lindsay lindsay 1073741824 Jan 4 12:50 nande.img-rw-r--r-- 1 lindsay lindsay 16777216 Jan 4 12:50 nandf.img-rw-r--r-- 1 lindsay lindsay 33554432 Jan 4 12:50 nandg.img-rw-r--r-- 1 lindsay lindsay 268435456 Jan 4 12:51 nandh.img-rw-r--r-- 1 lindsay lindsay 134217728 Jan 4 12:52 nandi.img-rw-r--r-- 1 lindsay lindsay 1852833792 Jan 4 12:58 nandj.img

    In order to compare this with the partition sizes, we need to display the file sizes in blocks as well.This can be done using the --block-size=1024 switch:

    lindsay@lindsay-Vostro1310:~$ ls -l --block-size=1024total 3890192-rw-r--r-- 1 lindsay lindsay 16384 Jan 4 12:43 nanda.img-rw-r--r-- 1 lindsay lindsay 16384 Jan 4 12:43 nandb.img-rw-r--r-- 1 lindsay lindsay 32768 Jan 4 12:43 nandc.img-rw-r--r-- 1 lindsay lindsay 524288 Jan 4 12:46 nandd.img-rw-r--r-- 1 lindsay lindsay 1048576 Jan 4 12:50 nande.img-rw-r--r-- 1 lindsay lindsay 16384 Jan 4 12:50 nandf.img-rw-r--r-- 1 lindsay lindsay 32768 Jan 4 12:50 nandg.img-rw-r--r-- 1 lindsay lindsay 262144 Jan 4 12:51 nandh.img

    -rw-r--r-- 1 lindsay lindsay 131072 Jan 4 12:52 nandi.img-rw-r--r-- 1 lindsay lindsay 1809408 Jan 4 12:58 nandj.img

    Comparing these with the partition sizes from /proc/partitions, we can see that they are exactly thesame, as expected.

    References

    Here's some good references on partitions:

    http://androidforums.com/evo-4g-all-things-root/278898-android-partitions-kernels-

    explained.htmlhttp://androidforums.com/evo-4g-all-things-root/279261-more-information-about-android-partitions.htmlhttp://www.addictivetips.com/mobile/android-partitions-explained-boot-system-recovery-data-cache-misc/

    Mounting an image as a filesystem under Linux

    Some of the partition images are filesystems which can be directly mounted under Linux. This takesa wee bit of trickery. As an example, we'll use the nanda.img image file. All this is done under Ubuntu 12.04.

    First, copy the image file to the Linux machine - I put it on the desktop (i.e. under /home/lindsay/Desktop).

    Next, make a new directory on the desktop - for example, nanda . This will be the mount point for

    http://www.addictivetips.com/mobile/android-partitions-explained-boot-system-recovery-data-cache-misc/http://androidforums.com/evo-4g-all-things-root/279261-more-information-about-android-partitions.htmlhttp://androidforums.com/evo-4g-all-things-root/278898-android-partitions-kernels-explained.html
  • 8/13/2019 Particiones Tablet

    3/13

    the image file.

    To enable read/write permissions on the mounted image, we need to know the user id (UID) andgroup id (GID) of the current user. This is done using the id command:

    lindsay@lindsay-Vostro1310:~$ iduid=1000(lindsay) gid=1000(lindsay) groups=1000(lindsay),4(adm),24(cdrom),27

    So, the UID is 1000, and the GID is 1000.

    We're now ready to mount the device. Run the following command (see here ):

    sudo mount -o loop,uid=1000,gid=1000 -t vfat nanda.img nanda

    This mounts the nanda.img file, with the directory nanda as the mount point. The -t switchspecified a vfat filesystem, and the -o specifies the UID and GID options (so you can read & writeto the filesystem). Browse the nanda folder - you'll see the whole filesystem and can add or removefiles as required.

    Once finished, unmount the image with the following:

    sudo umount nanda

    The nanda.img image file, although remaining the same size, will contain the updated filesystem.

    Let's take a look at the partitions.

    /dev/block/nanda - bootloader

    This is the very first partition which the processor looks at on startup. Mount using

    sudo mount -o loop,uid=1000,gid=1000 -t vfat nanda.img nanda

    Here's the contents of the image:

    http://superuser.com/questions/196653/how-do-i-manually-mount-a-linux-file-system-read-write-as-a-normal-user
  • 8/13/2019 Particiones Tablet

    4/13

    Some interesting stuff. script.bin is the configuration file used by the A13 processor when firststarting (see here , although that's for an A10). boot.axf appears to be Allwinner's own bootloader,which can then load u-boot (contained inside the linux directory).

    Click here for a tree listing of all files and directories in the image (obtained using the sudo tree -Fcommand).

    Here's the contents of the linux directory:

    And the contents of linux.ini :

    [segment]img_name = c:\linux\u-boot.binimg_size = 0x80000img_base = 0x4A000000

    [script_info]script_base = 0x43000000script_size = 0x10000

    [logo_info]logo_name = c:\linux\linux.bmplogo_show = 1

    http://www.imajeenyus.com/computer/20130301_android_tablet/android/partitions_detailed/nanda-tree.txthttp://rhombus-tech.net/allwinner_a10/a10_boot_process/
  • 8/13/2019 Particiones Tablet

    5/13

    This says to use the u-boot bootloader. To change the small square logo shown first on startup, justreplace the linux.bmp image with another of the same kind (32-bit colour).

    The os_show directory contains various images used by the bootloader, mainly battery chargingsymbols.

    /dev/block/nandb - env

    This partition is a bit of a mystery. Very little information is available on it.

    It appears to be related to the u-boot bootloader (which is located on /dev/block/nanda). Accordingto here , it is the environment to assist u-boot .

    Some more information is available here :

    Many embedded devices these days use the U-Boot bootloader. This bootloader stores itsconfiguration into an area of the flash called the environment that can be manipulated from within U-Boot using the printenv, setenv and saveenv commands, or from Linux using the fw_printenv and fw_setenv userspace utilities provided with the U-Boot source code. This environment is typically stored in a specific flash location, defined in the board configuration header in U-Boot. Theenvironment is basically stored as a sequence of null-terminated strings, with a little header containing a checksum at the beginning.

    And more, from here :

    Many embedded devices these days use the U-Boot bootloader. This bootloader stores itsconfiguration into an area of the flash called the environment......

    Yet another hint is in the COMMON_SYS_CONFIG000000.fex file which can be unpacked from thestock ROM. In it, various partitions are listed, and this one is called "environment for u-boot".

    Going through the file. We first have, from 0x4 to 0x1D6, some text with the NUL char signifying

    end of line:

    bootdelay=2bootcmd=run setargs boot_normalconsole=ttyS0,115200nand_root=/dev/nandcmmc_root=/dev/mmcblk0p4init=/initloglevel=8setargs=setenv bootargs console=${console} root=${nand_root} init=${init} loboot_normal=nand read 40007800 boot;boota 40007800boot_recovery=nand read 40007800 recovery;boota 40007800boot_fastboot=fastboot

    recovery_key_value_max=0x13recovery_key_value_min=0x10fastboot_key_value_max=0x8fastboot_key_value_min=0x2

    All 00 until 0x1F4D5 to 0x2016C. Some gibberish first , but then we have the text (from 0x2004 to0x2016C):

    bootdelay=3bootcmd=run setargs boot_normalconsole=ttyS0,115200

    nand_root=/dev/nanddmmc_root=/dev/mmcblk0p7init=/initloglevel=8setargs=setenv bootargs console=${console} root=${mmc_root} init=${init} logboot_normal=mmc read 40007800 22000 10000;boota 40007800

    http://free-electrons.com/blog/mkenvimage-uboot-binary-env-generator/http://free-electrons.com/blog/mkenvimage-uboot-binary-env-generator/http://linux-sunxi.org/Android/partitions
  • 8/13/2019 Particiones Tablet

    6/13

  • 8/13/2019 Particiones Tablet

    7/13

    Note that the uid=1000,gid=1000 doesn't apply to an ext4 filesystem, so it will be mounted read-only. To add/remove any files from it, you'll either need to do it with sudo at the shell prompt, or (more dangerous) start a superuser session of your file manager - e.g. sudo nautilus .

    Here's the contents:

    Click here for a tree listing. Notice the build.prop file - this contains details about the tablet.

    Description of this partition (from here ):

    This partition basically contains the entire operating system, other than the kernel and the ramdisk.This includes the Android user interface as well as all the system applications that come pre-installed on the device. Wiping this partition will remove Android from the device without rendering it unbootable, and you will still be able to put the phone into recovery or bootloader mode to install anew ROM.

    /dev/block/nande - data

    Mount using:

    sudo mount -o loop -t ext4 nande.img nande

    Screenshot of the contents:

    http://www.addictivetips.com/mobile/android-partitions-explained-boot-system-recovery-data-cache-misc/http://www.imajeenyus.com/computer/20130301_android_tablet/android/partitions_detailed/nandd-tree.txt
  • 8/13/2019 Particiones Tablet

    8/13

    Click here for a tree listing.

    Description of this partition (from here ):

    Also called userdata, the data partition contains the users data this is where your contacts ,messages, settings and apps that you have installed go. Wiping this partition essentially performs afactory reset on your device, restoring it to the way it was when you first booted it, or the way it wasafter the last official or custom ROM installation. When you perform a wipe data/factory reset fromrecovery, it is this partition that you are wiping.

    /dev/block/nandf - misc

    According to here :This partition contains miscellaneous system settings in form of on/off switches. These settingsmay include CID (Carrier or Region ID), USB configuration and certain hardware settings etc. This isan important partition and if it is corrupt or missing, several of the devices features will will not function normally.

    And here :

    Partition used to pass data amongst various stages of the boot chain (e.g. boot into recovery mode,fastboot etc)

    However, it appears that this partition isn't used for this purpose on my tablets. The nandf image fileseems to contain just a few large blocks of 0x00 or 0xFF. Here's a summary of the contents of theimage file obtained from a variety of different situations. I also did a test to see what, if anything, iswritten to the partition. Text descriptions first, then an image.

    http://linux-sunxi.org/Android/partitionshttp://www.addictivetips.com/mobile/android-partitions-explained-boot-system-recovery-data-cache-misc/http://www.addictivetips.com/mobile/android-partitions-explained-boot-system-recovery-data-cache-misc/http://www.imajeenyus.com/computer/20130301_android_tablet/android/partitions_detailed/nande-tree.txt
  • 8/13/2019 Particiones Tablet

    9/13

    1. From original good tablet (Mum's). 0x00 from offset 0x0 to 0x43F, then 0xFF from 0x440 to0xFFFFFF.

    2. Also from original good tablet, but can't remember how I obtained this. 0xFF from 0x0 to0x1FF, 0x00 from 0x200 to 0x43F, then 0xFF from 0x440 to 0xFFFFFF.

    3. Totally random. I created an image file with totally random bytes throughout and flashed this tonandf on the testing tablet.

    4. Random image, after booting into Android. Booted the testing tablet into Android. nandf isidentical to the random image - no change.

    5. Random image, after rebooting into CWM recovery. Next booted into CWM recovery. Somechange - 0xFF from 0x00 to 0x1FF, remainder random as before.

    6. Random image, after rebooting into Android again. No change from before.

    To make all this eaiser to visualise, here's a graphical representation of each image file. Eachimage shows the first 3200 bytes, arranged in 16x200 pixels, with the grayscale valuecorresponding to the byte.

    It would appear that this partition is somehow written to by the tablet, so I would guess there is noneed to back up this partition, so long as it exists.

    /dev/block/nandg - recovery

    This contains the recovery partition. It cannot be mounted as-is, since it contains both a kernel andramdisk. It has to be split up using the technique described on my other page " Unpacking and

    repacking CWM recovery image ". After using unmkbootimg and gunzip , we end up with thefollowing ramdisk contents:

    http://www.imajeenyus.com/computer/20130301_android_tablet/android/unpack_repack_recovery_image.html
  • 8/13/2019 Particiones Tablet

    10/13

    Click here for the tree structure.

    This is very similar to the CWM recovery ramdisk, with slight differences (e.g. fewer images in theres/images directory, and a different init binary). This is because the recovery is a stock recoverypartition. The contents of this partition are also very similar to the boot (nandc) partition, since italso contains a kernel and ramdisk.

    Description of this partition (from here ):

    The recovery partition can be considered as an alternative boot partition that lets you boot thedevice into a recovery console for performing advanced recovery and maintenance operations on it.

    /dev/block/nandh - cache

    Mount with

    sudo mount -o loop -t ext4 nandh.img nandh

    Contents:

    http://www.addictivetips.com/mobile/android-partitions-explained-boot-system-recovery-data-cache-misc/http://www.imajeenyus.com/computer/20130301_android_tablet/android/partitions_detailed/nandg-ramdisk-tree.txt
  • 8/13/2019 Particiones Tablet

    11/13

    Click here for a tree listing.

    The only interesting file is recovery/last_log - click here to see it. It appears to be a log of everything which happened the last time the tablet was booted into recovery mode.

    Description of this partition (from here ):

    This is the partition where Android stores frequently accessed data and app components. Wiping the cache doesnt effect your personal data but simply gets rid of the existing data there, whichgets automatically rebuilt as you continue using the device.

    /dev/block/nandi - emmc (a.k.a. databk)

    This partition is called emmc when booted into CWM recovery, and is called databk when you lookat the dmesg log from the booted Android system. Mount using:

    sudo mount -o loop -t ext4 nandi.img nandi

    Here's a screenshot of the root directory:

    Click here for a tree listing.

    Not much interesting there - what's data_backup.tar though? Let's copy it out and extract it - itproduces a folder called data , which contains:

    http://www.imajeenyus.com/computer/20130301_android_tablet/android/partitions_detailed/nandi-tree.txthttp://www.addictivetips.com/mobile/android-partitions-explained-boot-system-recovery-data-cache-misc/http://www.imajeenyus.com/computer/20130301_android_tablet/android/partitions_detailed/nandh-last_log.txthttp://www.imajeenyus.com/computer/20130301_android_tablet/android/partitions_detailed/nandh-tree.txt
  • 8/13/2019 Particiones Tablet

    12/13

    Click here for tree listing.

    This would appear to be a complete backup copy of the data partition (hence the name databk inthe dmesg output). When or how it was created, I'm not sure - perhaps the last time recovery modewas started. Since it is a backup copy, I would imagine that this partition (emmc) could be wipedwithout any problems.

    Further confirmation that this is a backup of the data partition comes again from theCOMMON_SYS_CONFIG000000.fex file, where it's called "data image backup". I don't quite seehow it could be a complete backup, since the emmc partition is much smaller than the datapartition.

    /dev/block/nandj - sdcard

    This is the "internal" SD card, used for storing user files, pictures, videos etc. Mount using

    sudo mount -o loop,uid=1000,gid=1000 -t vfat nandj.img nandj

    Here's a screenshot of the root directory:

    http://www.imajeenyus.com/computer/20130301_android_tablet/android/partitions_detailed/nandi-data-tree.txt
  • 8/13/2019 Particiones Tablet

    13/13

    Click here for a tree listing of all files and directories.

    Description of this partition (from here ):

    This is not a partition on the internal memory of the device but rather the SD card. In terms of usage, this is your storage space to use as you see fit, to store your media, documents, ROMs etc.on it. Wiping it is perfectly safe as long as you backup all the data you require from it, to your computer first. Though several user-installed apps save their data and settings on the SD card and wiping this partition will make you lose all that data. On devices with both an internal and anexternal SD card devices like the Samsung Galaxy S and several tablets the /sdcard

    partition is always used to refer to the internal SD card. For the external SD card if present an alternative partition is used, which differs from device to device. In case of Samsung Galaxy S series devices, it is /sdcard/sd while in many other devices, it is /sdcard2. Unlike /sdcard, nosystem or app data whatsoever is stored automatically on this external SD card and everything

    present on it has been added there by the user. You can safely wipe it after backing up any datafrom it that you need to save.

    Back to index

    http://www.imajeenyus.com/computer/20130301_android_tablet/android/index.htmlhttp://www.addictivetips.com/mobile/android-partitions-explained-boot-system-recovery-data-cache-misc/http://www.imajeenyus.com/computer/20130301_android_tablet/android/partitions_detailed/nandj-tree.txt