Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,730,983 Members 46,192 Now Online
XDA Developers Android and Mobile Development Forum

Natice Linux Installation No Android

Tip us?
 
DJHenjin1
Old
(Last edited by DJHenjin1; 27th May 2014 at 05:31 AM.)
#1  
Junior Member - OP
Thanks Meter 3
Posts: 4
Join Date: Apr 2014
Tablet Natice Linux Installation No Android

As anyone who has tinkered around with android and linux will know there are tons of different security mechanism in place or even general lacks of features that dissallow the ability to start linux on boot instead of android. One of the features that will make booting our own OS easier is the use of RAM-Disk.

First we must consider the way that Android boots when we turn on our devices currently, The system powers on and depending on button combination or system state the bootloader decides where to start booting. In the case of my Samsung SM-T520 this means that I have 2 partitions that I can access in order to interrupt the Android boot sequence and boot instead into an OS of my choosing. Those two partitions are Labelled as Boot and Recovery and reside at /dev/block/mmcblk0p9 and /dev/block/mmcblk0p10, but it is not as simple as simply mounting the partition and modifying the contents, we have to Modify the stock Kernel as well a little bit to be able to achieve better performance in the Linux side of things.


In the case of the SM-T520 I have compiled a preconfigured Kernel for this and will upload it below, But for those of you who do Not have the SM-T520 I will upload a sample Kernel config that you can base your own off of.

That settles the Kernel side of things but there is still 1 other part missing, If we just modify the Kernel then we are really not making any difference so we must edit...

The Initial RAMDISK
The Initramfs as many know it is glued to the back end of our kernel zImage that we get from compiling our own kernel, and includes a few small files to set up the initial environment for Android, or our Guest OS to finish booting from. This means that we have a pretty good base to start out with booting Linux. We simply have to grab this base and modify to our will.

So to start I took an image of /dev/block/mmcblk0p9 using dd from recovery like so ‘dd if=/dev/block/mmcblk0p9 of=sdcard/mmcblk0p9.img’ and copied the file onto my linux development machine. I then used umkbootimg passing the file to it as input in order to deconstruct that file into the zImage and the Ramdisk. i then copied the Ramdisk which will be in a file called initramfs.cpio.gz into a new folder on my computer and ran unpack_ramdisk on it to get to the nitty gritty inside which is what we need. and i promptly threw out the old initramfs.cpio.gz and kept only the ramdisk folder. This allowed me to modify the “scripts” inside of it so that it would boot Linux by mounting the linux install location as / then telling if to boot using the init function that linux already has. while I was testing i decided to leave the android install mounted essentially, what that means is that the android install hides away in the filesystem inside the linux install if we ever want to boot Android into a chroot Jail of its own.

That is possible because Android’s file system and the linux filesystem being used are the same structure, but at different locations /system being empty for the Android system to occupy. This is all fine, but where do we put linux? The short answer, Wherever the heck ya want to!
My answer was to put the linux install onto my MicroSD card at /dev/block/mmcblk1p1 so that i could write an addition to the logic inside the Ramdisk to start linux or android based on whether the SD card was inserted at boot.

More yet to follow
The Following 3 Users Say Thank You to DJHenjin1 For This Useful Post: [ Click to Expand ]
 
k8108
Old
#2  
Senior Member
Thanks Meter 68
Posts: 383
Join Date: Jun 2010
Interesting read. It will be great to see where this leads.
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


XDA PORTAL POSTS

Blast Those Flags with Knock the Flags

Lately, we have seen a rather drastic shift in the world of mobile device gaming. The infamous Angry … more

Hide Numbers on Your SMS and Call Logs with Reflection

How many times have you given your device to someone else in order to show them a … more

Implement Split View in Your LG G2 KitKat Rom with Automated Installer

Some of you may have remembered a story on the Portal a few weeks back … more