[HD2 Android SD Development] securecrt:
Q&A

How is the NativeSD ROM work?

To boot the Android from SD card, the old SD ROMs mount the system.ext4 and data.ext4 before the init(rename to init.android) thread is start. I changed the initrd.gz to make it mount the ext4 partition before the android init.android start. here is the main code for the init script

echo "mount system and data partition on sdcard"
# change the rom_name TO PA MIUI CM7 will support
# to boot other system on SD/EXT4
# the system layout :
# /NativeSD/NexusHD2/
# /system
# /data
# /PA/
# /system
# /data
# /MIUI/
# /system
# /data
# /app
# the app dir is shared for all ROMs
#

# set the name of the rom to boot
rom_name="PA"

# mount the 1st (NativeSD) SD-EXT partition
mkdir -p /NativeSD
mount -t ext4 -o rw,noatime,nodiratime,barrier=0 /dev/block/mmcblk0p2 /NativeSD

# mount the system data app dir
mount --bind /NativeSD/$rom_name/system /system
mount --bind /NativeSD/$rom_name/data /data
# create app data/app dir
mkdir -p /NativeSD/app
mkdir -p /data/app
mount --bind /NativeSD/app /data/app

So for the ROM Devs should create new initrd.gz which is different with the NAND version, use different rom_name distinguish with others the whole templete is in 2nd post by Xylograph​

How is the multi-boot works on NativeSD ROM?

Set the SD boot dir /sdcard/NativeSD in Magldr or CLK,the dir structure is

/sdcard/NativeSD/NexusHD2/zImage

/sdcard/NativeSD/NexusHD2/initrd.gz

/sdcard/NativeSD/PA/zImage

/sdcard/NativeSD/PA/initrd.gz

/sdcard/NativeSD/zImage

/sdcard/NativeSD/initrd.gz​

The Magldr& CLK always read the /sdcard/NativeSD/zImage /sdcard/NativeSD/initrd.gz files to boot, so if you want to switch from PA to NexusHD2 just only need to copy the zImage & initrd.gz to the up layer dir, use the NativeSD ROM switch app made by datagr​

How to convert the NAND ROM to NativeSD ROM?

HOWTO port NAND ROM to NATIVESD STEP-BY-STEP Credits to c1cl0n

This is for Devs and advanced users only. For example if we got the NAND version of the NexusHD2 extract the zip file and replace 2 files and add 1 file will finish the convert.

/kernel/boot/initrd.gz

the initrd.gz is similar with the SD ROMs but need to change the init script to mount the ext4 partition

/META-INF/com/google/android/updater-script

the updater-script is used for CWM to execute the install process; execute install.sh before copy the system content to the ext4, here is the sample code

package_extract_file("install.sh", "/tmp/install.sh");

set_perm(0,0, 0777, "/tmp/install.sh");

run_program("/tmp/install.sh");
show_progress(0.8, 80);

if file_getprop("/tmp/nfo.prop","NativeSD") == "true"

then

package_extract_dir("kernel/boot", "/boot");
package_extract_dir("kernel/boot", "/boot_dir");
package_extract_dir("system", "/system");
......

else
ui_print("can't find ext4 partition on your SDcard");
ui_print("install failed");
endif;

/install.sh

#!/sbin/sh

# Set the ROM name
ROM_NAME=NexusHD2
export ROM_NAME

mmcblk0p2=`ls /dev/block/mmcblk0p2`

# Mount the ext4 partition
if [ $mmcblk0p2 == "/dev/block/mmcblk0p2" ]
then

mkdir -p /ext4p
mkdir -p /sdcard/NativeSD/$ROM_NAME
mkdir -p /boot /boot_dir

mount -t ext4 /dev/block/mmcblk0p2 /ext4p
mkdir -p /ext4p/$ROM_NAME/system /ext4p/$ROM_NAME/data

mount --bind /ext4p/$ROM_NAME/system /system
mount --bind /ext4p/$ROM_NAME/data /data

mount --bind /sdcard/NativeSD/$ROM_NAME /boot
mount --bind /sdcard/NativeSD	/boot_dir
#delete the old system
rm -rf /system/*

#clean the dalvik-cache
rm -rf /data/dalvik-cache/*

#all the dir has ready write some info for updater-script
echo "NativeSD=true" >> /tmp/nfo.prop
else

#no ext4 partition found
echo "NativeSD=false" >> /tmp/nfo.prop
fi

​

How to make ext4 partition on my SDCARD?

http://xdaforums.com/showthread.php?p=31414628#post31414628