[HD2 Android Q&A, Help & Troubleshooting and Genera] HypoTurtle:
How are you formatting the partition

This is what I'm running at the minute (on linux)

#!/sbin/sh
###### Added for testing
#echo "ro.build.display.id [romn] [DirectSD]" > system/build.prop
#cp initrd.gz tmp/initrd.gz
#cp zImage tmp/zImage
###### Clearing config files
if [ -f tmp/mt1.txt ]; then
rm tmp/mt1.txt
fi
if [ -f tmp/zI.txt ]; then
rm tmp/zI.txt
fi
if [ -f tmp/mt2.txt ]; then
rm tmp/mt2.txt
fi

###### Bootloader check
echo "bootloader=MAGLDR" > tmp/nfo.prop
output=`grep -i "clk" proc/cmdline`
if [ -n "${output}" ]; then
echo "bootloader=cLK" > tmp/nfo.prop
fi
###### Mounting stuff
if [ ! -d NativeSD ]; then
mkdir NativeSD
fi

if [ -f "Rname.prop" ]; then
ROM_NAME=`cat Rname.prop`
mount -t auto /dev/block/mmcblk0p2 NativeSD
mount --bind NativeSD/${ROM_NAME}/system system
umount boot
rmdir boot
fi
ROM_NAME=` cat system/build.prop | grep ro.build.display.id | awk '{print $(NF-1)}' | sed 's/\(\[\|\]\)//g' `
if [ ! -d "boot_dir" ]; then
mkdir boot_dir
mount --bind sdcard/NativeSD boot_dir
fi
if [ ! -d "boot" ]; then
mkdir boot
if [ ! -d sdcard/NativeSD/${ROM_NAME}-new ]; then
mkdir sdcard/NativeSD/${ROM_NAME}-new
fi
mount --bind sdcard/NativeSD/${ROM_NAME} boot
fi
###### Exporting variables
type=` cat system/build.prop | grep ro.build.display.id | awk '{print $(NF)}' | sed 's/\(\[\|\]\)//g' `
bootloader=` cat 'tmp/nfo.prop' | sed 's/bootloader=//g' `
### Changing install_type to numbered value
if [ ${type} = 'NAND' ]; then
install_type='1'
fi
if [ ${type} = 'DataOnExt' ]; then
install_type='2'
fi
if [ ${type} = 'NativeSD' ]; then
install_type='3'
fi
if [ ${type} = 'DirectSD' ]; then
install_type='4'
fi

###### Copying zImage and initrd.gz from /boot_dir when one wasn't added to zip
if [ ! -f "tmp/zImage" ]; then
cp boot/zImage/ tmp/zImage
fi
if [ ! -f "tmp/initrd.gz" ]; then
cp boot/initrd.gz/ tmp/initrd.gz
fi

###### Making mountfs-file
if [ ! -f tmp/mountfs-${type}.sh ]; then
if [ "${install_type}" -gt "1" ]; then
echo "#!/bin/busybox sh
# wait for 2nd partition ready
wait /dev/block/mmcblk0p2
wait /dev/block/mmcblk0p2
wait /dev/block/mmcblk0p2
wait /dev/block/mmcblk0p2" > tmp/mountfs-${type}.sh
if [ ${type} = 'DirectSD' ]; then
echo "# wait for 3rd partition ready
wait /dev/block/mmcblk0p3
wait /dev/block/mmcblk0p3
wait /dev/block/mmcblk0p3
wait /dev/block/mmcblk0p3" >> tmp/mountfs-${type}.sh
fi
hexdump -C dev/block/mmcblk0p2 | head -30 | grep 'f2fs' > tmp/mt1.txt
if grep -q 00000940 "tmp/mt1.txt"; then
mt1=f2fs
else
mt1=ext4
fi
if [ ${mt1} = 'ext4' ]; then
echo "# check the ext4 fs
/bin/e2fsck -p /dev/block/mmcblk0p2 /e2fsck.log" >> tmp/mountfs-${type}.sh
else
echo "/bin/fsck.f2fs -p /dev/block/mmcblk0p2 /fsckf2fs.log" >> tmp/mountfs-${type}.sh
fi
if [ ${type} = 'DirectSD' ]; then
echo "Modifying for ${type}"
if [ -b dev/block/mmcblk0p3 ]; then
hexdump -C dev/block/mmcblk0p3 | head -30 | grep 'f2fs' > tmp/mt2.txt
else
echo "No 2nd ext partition present, format one and run script again"
fi
if grep -q 00000940 "tmp/mt2.txt"; then
mt2='f2fs'
else
mt2='ext4'
fi
if [ ${mt2} = 'ext4' ]; then
echo "# check the ext4 fs
/bin/e2fsck -p /dev/block/mmcblk0p3 /e2fsck.log" >> tmp/mountfs-${type}.sh
else
echo "/bin/fsck.f2fs -p /dev/block/mmcblk0p3 /fsckf2fs.log" >> tmp/mountfs-${type}.sh
fi
fi
echo "/bin/busybox mkdir -p /NativeSD
/bin/busybox mount -t ${mt1} -o ro,noatime,nodiratime,barrier=0 /dev/block/mmcblk0p2 /NativeSD
# mount the system data app dir" >> tmp/mountfs-${type}.sh
echo "Modifying for ${type}"
if [ ${type} = 'DataOnExt' ]; then
echo "/bin/busybox mount --bind /NativeSD/${ROM_NAME}/data /data" >> tmp/mountfs-${type}.sh
fi
if [ "${install_type}" -gt "2" ]; then
echo "/bin/busybox mount --bind /NativeSD/${ROM_NAME}/system /system" >> tmp/mountfs-${type}.sh
if [ ${type} = 'NativeSD' ]; then
echo "/bin/busybox mount --bind /NativeSD/${ROM_NAME}/data /data" >> tmp/mountfs-${type}.sh
else
echo "/bin/busybox mkdir -p /DirectData
/bin/busybox mount -t ${mt2} -o noatime,nodiratime,nosuid,nodev,discard /dev/block/mmcblk0p3 /DirectData
/bin/busybox mount --bind /DirectData/${ROM_NAME}/data /data" >> tmp/mountfs-${type}.sh
fi
fi
echo "# cleanup
# delete /bin to free ram
/bin/busybox rm -rf /bin" >> tmp/mountfs-${type}.sh
fi
fi

###### Setting up working directory
cp tmp/initrd.gz tmp/initrd-${ROM_NAME}.gz
mkdir -p tmp/work
cd tmp/work

###### Unzipping nand kernel
gzip -d -c ../initrd-${ROM_NAME}.gz | cpio -i -d
if [ ! -d bin ]; then
mkdir bin
fi
cd ../..
cp sbin/busybox tmp/work/bin/busybox
cp sbin/e2fsck tmp/work/bin/e2fsck
cp tmp/mountfs-${type}.sh tmp/work/mountfs-${type}.sh

if [ -f tmp/mt2.txt ]; then
echo "copying fsck for f2fs"
if grep -q 00000940 "tmp/mt2.txt"; then
cp sbin/fsck.f2fs tmp/work/bin/fsck.f2fs
chmod 0777 tmp/work/bin/fsck.f2fs
fi
fi
chmod 0777 tmp/work/mountfs-${type}.sh
chmod 0777 tmp/work/bin/busybox
chmod 0777 tmp/work/bin/e2fsck

###### Modifying ramdisk to not use yaffs, and use sd partitions instead.
if [ "${install_type}" -gt "2" ]; then
sed -i '/mtd@misc/s/^/#/' tmp/work/ueventd.htcleo.rc
sed -i '/mount yaffs2/s/^/#/
s/# #/# /g' tmp/work/init.rc
sed -i '/mount yaffs2/s/^/#/
s/# #/# /g' tmp/work/init.htcleo.rc
sed -i "s/rOm/$ROM_NAME/g" tmp/work/mountfs-${type}.sh
fi

###### Checking for anything other than nand is to be installed
if [ "${install_type}" -gt "1" ]; then
sed -i '/on fs/ a exec /mountfs-'${type}'.sh' tmp/work/init.rc
sed -i '/on fs/ a exec /mountfs-'${type}'.sh' tmp/work/init.htcleo.rc
chmod 0750 tmp/work/init.rc
chmod 0750 tmp/work/init.htcleo.rc
chmod 0644 tmp/work/ueventd.htcleo.rc
fi
cd tmp/work
###### Building new ramdisk
find . | cpio -o -H newc | gzip -9 > ../initrd-done.gz
cd ..

###### Checking bootloader
if [ ${bootloader} != "cLK" ]; then
###### Checking zImage type
if [ -f "zImage" ]; then
hexdump -C zImage | grep '1f 8b 08' > zI.txt
if grep -q 00003f80 "zI.txt"; then
dd if=/dev/zero of=/tmp/6MB bs=1M count=6
fi
fi
cat initrd-done.gz >> 6MB
cp 6MB ../boot_dir/${ROM_NAME}-new/initrd.gz
cp zImage ../boot_dir/${ROM_NAME}-new/zImage
else
cp initrd-done.gz initrd.gz
if [ ${install_type} -lt "3" ]; then
flash_image boot boot.img
chmod 0755 mkbootimg
chmod 0755 mkbootimg.sh
exec mkbootimg.sh
else
cp initrd.gz ../boot_dir/${ROM_NAME}-new/initrd.gz
cp zImage ../boot_dir/${ROM_NAME}-new/zImage
fi
fi
cd ..
cp tmp/initrd-${ROM_NAME}.gz tmp/initrd.gz
#rm -r tmp/work/*
#rm tmp/mountfs-${type}.sh
echo "Ramdisk successfully modified for ${ROM_NAME} running as ${type} on ${mt1}"
if [ -f tmp/mt2.txt ]; then
echo "with data on ${mt2}"
fi
echo "The install folder is ${ROM_NAME}-new"
if [ -f tmp/zI.txt ]; then
echo "kernel used is"
if grep -q 00003f80 "tmp/zI.txt"; then
echo "a 3.0.x kernel"
else
echo "a 2.x kernel"
fi
fi

It should also run file fine on device (if run from /). I have kernel marked as 00003f80 as thats what I'm getting from the kernel I'm using (which should be the one being used to power recovery md5sum=b4757fbfbc90c7fce419c9826b81770e)