[HD2 Android NAND Development] HypoTurtle:
mkmountfs() {
### Making the mountfs.sh for the various install types ###
busybox printf "%b\n" "creating mountfs.sh"
if [ ${4} -gt '1' ]; then
printf "#!/bin/busybox sh\nwhile [ ! -b ${firstpart} ]; do\n/bin/busybox sleep 5\ndone\n/bin/busybox sleep 2\n" > /tmp/mountfs-"${1}".sh
if [ ${1} = DirectSD ]; then
echo "Modifying for ${type}"
printf "while [ ! -b ${secondpart} ]; do\n/bin/busybox sleep 5\ndone\n/bin/busybox sleep 2\n" >> /tmp/mountfs-"${1}".sh
fi
printf "write /sys/devices/virtual/bdi/179:0/read_ahead_kb 2048\n" >> /tmp/mountfs-"${1}".sh
####printf "echo 2048 >> /sys/devices/virtual/bdi/179:0/read_ahead_kb\n" >> /tmp/mountfs-"${1}".sh
### This looks for the partition type (defaulting to ext4) ###
mt1=` blkid ${firstpart} | cut -d '"' -f '4' `
mt2="${mt1}"
if [ ${mt1:-f2fs} = ext4 ]; then
printf "# check the first ext4 fs\n/bin/e2fsck -p ${firstpart} > /e2fsck.log\n" >> /tmp/mountfs-"${1}".sh
else
printf "# check the first f2fs fs\n/bin/fsck.f2fs -p ${firstpart} > /fsckf2fs.log\n" >> /tmp/mountfs-"${1}".sh
fi
if [ ${1} = DirectSD ]; then
if [ -b ${secondpart} ]; then
mt2=` blkid ${secondpart} | busybox cut -d '"' -f '4' `
else
echo "No 2nd ext partition present, format one and run script again"
fi
if [ ${mt2:-f2fs} = ext4 ]; then
printf "# check the second ext4 fs\n/bin/e2fsck -p ${secondpart} > /e2fsck2.log\n" >> /tmp/mountfs-"${1}".sh
else
printf "# check the second f2fs fs\n/bin/fsck.f2fs -p ${secondpart} > /fsckf2fs2.log\n" >> /tmp/mountfs-"${1}".sh
fi
fi
if [ ${mt1:-f2fs} = ext4 ]; then
mnt1flgs="-o rw,noatime,nodiratime,barrier=0 "
else
mnt1flgs="-o rw,flush_merge,discard,noatime,nodiratime,background_gc=on,inline_xattr,active_logs=2 "
#mnt1flgs=""
fi
printf "/bin/busybox mkdir -p /NativeSD\n/bin/busybox mount -t ${mt1:-f2fs} ${mnt1flags}${firstpart} /NativeSD\n# mount the data dir\n" >> /tmp/mountfs-"${1}".sh
if [ ${1} = DataOnExt ]; then
echo "Modifying for ${1}"
printf "/bin/busybox mount --bind /NativeSD/${2}/data /data\n" >> /tmp/mountfs-"${1}".sh
fi
if [ ${4} -gt '2' ]; then
printf "/bin/busybox mount --bind /NativeSD/${2}/system /system\n" >> /tmp/mountfs-"${1}".sh
if [ ${1} = NativeSD ]; then
echo "Modifying for ${1}"
printf "/bin/busybox mount --bind /NativeSD/${3}/data /data\n" >> /tmp/mountfs-"${1}".sh
else
if [ ${mt2:-f2fs} = ext4 ]; then
mnt2flgs="-o rw,noatime,nodiratime,barrier=0 "
else
mnt2flgs="-o rw,flush_merge,discard,noatime,nodiratime,background_gc=on,inline_xattr,active_logs=2 "
#mnt2flgs=""
fi
printf "/bin/busybox mkdir -p /DirectData\n/bin/busybox mount -t ${mt2:-f2fs} ${mnt2flags}${secondpart} /DirectData\n/bin/busybox mount --bind /DirectData/${3}/data /data\n" >> /tmp/mountfs-"${1}".sh
fi
fi
printf "systupd=\"/sdcard/NativeSD/${2}-${1}/update\"\nif [ ! -z \"\`ls \${systupd}/*\`\" ]; then\n cp \${systupd}/* /\n rm -rf \${systupd}/*\n reboot\nfi\n" >> /tmp/mountfs-"${1}".sh
printf "%b\n" "# cleanup deleting /bin to free ram\n /bin/busybox rm -rf /bin
" >> /tmp/mountfs-"${1}".sh
fi
}

This is the mkmountfs.sh function which makes a mountfs-"${1}".sh script.

Taking for example a DirectSD install of a rom called LolliP.

$1 will be DirectSD

$2 will be LolliP

$3 will be LolliP

$4 will be 4

$mt1 and $mt2 is the filesystem of mcblk0p2 and p3 determined earlier.

The above function will only run if /tmp/mountfs-DirectSD.sh doesn't exist.

When it is run it goes through the above and creates a /tmp/mountfs-DirectSD.sh file which will be added into the initrd.gz.

If you slip in the logcat code somewhere (after system and data are mounted) you should be able to get one.