How is storage on the tablet arranged?
First, storage is split into internal and external. Internal storage consists of a single NAND chip, which in this case is around 4GB capacity total. External storage is on the micro SD card. The internal storage is split into many different partitions, just like a hard drive. These partitions contain things like system, boot, bootloader, recovery etc.
We need to know what is contained in each partition in order to back up and restore them safely. There is some information on partition structure at http://linux-sunxi.org/Android/partitions but I wanted to have a poke around to see what my device is like.
There caused me some confusion. A region of the internal NAND is called the internal SD card and mounted as "sdcard". The actual physical external SD card is called extsd. HOWEVER, when booted into the CWM recovery, it appears to refer to the external SD card as "sdcard"!
The best way of viewing the output from a shell command is to pipe it to a text file, pull the text file to the computer over ADB, then view the text file. For example:
adb shell adb shell "cat /proc/devices > /sdcard/output.txt" adb pull /sdcard/output.txt
This runs the cat /proc/devices command to list system devices and pipes the output to output.txt which can then be viewed later.
Let's see what we can find out. The following is performed on Mum's tablet (the good, original one) with the tablet fully booted up into Android. I'm looking at various files which contain information on devices and partitions.
The output consists of character devices, which we're not interested in, and block devices. Here is the block devices listing:
Block devices: 1 ramdisk 259 blkext 7 loop 8 sd 11 sr 65 sd 66 sd 67 sd 68 sd 69 sd 70 sd 71 sd 93 nand 128 sd 129 sd 130 sd 131 sd 132 sd 133 sd 134 sd 135 sd 179 mmc 254 device-mapper
The numbers are the major device numbers, which are a way of identifying physical storage devices. The two we are interested in are 93 nand and 179 mmc. These correspond to the internal NAND and external SD card (multimedia card), respectively.
This lists all current storage partitions. Output:
major minor #blocks name 93 0 16384 nanda 93 8 16384 nandb 93 16 32768 nandc 93 24 524288 nandd 93 32 1048576 nande 93 40 16384 nandf 93 48 32768 nandg 93 56 262144 nandh 93 64 131072 nandi 93 72 1809408 nandj 179 0 7761920 mmcblk0 179 1 7757824 mmcblk0p1
Note the major device numbers 93 and 179, corresponding to the internal NAND and external SD card. There are a total of 10 partitions on the internal nand, called nanda to nandj, and two on the external SD card. These partitions are all available under /dev/block/ (for example, /dev/block/nanda).
The sizes of each partition are listed in blocks of 1024 bytes each. For example, nanda is 16384*1024=16777216 bytes=16MB in size. If we add up the sizes of each partition in the NAND (major number 93), we get a total of 3890176 blocks, or 3.98GB - i.e. the 4GB internal storage.
Doesn't contain much. Relevant line:
dev_mount sdcard /mnt/sdcard auto /devices/virtual/block/nandj
Suggests that nandj corresponds to sdcard (the internal SD card). Size-wise, this is about 1.8GB.
Output (relevant lines only):
/dev/block/nandd /system ext4 rw,nodev,noatime,user_xattr,barrier=0,data=ordered 0 0 /dev/block/nande /data ext4 rw,nosuid,nodev,noatime,user_xattr,barrier=0,journal_checksum,data=ordered,noauto_da_alloc 0 0 /dev/block/nandh /cache ext4 rw,nosuid,nodev,noatime,user_xattr,barrier=0,journal_checksum,data=ordered,noauto_da_alloc 0 0 /dev/block/vold/179:1 /mnt/extsd vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0 /dev/block/vold/93:72 /mnt/sdcard vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
We can see that nandd is /system, nande is /data and nandh is /cache. The external SD card (identified by major:minor numbers 179:1) is mounted to /mnt/extsd, and the internal SD card (93:72) to /mnt/sdcard. The major:minor numbers confirm that the internal SD card is nandj (compare with with /proc/partitions output).
The df command lists the space usage of current partitions. The busybox version of the command gives a more detailed output:
Filesystem 1K-blocks Used Available Use% Mounted on tmpfs 180968 44 180924 0% /dev tmpfs 180968 0 180968 0% /mnt/asec tmpfs 180968 0 180968 0% /mnt/obb /dev/block/nandd 516040 269540 246500 52% /system /dev/block/nande 1032088 88152 943936 9% /data /dev/block/nandh 258016 4236 253780 2% /cache /dev/block/vold/179:1 7753728 64 7753664 0% /mnt/extsd /dev/block/vold/93:72 1904156 7852 1896304 0% /mnt/sdcard /dev/block/vold/93:72 1904156 7852 1896304 0% /mnt/secure/asec
Another command which gives some very useful information is dmesg (see http://en.wikipedia.org/wiki/Dmesg and http://www.linfo.org/dmesg.html. This lists all messages produced by the kernel during (and sometimes after) startup. Buried in the messages are some on the disk structure. To see these, run this from an adb shell prompt and pull the resulting text file back to the computer for viewing:
dmesg | busybox grep "disk name" > /sdcard/dmesg.txt
The output from dmesg is piped to grep, which displays only those lines containing the text "disk name", and the output from grep is dumped into the dmesg.txt text file. Here's the result:
<4>[ 0.185665] The 0 disk name = bootloader, class name = DISK, disk size = -544396252 <4>[ 0.185684] The 1 disk name = env, class name = DISK, disk size = -544396188 <4>[ 0.185694] The 2 disk name = boot, class name = DISK, disk size = -544396124 <4>[ 0.185704] The 3 disk name = system, class name = DISK, disk size = -544396060 <4>[ 0.185713] The 4 disk name = data, class name = DISK, disk size = -544395996 <4>[ 0.185723] The 5 disk name = misc, class name = DISK, disk size = -544395932 <4>[ 0.185733] The 6 disk name = recovery, class name = DISK, disk size = -544395868 <4>[ 0.185743] The 7 disk name = cache, class name = DISK, disk size = -544395804 <4>[ 0.185752] The 8 disk name = databk, class name = DISK, disk size = -544395740 <4>[ 0.185762] The 9 disk name = UDISK, class name = DISK, disk size = -544395676
Note some oddities. The #8 partition is called "databk", suggesting "data backup". This partition is called "emmc" when booted into CWM recovery. Also note #9 is called UDISK - this is the "internal" SD card, called "sdcard" elsewhere.
Here's a quick summary of the partitions.
Block name Name/purpose Filesystem type ---------- ------------ --------------- nanda bootloader vfat nandb environment raw nandc boot raw nandd system ext4 nande data ext4 nandf misc raw nandg recovery raw nandh cache ext4 nandi emmc ext4 nandj sdcard vfat