[G1 Q&A, Help & Troubleshooting] david1171:
How to easily esperiment with linux-swap partition sizes

So you want to try out different linux-swap sizes, but do not want to lose your data on your sdcard each time? Then this is the guide for you.

To start you will need you cyanogen's 1.4 recovery image (good thing you followed the above guide eh:)) and some basic math skill.

SETTING UP YOUR SDCARD

Well for this to work you will need to partition your sdcard a certain way, but only once for the entire card. BACKUP YOUR SDCARD!!!

To do this you will go into parted in the recovery console with these commands

parted /dev/block/mmcblk0
print

Do not leave this screen we will come back to it

After you type print you will want to look for the line that says

Now for the math. (i will explain some of the reason behind certain sizes then clear up the line)

first line in equation:

xxxxmb (total on card) - 96mb (it can be as large or as small as you want it but the highest i have seen people go with good results is 96mb)

so the first line will be:

xxxxmb - 96mb = zzzzmb

second line in equation:

zzzzmb - 500mb ( most people and guides suggest not to go over 500mb for ext2/3/4 so i shall do the same)

so the second line will be:

zzzzmb - 500mb = yyyymb

complete equation:

xxxxmb - 96mb = zzzzmb

zzzzmb - 500mb = yyyymb

;where xxxx = total mb (going to be the end point for linux-swap as well), zzzz= end point for ext2/ beginning point for linux-swap yyyy = end point for fat32/ beginning for ext2

So now with the equations out of the way (yes, I do like math, thank you very much) type this into recovery while still in parted

rm 1
rm 2 (if it exists)
rm 3 (if it exists)
(for the next commands obviously you will plug your own numbers in)
mkpartfs primary fat32 0 yyyy
mkpartfs primary ext2 yyyy zzzz
mkpartfs primary linux-swap zzzz xxxx
print (to verify it worked)
quit (ignore the update etc/fstab comment)
upgrade_fs
reboot

Now that was the hard part, the next part is really easy.

TO CHANGE LINUX-SWAP SIZES EASILY

With the setup above your linux-swap partition will be 96mb by default, to change it you will need to do the following

Go to the recovery console and type

parted /dev/block/mmcblk0
print

Again do not leave this screen for we shall return momentarily

After you type print, it will show you the sizes of your 3 partitions. The third partition is the one we want to look at. You will need to get the start and end points for this partition.

(for ease of writing this guide, x will be the start and y will be the end)

For a 64mb swap partition you will want to follow this equation:

y - 32mb = y* (y* will be the new endpoint)

For a 32mb swap partition you will want to follow this equation:

y - 64mb = y* (y* will be the new endpoint)

Now go back to your phone that is still in parted and type (of course you substitute in your numbers)

resize 3 x y*
quit (ignore etc/fstab comment)
reboot

There you go, that is how you quickly and easily change the size of your linux-swap partition without ever taking the sdcard out of your phone.

Also you will need to edit your user.conf and userinit.sh to reflect the new size of your linux-swap partition. Here are instructions for how to edit your user.conf. (thank you kingklick)