[HTC EVO 3D] EarlyMon:
Cool. :)

OK - so here's the thing - it's my memory. Truth is - it pretty much sucks. Between that and copy and paste, I'm liable to screw up just about anything.

So - I've decided to script all of this.

I just couldn't wrap my head around using the fat32 SDcard for the unix mount points - even if that works, it just made me all ooogly to go that route. So I took your instruction and made the mount points on /data/local/ubuntu (just like bootubuntu) and cleaned my way out when done.

So, here's the deal:

Back up your ubuntu.img to your PC before starting (along with anything else)

run the script as a bash script, not as shell

I put mine in /sdcard/ubuntu

You can put yours somewhere in /system in your path and then just execute when you want - be sure that the first line is pointing to your bash and that you chmod the file correctly in the first place

What it does:

Asks if you've really just rebooted

Checks your free /sdcard space

Sets the minimum size at 2150 MB

Reduces the available free size by 500 MB (just for safety)

Prompts you for the size you want

Answer not Y for the boot question, or give it any grief over the size of the new image file, and it bails on you

Runs unCoRrUpTeD instructions and automagically answers the mke2fs question for you

Here's the script, I called mine /sdcard/ubuntu/ubuntu_sizer.sh

#! /system/bin/bash

# bash script to resize the ubuntu.img file used for Ubuntu on Android
#
# Real work on how to do this by unCoRrUpTeD at XDA
# (http://twitter.com/#!/unCoRrUpT3d) - see:
# http://xdaforums.com/showpost.php?p=16455543&postcount=101
#
# Interactive stuff added by EarlyMon (XDA, Android Forums) 2011 Aug 9

clear
echo "Ubuntu image resizer - Please be root!"
echo
echo "It is imperative that you ONLY run this immediately AFTER rebooting!"
echo -n "Tell the truth - did you just now reboot? [y/N] "
read rebooted

if [[ !( "$rebooted" =~ [Yy] ) ]]; then
echo "OK, try again after reboot, exiting."
exit
fi

cd /sdcard/ubuntu

sd_free=`df /sdcard | awk '{print $6}' | sed s/K$//`
# Convert to MB
sd_free=$[$sd_free/1000]
# Reserve 500 MB as a safety measure
sd_free=$[$sd_free-500]

ubuntu_size=`ls -l ubuntu.img | awk '{print $4}'`
ubuntu_size=$[$ubuntu_size/1000000]

# Pick a lower limit here for the image size
minimum=2150

echo "Existing Ubuntu image size: $ubuntu_size MB"
echo "Free space on SDcard: $sd_free MB"
echo -n "Target size in MB? (minimum: $minimum) "
read target

if [[ "$minimum" < "$target" && "$target" < "$sd_free" ]]; then

echo "Resizing ubuntu.img to $target MB"
echo
echo "Beginning resize - will reboot when done."
echo "Test ubuntu.img when complete - discard oldubuntu.img if happy"
echo
echo "Please be patient - image creation will take several minutes"
echo
echo "mke2fs prompt will be answered automagically"
echo

if [ ! -d /data/local/ubuntu ]; then
mkdir /data/local/ubuntu
fi
MOUNT=/data/local/ubuntu

mv ubuntu.img oldubuntu.img
dd if=/dev/zero of=ubuntu.img bs=1024000 count=$target

# DO NOT modify the indentation of the following herefile
# DO NOT allow trailing spaces after either use of the word
# END_HEREFILE -- be especially cautious of this with copy/paste

mke2fs ubuntu.img << END_HEREFILE
y
END_HEREFILE

# Strictly cosmetic
echo "y"

losetup /dev/block/loop1 ubuntu.img
losetup /dev/block/loop2 oldubuntu.img
mkdir $MOUNT/ubuntu
mkdir $MOUNT/oldubuntu
mount -t ext2 /dev/block/loop1 $MOUNT/ubuntu
mount -t ext2 /dev/block/loop2 $MOUNT/oldubuntu
cp -a $MOUNT/oldubuntu/* $MOUNT/ubuntu
umount $MOUNT/ubuntu
umount $MOUNT/oldubuntu
rmdir $MOUNT/ubuntu
rmdir $MOUNT/oldubuntu
reboot

else
echo "$target is not a good size"
cd -
exit
fi

How to run:

cd /sdcard/ubuntu
su
bash ubuntu_sizer.sh

How it looks after it's run:

# cd /sdcard/ubuntu
# bash
bash-4.1# bash ubuntu_sizer.sh

Ubuntu image resizer - Please be root!

It is imperative that you ONLY run this immediately AFTER rebooting!
Tell the truth - did you just now reboot? [y/N] y
Existing Ubuntu image size: 2147 MB
Free space on SDcard: 2964 MB
Target size in MB? (minimum: 2150) 2500
Resizing ubuntu.img to 2500 MB

Beginning resize - will reboot when done.
Test ubuntu.img when complete - discard oldubuntu.img if happy

Please be patient - image creation will take several minutes

mke2fs prompt will be answered automagically

2500+0 records in
2500+0 records out
2560000000 bytes transferred in 614.510 secs (4165920 bytes/sec)
mke2fs 1.41.11 (14-Mar-2010)
ubuntu.img is not a block special device.
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
156480 inodes, 625000 blocks
31250 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=641728512
20 block groups
32768 blocks per group, 32768 fragments per group
7824 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[COLOR="Blue"]EarlyMon$ <---this is the kickout to my machine after reboot[/COLOR]

Hope this helps!

Tested this all the obvious ways, worked for me.

Your mileage may vary. If in doubt, nandroid and then back up entire SDcard to PC.

This takes a LONG while to run. Just trust it, don't baby it. ;)

Cheers!

PS - I always forget about here-strings, so, oh well.