Nexus 7: Easily Flash/Access Entire Userdata Partition

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.

Advertisement
This entry was posted in Snippets and tagged , , , . Bookmark the permalink.

7 Responses to Nexus 7: Easily Flash/Access Entire Userdata Partition

  1. Pingback: Nexus 7 MOSLO with kexec hardboot and 3G Nexus Support | ruedigergad

  2. e8hffff says:

    So you still aren’t repartitioning the device’s nand memory to a single one or how you’d like it?

    • ruedigergad says:

      That’s correct. I am not repartitioning it right now.
      However, MOSLO enables you to easily do that: once MOSLO is booted you can use telnet to log in to MOSLO via USB networking.
      To do this simply boot into MOSLO with the Nexus 7 connected to your computer via USB. Once MOSLO is booted you should see instructions how to connect, i.e., the IP address it uses (It should use 192.168.2.15.).
      On your computer you should find a “usb0” networking device that you can simply configure, e.g., with “ifconfig”. Once this is done you can log in to your Nexus 7 MOSLO via “telnet”.
      Still be aware that all warnings about warranty loss etc. still apply. Furthermore, I don’t know what happens if you repartition the Nexus 7. So you do this all at your own risk of course.

      • e8hffff says:

        Are you thinking that ‘parted’ will format the nand memory?

        With other tablets, like the Allwinner A10 SoC, you need to use livesuit or something similar to format the partitions. This is done externally before the data is written to those partition. Livesuit some how talks to a arcane SoC level to allow the device management. Not sure if Tegra has similar methods.

        There may also be EFI type structure to block later manipulation.

        I am yet to do any extensive research, but been hoping some smart people will release easy to install Plasma-Active on a single partition or other config that optimises the space for system growth. Android devices usually have many partitions which in effect are walls to file sizes and space.

  3. A. says:

    G’day,
    I have a rather similar and strange problem. I am trying to flash current Ubuntu 13.04 on my nexus, using the preinstalled images. However, this image is 705701 KB (reported by fastboot) in size (quoted by Linux as 690MB only). Fastboot goes to disk sleep whenever I try to flash this image.

    Having said that, the 12.04 image flashes to the device smoothly. The fastboot quotes the size of 12.04 as something 6xxxxxKB; essentially less than 700000KB.

    When you say 700MB, do you mean 700,000,000 bytes or 734,003,200 bytes?

    Cheers,
    A

    • A. says:

      Also, would you be able to refer me to some official source from where you know that there is a size limitation on the images that can be flashed to userdata.

      Thanks mate.
      A.

  4. Yuan says:

    could you make the files need to flash Nexus 7 like the ROMs as CM, is like that: XXX.zip.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.