[Proof of concept] Everything2SD

ilarrain

Senior Member
Dec 13, 2010
154
133
43
The basic idea of this mod is moving all partitions to the SD card, and running the full OS from the SD card.

There are many reasons why not to do this and probably is a bad idea, but the main reason behind this mod is just a proof of concept that can potentially result in a better internal and external memory utilization and speed improvements.

Reasons I can think of for not doing this:
- Reduced responsiveness and overall speed.
- Over stress on the SD card that can potentially leed to permanent damage to the card.
- The need to use modified boot and recovery images, thus leading to an install incompatible with any rom update (as it is) out there.
- Reduced battery autonomy.
- Many more I can't think of right now.

Reasons to do this:
- Because we can.
- As a proof of concept.
- For developing purposes.
- We get the ability to switch between 2 installations just by switching the SD card (of the same rom or roms with compatible boot images: kernel+ramdisk).

Don't do any of this if you don't know what you are doing!!!

Simplified steps (I've only tested this with Mik's CM7 (betas 6.2 and 6.3) + ClockWorkMod recovery on a Ubuntu machine):
- Download and flash ClockWorkMod recovery.
- Download and flash Mik's CM7.
- Do a full backup from recovery.
- Turn the phone off.
- Take out the SD card and put it on a Card reader on your PC.
- Backup the SD Card contents (including the full backup).
- Use Gparted (or any partition manager that has support for ext4 partition creation) to create the following partition structure:
Code:
num   mount point   size   type
1:    /sdcard       REST   fat32
2:    /data         500M   ext4
3:    /system       190M   ext4
4:    /cache        64M    ext4
The partition number is important, so you should calculate the fat32 partition beforehand or resize the existing one.
- Put new boot and recovery images on the fat32 partition. *
- Put the card on the phone and boot into recovery.
- Mount the sdcard trough menu.
- Connect the phone to your pc and start adb shell.
- Flash custom boot and recovery images:
Code:
flash_image boot /sdcard/boot-everything2sd.img
flash_image recovery /sdcard/recovery-everything2sd.img
- Reboot recovery.
- Through menu, mount all partitions.
- Connect trough adb shell and copy your data:
Code:
adb shell
cp -a /int-cache/* /cache/
cp -a /int-system/* /system/
cp -a /int-data/* /data/
- In adb shell, remove the sd_ext mount script:
Code:
rm /system/etc/init.d/05mountsd
- Reboot the phone.

Off course, no other method of storing the apps on the SD is desired as they are already there.

* I've attached custom boot and recovery images for Mik's CWM and CM7 beta 6.2 (updated boot images to Mik's CM7.02 beta 6.3 in post #3), but, the steps for creating them are next:
- Extract the original images (boot.img and recovery.img) from the root of the downloaded zips (signed-recovery.zip and cyanogen_thunderg-ota-eng.mik.zip).
- Unpack the images following this guide: HOWTO: Unpack, Edit, and Re-Pack Boot Images: Alternative Method (Perl scripts are attached, you'll need compiled mkbootfs and mkbootimg for your OS).
- On recovery ramdisk, change the etc/recovery.fstab file as follows:
Code:
# mnt pnt   fstype  device               [device2]            [fstype2]  

/boot       mtd     boot
/cache      ext4    /dev/block/mmcblk0p4
/data       ext4    /dev/block/mmcblk0p2
/misc       mtd     misc
/recovery   mtd     recovery
/sdcard     vfat    /dev/block/mmcblk0p1 /dev/block/mmcblk0   ext4
/system     ext4    /dev/block/mmcblk0p3
/int-cache  yaffs2  cache
/int-data   yaffs2  userdata
/int-system yaffs2  system
- On boot ramdisk, change the init.rc file as follows (diff output):
Code:
[email protected]:~/Descargas/bootimages$ diff boot.img-orig_ramdisk/init.rc boot.img-ramdisk/init.rc 
22d21
<     export SD_EXT_DIRECTORY /sd-ext
68,69d66
<     mkdir /sd-ext 0771 system system
< 
100,103c97,100
<     mount yaffs2 [email protected] /system
<     mount yaffs2 [email protected] /system ro remount
<     mount yaffs2 [email protected] /data nosuid nodev
<     mount yaffs2 [email protected] /cache nosuid nodev
---
>     mount ext4 /dev/block/mmcblk0p3 /system
>     mount ext4 /dev/block/mmcblk0p3 /system ro remount
>     mount ext4 /dev/block/mmcblk0p2 /data nosuid nodev
>     mount ext4 /dev/block/mmcblk0p4 /cache nosuid nodev
- Recreate the ramdisks and images following the guide posted above, changing the mkbootimg command line to (notice the base and cmdline parameters; for recovery, change boot to recovery on all instances):
Code:
mkbootimg --base 0x12800000 --cmdline 'mem=471M console=ttyMSM2,115200n8 androidboot.hardware=thunderg' --kernel boot.img-kernel --ramdisk boot.img-ramdisk.gz -o boot-new.img
 

Attachments

Last edited:

ilarrain

Senior Member
Dec 13, 2010
154
133
43
I've updated boot images to Mik's CM7.02 beta 6.3, attached below.

I'm going to run a Quadrant Advanced and let you know. Anyway, I don't think I will get good results, as my SD card is cheap and buggy, half the time it doesn't get mounted, with or without this mod. Also, I think we'll get better scores with your tweaks, especially with the modded libsqlite.so.

The idea behind this is not to get impressive results or leave it as a definitive mod (as it is right now). Instead, the idea I have is to start moving some things back to the internal memory, for instance, mounting [email protected] as /data/dalvik-cache (just an idea). Basically, leaving the things that need fast reading times, but infrequent writes in the SD, and the things that are constantly being written to, in the internal memory.
 

Attachments

cmangalos

Senior Member
Nov 12, 2010
325
16
0
Cardona, Rizal
so what class of sd card do you preffer?
still class 4 above?
well, sorry about what im going to say , but if **** happened and luckily sd card got corrupted, then the phone does as well?
ive not read all of your first post,
but if ever we are changing sd cards, like example upgrading from 4g-8g,
is it necessary to repeat the whole process or copy paste is enough?(i bet not due to ext)
 

theb3s7

Senior Member
Jul 4, 2010
140
21
0
Bucharest
so what class of sd card do you preffer?
still class 4 above?
well, sorry about what im going to say , but if **** happened and luckily sd card got corrupted, then the phone does as well?
ive not read all of your first post,
but if ever we are changing sd cards, like example upgrading from 4g-8g,
is it necessary to repeat the whole process or copy paste is enough?(i bet not due to ext)
If **** happened you could mount it in a computer with a card reader and perform a disk check + recovery. If the sd card broke, well.. I think there's still hope, since you may boot in recovery and replace the mount points back to the internal memory ( right ? :D )

As for the storage upgrade, well, it's not exactly copy-paste but you should be able to duplicate the partitions without much hassle..
 

Bytecode

Inactive Recognized Developer
Dec 30, 2010
2,684
4,487
0
22
/dev/null
I really like this idea,we could get 3000+ quadrant score :D

But can be potentially dangerous. If anything goes wrong i think that Phone can't boot anymore.
 

sarfaraz1989

Senior Member
Jan 19, 2011
655
62
0
New Delhi
how abt two separate roms in 6 separate partitions ???? is the bootloader cracked ??? Can we have a grub like menu to select two roms ???Way 2: Maybe somebody cud mod android's initramfs and add options there to select two different fstabs ...just a thought
 

ilarrain

Senior Member
Dec 13, 2010
154
133
43
I really like this idea,we could get 3000+ quadrant score :D
Not me, because my SD card is very buggy. Anyway, it depends very much on the card, the card reader and the kernel. Anyway, it's just a proof of concept and it opens a great window for experimentation.

But can be potentially dangerous. If anything goes wrong i think that Phone can't boot anymore.
Not at all, recovery can boot even if the SD card is damaged or not present. Then you can flash the original recovery, boot it and flash any ROM without this mod.

Steps:
- Extract recovery.img from your desired custom recovery.
- Boot recovery.
- Mount /int-cache from mounts and storage menu.
Code:
adb push recovery.img /int-cache/recovery.img
adb shell
flash_image recovery /int-cache/recovery.img
- Reboot recovery
- Flash desired ROM from any SD card.

OR: Just flash an original (released by LG) ROM through emergency mode.

how abt two separate roms in 6 separate partitions ???? is the bootloader cracked ??? Can we have a grub like menu to select two roms ???Way 2: Maybe somebody cud mod android's initramfs and add options there to select two different fstabs ...just a thought
Bootloader isn't cracked yet, so it would have to be implemented on the boot.img (kernel and/or ramdisk), and I don't know how. Right now is easier to swith SD cards. Anyway, ROMs should be able to share boot.img (kernel + ramdisk).

Having fastboot disabled is such a pain in the ass... :(
+1. But bootloader isn't cracked yet.
 
  • Like
Reactions: levideva

tsukisan

Senior Member
Jul 17, 2009
61
7
0
Santa Clara, CA
Just a little heads up, but if anyone is paying attention to the Nook Color development, this is exactly how the boot process on that device works, I am running one os off the sd card and if I remove it I am back to stock. The main point of my brining this up is you create the sd card with all it's partitions by flashing an image of the sd card with the WinImage application on windows. Might at least save you some steps. Hope this helps.
 

lekhwani

Senior Member
Oct 15, 2010
1,876
260
0
Just a little heads up, but if anyone is paying attention to the Nook Color development, this is exactly how the boot process on that device works, I am running one os off the sd card and if I remove it I am back to stock. The main point of my brining this up is you create the sd card with all it's partitions by flashing an image of the sd card with the WinImage application on windows. Might at least save you some steps. Hope this helps.
Possibilities seem to be limitless.

Sent from my LG-P500 using Tapatalk