[Eee Pad Transformer Android Development] jrohwer:
[KERNEL/MOD] [LINUX] [Rootbind] [Native EMMC/all TF101&TF101G/fast/tested] [2-Jul-13]

UPDATE 2013/11/08: New kernel released with USB and framebuffer fixed. See post #3.

UPDATE 2014/05/16: New Ubuntu 14.04 filesystem. See point #2 below under Installation.

UPDATE 2014/06/03: New kernel released with USB and framebuffer fixed, OC to 1.5 GHz. See post #3 and #326.

UPDATE 2014/07/09: New kernel released with OC to 1.5 GHz fully working, boots every time. See post #3 and #334.

This is a kernel/initrd mod that allows you to run Linux (Ubuntu, Debian, Arch,...) on your TF101 from the internal EMMC (/data partition in Android) without repartitioning your tab.

Disclaimer:

This works on my tablet and I use it daily. However, I am not responsible for any bricks or if you damage your beloved TF. YOU ARE DOING THIS AT YOUR OWN RISK!

Features and advantages:

Fast (and I mean about as fast as it's gonna get on this device). See post #2 for benchmarks.

No need to repartition to get this. Previously TF101 users could run Linux on EMMC but they had to repartition with wheelie/nvflash, but it wasn't available to TF101G users (of which I'm one).

Any free space on your /data partition is available to both Linux and Android. When you delete stuff on either operating system, the free space is available for both again, as they are running off the same partition. Previously, when you re-partitioned e.g. with OLiFE you had to allocate a certain space (8GB by default) for Linux, then this was not available for Android even if you're not using all of it in Linux.

Way faster than loopmount, especially for disk writes.

Way faster than running Linux off a MicroSD card ext4 partition (even with class 10).

Dualboot is achieved just by flashing either the Android or the Linux kernel.

So how does this work?

The kernel/initrd is modded to take an extra parameter "bind=/path/to/linux/rootfs" on the command line. This will then bind-mound that path to the Linux root mount. It works pretty similar to the way a loop-mounted linux image is loaded and set up during boot, except that now bind-mount is used, not a loop-mount. This is possible because both Android and Linux use the ext4 filesystem, so they can actually share the same partition.

N.B. This thread is not a guide on how to get Ubuntu running on your TF101. There are plenty of guides for that, e.g.

http://xdaforums.com/wiki/ASUS_Eee_Pad_Transformer/How_to_install_Ubuntu

http://xdaforums.com/wiki/ASUS_Eee_Pad_Transformer/How_to_install_Ubuntu/Ubuntu_Install

Tubuntu by x3maniac - http://xdaforums.com/showthread.php?t=1995157

Net-Install by NoDiskNoFun - http://xdaforums.com/showthread.php?t=1852702

Transformazing by transformador - http://xdaforums.com/showthread.php?t=2167224

Make sure to read those threads to get an idea of how this works.

READ THESE INSTRUCTIONS CAREFULLY!

Installation:

Take a Nandroid backup, just in case something goes wrong.

Get a Linux root filesystem if you don't already have one.

See this thread for a discussion of various filesystems available for rootbind.

Alternatively roll your own using debootstrap as described by shaola:

http://xdaforums.com/showthread.php?t=1476835

NEW! For a fully working Kubuntu 14.04 image (with graphics acceleration using the Nvidia drivers) see this post: http://xdaforums.com/showpost.php?p=52697775&postcount=303

This is already an image in a tar file so it doesn't need to be mounted, so instead of the code below you can merely do the following:

mkdir -p /data/linuxroot
busybox chmod 755 /data/linuxroot
cd /data/linuxroot
tar -xpjf /path/to/my/saved/kubuntu-14.04.tar.bz2

Running Android, copy the root filesystem to a directory on your /data partition, preserving the permissions. The easiest is with the "tar" command (see below). The default install assumes that Linux lives in /data/linuxroot under Android.

For a Linux image in a file that is used for loop-mount (assume it is in /sdcard/ubuntu.img, or edit accordingly), run the following in a terminal when running Android (make sure you are root):

busybox mount -o remount,rw /
mkdir -p /data/linuxroot
busybox chmod 755 /data/linuxroot
mkdir -p /mnt/ubuntu
busybox mount -o loop /sdcard/ubuntu.img /mnt/ubuntu
cd /mnt/ubuntu
tar -cvp * | tar -C /data/linuxroot -xp
cd /
busybox umount /mnt/ubuntu
rmdir /mnt/ubuntu
busybox mount -o remount,ro /

(note in tar command first -c is lowercase, second -C is uppercase)

For a Linux rootfs that lives on a separate partition (e.g. 2nd part. on MicroSD), run the following (assumes linux is in /dev/block/mmcblk1p2, otherwise edit accordingly):

busybox mount -o remount,rw /
mkdir -p /data/linuxroot
busybox chmod 755 /data/linuxroot
mkdir -p /mnt/ubuntu
busybox mount -t ext4 /dev/block/mmcblk1p2 /mnt/ubuntu
cd /mnt/ubuntu
tar -cvp * | tar -C /data/linuxroot -xp
cd /
busybox umount /mnt/ubuntu
rmdir /mnt/ubuntu
busybox mount -o remount,ro /

Copy kernel modules to your rootfs. Download modules-3.1.10-9.tar.gz to your /sdcard. then:

cd /data/linuxroot/lib/modules
tar -xzf /sdcard/modules-3.1.10-9.tar.gz

Flash the Linux kernel. Either flash the zip from recovery or copy the kernelblob directly to the staging partition with dd (if you don't know what I'm talking about here, then use the recovery method).

Reboot 'n enjoy! Remember to run "sudo depmod -a" after the first Linux boot, and reboot. Otherwise your modules won't load and wifi, etc., won't work.

To re-boot into Android, simply flash the boot image/kernelblob from your Android ROM.

Notes:

The kernel is compiled from Jhinta's source with a few modifications to the config - http://xdaforums.com/showthread.php?t=1683145

Make sure not to have a /host directory in your Linux rootfs - this interferes with the bind mount!

The Linux rootfs can live anywhere on your Android /data partition (the default is /data/linuxroot). If you want to change this, then you'll have to blobunpack the kernelblob-rootbind, unpack the boot image (kernelblob-rootbind.LNX) with abootimg, change the command line as desired, re-pack the boot image with abootimg, and re-pack the blob for flashing.

The "bind" cmdline argument is the location of your Linux rootfs without the initial "/data". So if your Linux rootfs lives on /data/my/linux/path under Android, then you'd have to change the cmdline parameter to "bind=/my/linux/path".

Make sure, however, not to put the Linux rootfs to the "internal storage" (/data/media) or any subdirectories thereof. This plays havoc with the Android media scanner when re-booting into Android and your tablet may slow down to a crawl.

Under Android your EMMC partitions are /dev/block/mmcblk0p1,2,3,....

Under Linux, this is /dev/mmcblk0p1,2,3....

Thanks to:

lilstevie - for bringing Ubuntu to our tablet

Jhinta - for his 3.1.10 kernel

shaola - for his debootstrap guide

x3maniac - for his Tubuntu installer

transformador - for his mountloop instructions

TomTcom - for all his Ubuntu-related guides on xda

Kingzak34 - for his dualboot guide and general help/discussion

DjDill - for putting together the collection of rootbind filesystem images

(if your name should be here and I have forgotten you, please PM me...)