[HD2 Android Q&A, Help & Troubleshooting and Genera] HypoTurtle:
Looks like some bad nesting around that area anyway, yea rOm can be changed - just hangovers from the previous setup.

Need to power up the phone to test it but:

#!/sbin/sh

###### Added for testing
#echo "ro.build.display.id [romn] [NativeSD]" > /system/build.prop
#cp /sdcard/initrd.gz /tmp/initrd.gz
#cp /sdcard/zImage /tmp/zImage

###### 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
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
###### Mounting stuff
if [ ! -d /NativeSD ]; then
mkdir /NativeSD
fi
if [ -f "/tmp/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
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 [ -b /dev/block/mmcblk0p3 ]; then
hexdump -C /dev/block/mmcblk0p3 | head -30 | grep 'f2fs' > /tmp/mt2.txt
fi
if grep -q 00000940 "/tmp/mt1.txt"; then
mt1='f2fs'
else
mt1='ext4'
fi
if grep -q 00000940 "/tmp/mt2.txt"; then
mt2='f2fs'
else
mt2='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 [ ${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
mkdir bin
cp /sbin/busybox bin/busybox
cp /sbin/e2fsck bin/e2fsck
cp /tmp/mountfs-${type}.sh mountfs-${type}.sh
if [ ${mt2} = 'f2fs' ]; then
cp /sbin/fsck.f2fs bin/fsck.f2fs
chmod 0777 bin/fsck.f2fs
fi
chmod 0777 mountfs-${type}.sh
chmod 0777 bin/busybox
chmod 0777 bin/e2fsck

###### Modifying ramdisk to not use yaffs, and use sd partitions instead.
if [ "${install_type}" -gt "2" ]; then
sed -i '/mtd@misc/s/^/#/' ueventd.htcleo.rc
sed -i '/mount yaffs2/s/^/#/
s/# #/# /g' init.rc
sed -i '/mount yaffs2/s/^/#/
s/# #/# /g' init.htcleo.rc
sed -i "s/rOm/$ROM_NAME/g" 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' init.rc
sed -i '/on fs/ a exec /mountfs-'${type}'.sh' init.htcleo.rc
chmod 0750 init.rc
chmod 0750 init.htcleo.rc
chmod 0644 ueventd.htcleo.rc
fi

###### 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 "/tmp/zImage" ]; then
hexdump -C /tmp/zImage | grep '1f 8b 08' > /tmp/zI.txt
if grep -q 00003f80 "/tmp/zI.txt"; then
dd if=/dev/zero of=/tmp/6MB bs=1M count=6
fi
fi
cat initrd-done.gz >> 6MB
mkdir /boot_dir/${ROM_NAME}_new/
cp 6MB /boot_dir/${ROM_NAME}_new/initrd.gz
cp /tmp/zImage /boot_dir/${ROM_NAME}_new/zImage
else
cp initrd-done.gz /tmp/initrd.gz
if [ ${install_type} -lt "3" ]; then
flash_image boot /tmp/boot.img
chmod 0755 /tmp/mkbootimg
chmod 0755 /tmp/mkbootimg.sh
exec /tmp/mkbootimg.sh
else
mkdir /boot_dir/${ROM_NAME}_new/
cp /tmp/initrd.gz /boot_dir/${ROM_NAME}_new/initrd.gz
cp /tmp/zImage /boot_dir/${ROM_NAME}_new/zImage
fi
fi
cp /tmp/initrd-${ROM_NAME}.gz /tmp/initrd.gz
rm -r /tmp/work/*

echo "Ramdisk successfully modified for ${ROM_NAME} running as ${type} on ${mt1}"
if [ -f /tmp/mt2.txt ]; then
echo "with data on ${mt2}
install folder is ${ROM_NAME}_new"
fi
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

is the current attempt.