Recently, I got my hands on a Google Nexus 7. This is quite a nice device. But as you might have figured from my other posts I am not that much interested in using Android on it.
Fortunately, it is possible to open up the bootloader and install, e.g., Ubuntu on the Nexus 7. While the possibility to install Ubuntu is already nice and a first start, my personal favorite is to have Plasma Active running on the Nexus 7.
The very first issue I encountered is how to “flash” a root filesystem onto the Nexus 7. In this post I’ll explain the problems connected with this as well as my solution to this issue based on the “MeeGo OS LOader” (MOSLO). Furthermore, this solution will enable you to conveniently mount the root filesystem like a normal USB storage device even without any installed operating system.
One problem when dealing with the Nexus 7 and trying to get a custom OS on it is that even with the unlocked device it doesn’t allow you to mount the userdata partition as is. You can flash the userdata partition using fastboot but there is another limitation that limits the maximum size of the flashed image to 700 MB.
The current Ubuntu version for Nexus 7 circumvents the size limitation issue, basically, by flashing a compressed rootfs (as tarball) and extracting that tarball on first boot. This way the size of the image is below 700 MB while the actually installed rootfs may be much bigger. This, however, is very unflexible.
What one actually wants would be to have full access to the userdata partition even without an installed operating system. This way you could “flash” images of arbitrary size. Furthermore, you could mount the partition and read or edit files independently of the installed OS. This would provide much bigger flexibility when hacking on a custom OS.
Luckily there is already the MOSLO project which provides this functionality for devices like the Nokia N9. MOSLO, essentially, is an initrd with a shell script that can act as a boot loader or can export partitions via USB.
So, I took MOSLO as starting point. One problem on getting the required functionality on the Nexus 7 to work was to get the USB Gadget support in the Linux Kernel working (This is required for accessing the device via USB.). You can find the kernel config for the Ubuntu Nexus 7 kernel as well as a patch required for compiling the kernel with this config in my nexus7-moslo project on gitorious.
You can get a readily compiled version from one of my download repositories. Simply download a file named moslo-xx-yy.Project.KDE.Devel.armv7hl.rpm (xx being the version and yy the build version) and extract it as follows:
rpm2cpio moslo-xx-yy.Project.KDE.Devel.armv7hl.rpm | cpio -idmv
Then, in order to boot MOSLO start the Nexus 7 with the volume down button pressed to force it to start into the boot loader. Then you can boot MOSLO via fastboot like this:
fastboot boot usr/share/moslo/zImage-moslo usr/share/moslo/initrd-moslo
Alternatively, if you want to use MOSLO permanently, you can flash MOSLO to your boot partition as follows:
fastboot flash:raw boot usr/share/moslo/zImage-moslo usr/share/moslo/initrd-moslo
In order to export userdata via USB you need to have the Nexus 7 connected to your computer via USB. You should see according output on your Nexus. Furthermore, MOSLO allows you to connect to it with telnet via USB network. You should see some instructions for this once MOSLO is booted as well.
Right now the Nexus 7 version of MOSLO only supports exporting the userdata partition via USB and log in via telnet. What is not working so far is to boot into an OS with this version. This is one of the points I am still working on.
The N9 MOSLO also works as some kind of bootloader for choosing different operating systems. It does this via loading the kernels of the other OS via kexec. Right now, there is some problem with this in the current version of the Nexus 7 version of MOSLO.
Nonetheless, with the Nexus 7 MOSLO you gain raw access to the userdata partition of your precious device which is a huge improvement over the former way which only allowed writing to it and also had a limitation in size. Essentially, you could export any partition, but I think userdata should be the most interesting one.
I hope you consider this useful. This is still quite a work in progress but I thought having full read/write access to the Nexus 7 userdata partition is worth a blog post. Note that you can also format your userdata partition this way.