Skip to content

How to setup a device

Simone Mutti edited this page Dec 15, 2015 · 2 revisions

This is a complete tutorial on how you can setup a Nexus 5 (Android 5.1.0) 32GB to build your own phone cloud.

##Disclaimer It is your decision to follow this guide on your device. BareDroid team takes no responsibility for any damage that may occur from modifying the partitions on the device.

##Prerequisite

  • Download and install the latest TWRP image file (.img) from the download link and boot TWRP
  • Push the parted utility on the device (you can find a copy here) and make it executable
  • umount /sdcard and /data partitions

##How to use parted parted is a program to manipulate disk partitions. It is useful for creating space for new operating systems, reorganizing disk usage, and copying data to new hard disks.

SYNOPSIS
parted [options] [device [command [options...]...]]

To run parted type the command:

./parted /dev/block/mmcblk0

The device /dev/block/mmcblk0 is where all the partitions of an Android device reside. To note that if you are using another device (e.g., Samsung S4) the name could be different.

If everything went well, a message like this appear:

Using /dev/block/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)

From the parted shell type m to show the menu. Type p to see all the partitions (the below information refers to Nexus 5):

Number Start End Size File system Name
1 524kB 67.6MB 67.1MB fat16 modem
2 67.6MB 68.7MB 1049kB sbl1
3 68.7MB 69.2MB 524kB rpm
4 69.2MB 69.7MB 524kB tz
5 69.7MB 70.3MB 524kB sdi
6 70.3MB 70.8MB 524kB aboot
7 70.8MB 72.9MB 2097kB pad
8 72.9MB 73.9MB 1049kB sbl1b
9 73.9MB 74.4MB 524kB tzb
10 74.4MB 75.0MB 524kB rpmb
11 75.0MB 75.5MB 524kB abootb
12 75.5MB 78.6MB 3146kB modemst1
13 78.6MB 81.8MB 3146kB modemst2
14 81.8MB 82.3MB 524kB metadata
15 82.3MB 99.1MB 16.8MB misc
16 99.1MB 116MB 16.8MB ext4 persist
17 116MB 119MB 3146kB imgdata
18 119MB 142MB 23.1MB laf
19 142MB 165MB 23.1MB boot
20 165MB 188MB 23.1MB recovery
21 188MB 191MB 3146kB fsg
22 191MB 192MB 524kB fsc
23 192MB 192MB 524kB ssd
24 192MB 193MB 524kB DDR
25 193MB 1267MB 1074MB ext4 system
26 1267MB 1298MB 31.5MB crypto
27 1298MB 2032MB 734MB ext4 cache
28 2032MB 31.3GB 29.3GB ext4 userdata

To provide disposable roms we need to create a new userdata partition. The idea is to split the partition 28 to create two new partitions: (i) userdata and (ii) userdata_next.

The following steps can be used to split a partition, not copy and paste but try to understand...

  1. delete the current userdata partition:
    rm 28

  2. check whether the partition was deleted successfully:
    p free

  3. create a new partition using the free space:
    (parted) mkpartfs 1 ext2 2032MB 15.7GB

mkpartfs creates a new partition of type PART-TYPE (first parameter) with a new file system of type FS-TYPE (second parameter) on it. The new partition will start START megabytes (third parameter), and end END megabytes (fourth parameter). To note that mkpartfs does not provide support for ext4 fs-type, just use ext2 and see step 7.

  1. assign a name to the new partition:
    (parted) name 28 userdata

  2. check whether the new partition was created successfully:
    p free

  3. create the userdata_next partition:
    (parted) mkpartfs 1 ext2 15.7GB 29.4GB

  4. assign a name to the new partition:
    (parted) name 29 userdata_next

  5. create the store partition. It stores the initial snapshot of the userdata partition to speedup the restore process:
    (parted) mkpartfs 1 ext2 29.4GB 31.3GB

  6. assign a name to the new partition:
    (parted) name 30 store

  7. exit from parted:
    (parted) q

  8. reboot the device in recovery mode

  9. umount /sdcard and /data partitions

  10. change the userdata and userdata_new fs-type from ext2 to ext4:
    make_ext4fs /dev/block/mmcblk0p28 /data
    make_ext4fs /dev/block/mmcblk0p29 /data

  11. reboot in bootloader mode and flash a clean image of the userdata partition, take it from here

Clone this wiki locally