Cyanogenmod 12 Nightly Upgrade

In September, 2015, I decided to upgrade my aging Sony Xperia T Android phone to Cyanogenmod. The latest stable release at the time was CM11, but I opted to go for the experimental CM12 nightly builds instead. It may not be for the faint of heart, but I've been very happy with the switch now that it's done. One small wrinkle on the process was that I wanted to upgrade the app storage on the phone now that I was wiping it anyway. It is a 16GB device, but due to the device, the factory setup allocates only 2GB for app storage, and I'd run out.

Prerequisites

  • Make a backup! EVERYTHING will be wiped from your phone - especially if you, like me, want to resize your storage partitions.
  • An unlocked bootloader. The procedure for unlocking involves getting a code from Sony, and can be found on the Cyanogenmod install page
  • The Android SDK installed on a computer connected to your phone. We will be using the adb tool in particular.

Installing Cyanogenmod Recovery

At first, I experimented with rooting the phone and installing ClockworkMod recovery for backup purposes, but all the rootkits I found for my current ROM resulted in a boot loop, so I ended up ditching the idea. If your Xperia T ends up in a boot loop (soft brick) state, there may be no other way out than go back to a stock ROM and try again. For this purpose, I ended up using Flashtool and selecting an Xperia T ROM from their list. The instructions for doing the flashing itself is available with casual googling.

Back to square one, I went backed up whatever I could with an off-the-shelf Android app and proceeded. At this point, make sure that the USB Developer option is enabled in your phone's settings and that the computer you will be working from is authenticated for access.

Basically, follow the instructions at the Cyanogenmod wiki page for Xperia T (“mint”) installation until you've reached the point where you've flashed the boot.img file onto the phone. Reboot the phone into recovery mode and connect the USB cable.

Resizing Partitions

At this point, we need to put some partitioning tools onto the phone to manage the resizing of the app storage. I had to google a bit for this, and ended up at this guide which has a sendspace link about one page down. That link gives you a package with six tools that need to be pushed to your phone with adb:

$ ./adb push parted /sbin/
etc. Not all of the tools from this archive worked on my phone, but parted worked well enough to delete and create partitions, which was what I needed at first. My initial partion layour was thusly:
$ ./adb shell
shell@mint:/ $ su
root@mint:/ # /sbin/sdparted /dev/block/mmcblk0
(parted) print                                                            
print
Model: MMC SEM16G (sd/mmc)
Disk /dev/block/mmcblk0: 15.9GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name        Flags
 1      131kB   2228kB  2097kB               TA
 2      2228kB  3801kB  1573kB               Boot
 3      3801kB  5374kB  1573kB               Boot2
 4      6291kB  27.3MB  21.0MB               Kernel
 5      27.3MB  28.3MB  1049kB               TZ
 6      29.4MB  32.5MB  3146kB               modemst1
 7      33.6MB  36.7MB  3146kB               modemst2
 8      37.7MB  40.9MB  3146kB               fsg
 9      40.9MB  46.1MB  5243kB               ramdump
10      46.1MB  54.5MB  8389kB  ext4         apps_log
11      54.5MB  71.3MB  16.8MB               FOTAKernel
12      71.3MB  1359MB  1288MB  ext4         System
13      1359MB  1621MB  262MB   ext4         Cache
14      1621MB  3769MB  2147MB  ext4         Userdata
15      3769MB  15.6GB  11.9GB  ext4         SDCard
(this partition dump is from the fdisk tool, which, for me, would print but not edit my partition table.) Note in particular the Userdata partition, which is the one I wanted to increase in size. Fortunately, the only partition after it on the disk is the huge (and largely empty) SDCard partition, which we will be “stealing” the new app storage from. Now, use the newly-uploaded parted tool to delete the last two partitions (14 and 15) and re-create them with a different layout:

(… to come…)

My new partition layout is this:

$ ./adb shell
shell@mint:/ $ su
root@mint:/ # fdisk -l /dev/block/mmcblk0                                      
Found valid GPT with protective MBR; using GPT

Disk /dev/block/mmcblk0: 31105024 sectors, 2900M
Logical sector size: 512
Disk identifier (GUID): 98101b32-bbe2-4bf2-a06e-2bb33d000c20
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 31104990

Number  Start (sector)    End (sector)  Size       Code  Name
   1             256            4351       2048K   0700  TA
   2            4352            7423       1536K   0700  Boot
   3            7424           10495       1536K   0700  Boot2
   4           12288           53247       20.0M   0700  Kernel
   5           53248           55295       1024K   0700  TZ
   6           57344           63487       3072K   0700  modemst1
   7           65536           71679       3072K   0700  modemst2
   8           73728           79871       3072K   0700  fsg
   9           79872           90111       5120K   0700  ramdump
  10           90112          106495       8192K   0700  apps_log
  11          106496          139263       16.0M   0700  FOTAKernel
  12          139264         2654207       1228M   0700  System
  13         2654208         3166207        250M   0700  Cache
  14         3166208        12695312       4652M   0700  Userdata
  15        12695313        31104990       8989M   0700  SDCard
root@mint:/ # 
- The app storage partition is resized from 2GB to 4.5GB.

We now need to create a filesystem, and, unfortunately, the filesystem toolm from the sdparted package would not run on my phone. The answer lies in this mke2fs package which is statically linked. (The other tools from this repository may work for you as well, but I didn't find it until I'd already repartitioned my disk with the other tools). Download the mke2fs file and adb push it to your phone. Now, create the filesystems on your new partitions:

$ ./adb shell
shell@mint:/ $ su                                                                                                     
root@mint:/ # mke2fs -j /dev/block/mmcblk0p14                                  
root@mint:/ # mke2fs -j /dev/block/mmcblk0p15                                  

Sideloading Cyanogenmod

With the phone still in recovery mode, download your new Cyanogenmod image and load it onto your phone by selecting Apply UpdateApply from ADB in Cyanogen recovery on your phone and then sideloading via adb on your computer:

$ ./adb sideload cm-12-20150830-NIGHTLY-mint.zip
Wait for the device to reboot and you should be running a brand-spanking-new Cyanogenmod on your Xperia T

Troubleshooting

Internal SD Card not Mounted

Once installed, I has trouble with Cyanogenmod not recognizing the internal SD card partition (the SDCard one from sdparted). This resulted in, among other things, the camera app being unusable and telling me to insert an SD card. This was fixed very simply by going to the Settings menu on the device, selecting Storage and touching the Erase SD card option.

You could leave a comment if you were logged in.
misc/android/xperia_t_cyanogenmod.txt · Last modified: 2015/09/09 22:26 by fronck
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki