[G1 Android Development] 51dusty:
this script automates the process of partitioning a sdcard on your android device. it should work fine for all sizes/types of sdcards, but since i can't test all sizes/types of sdcards, we'll have to see. ;)

if you are running into problems with the script, post the log file(located at /data/sdparted.log) when asking for help.

big ups to cyanogen (parted and upgrade_fs) and Denkai (upgrading to ext4).

i welcome all comments, questions & suggestions, related to the script. this is NOT a general q&a.

read the ENTIRE post BEFORE asking questions, please.

to manually partition your sdcard see my other thread.

DISCLAIMER: i take no responsibility for what happens to you, your phone, sdcard, data, sanity, etc if you use this script. remember to backup your sdcard to your pc before you begin. this script has the potential to COMPLETELY WIPE your sdcard!

##########################

shameless promotion:

sdparted can also be found in amon_ra's recovery and natalic's android toolkit.​

##########################

features:

-automated partition of sdcard using parted

-upgrading to ext3/ext4

-downgrading to ext2

-interactive mode

-supports units (M and G)

-supports floating point partition sizes (ie. .5G=512M)

-automatic logging to /data/sdparted.log​

##########################

requirements:

android phone with proper utilities(cm-recovery-1.4, amon_ra's recovery)

sdcard <--class 6 recommended(adata makes good ones...they max out the g1 hw in terms of speed)

adb

fingies​

##########################

sdparted v0.6 created by 51dusty

if you use this script in your work, please give some credit. thanks.

requirements: cm-recovery-v1.4

usage: sdparted [options]

options:

--fatsize|-fs SIZE[MG] set the size of the fat32 partition to <SIZE>.
default=total sdcard size - (ext + swap)

--extsize|-es SIZE[MG] set the size of the ext partition to <SIZE>.
default=512M

--swapsize|-ss SIZE[MG] set the size of the swap partition to <SIZE>.
if set to 0, no swap partition will be created.
default=32M

--extfs|-efs TYPE set the filesystem of ext partition to <TYPE>.
valid types=ext2, ext3, ext4
default=ext2

--upgradefs|-ufs TYPE upgrades existing ext partition to <TYPE>.
this operation will NOT wipe your sdcard and
cannot be used with any partition creation options.
valid types=ext3, ext4

--downgradefs|-dfs TYPE downgrades existing ext partition to <TYPE>.
this operation will NOT wipe your sdcard and
cannot be used with any partition creation options.
valid types=ext2

--interactive|-i interactive mode

--help|-h display this help

--printonly|-po display sdcard information

--silent|-s do not prompt user, not even initial warning.

examples:
sdparted creates swap=32M ext2=512M fat32=remaining free space
sdparted -efs ext4 creates swap=32M ext4=512M fat32=remaining free space
sdparted -fs 1.5G -efs ext3 creates swap=32M ext3=512M fat32=1536M
sdparted -es 256M -ss 0 creates no swap ext2=256M fat32=remaining free space
sdparted -ufs ext4 upgrades ext partition to ext4

##########################

need to backup your ext partition?

the following commands will backup/restore your ext partition to/from a folder named sdbackup in your current directory. these must be run while phone is booted, not recovery.

to backup your ext partition: adb pull /system/sd/ %CD%\sdbackup

to restore back to sdcard: adb push %CD%\sdbackup /system/sd

##########################

to run from computer:

1. download sdparted.txt below to computer

2. connect g1 via usb

3. boot into cm-recovery-v1.4, goto console(alt-x)

4. at your windows cmd prompt type: adb push /path-to/sdparted.txt /sbin/sdparted

5. then type: adb shell chmod 755 /sbin/sdparted

6. to run type adb shell and hit enter.

7. you can now run script (ie. sdparted -efs ext4).​

to run w/o computer:

1. download sdparted.txt below to root of sdcard. (get downloadcrutch if needed*thnx lycoln)

2. boot into cm-recovery-v1.4, goto console(alt-x)

3. at # prompt type: mount /sdcard

4. then, mv /sdcard/sdparted.txt /sbin/sdparted

5. then, chmod 755 /sbin/sdparted

6. you can now run script (ie. sdparted -efs ext4).​

you CANNOT run this script from terminal app.

##########################

if the script crashes or you receive an error:

immediately pull the log to your computer(using adb pull /data/sdparted.log sdparted.log), b/c the log will not be there after a reboot. send me the log when reporting errors, please.

##########################

changelog:

changes in v0.6

*new feature=interactive mode

*tweak user abort function for those with itchy fingers

changes in v0.5.3

*remove initial warning(kinda pointless if there is another before you wipe)

*clean partition table handling code

*general code cleanup/consolidation in anticipation of new features

changes in v0.5.2

*handling of "partition 1 may not be aligned to cylinder boundaries", fixing "sh: -gt: argument expected" and related phenomena (ie. sdparted trying to partition using negative numbers :eek: ) reported by midtoad

changes in v0.5.1

*slight change to logging(so slight it only gets a .1), fixing "/sbin/sdparted: line 5: .//sbin/sdparted: not found"

changes in v0.5

*new feature=floating point partition sizes

*new feature=downgrade ext filesystem (ext3->ext2 ONLY, for now)

*fix some crappy programming

changes in v0.4

*unmount all partitions before operations, fixing "Error: Partition(s) on /dev/block/mmcblk0 are being used".

*remove some useless code

changes in v0.3

*new feature=logging

*new feature=units

*new feature=print card info

changes in v0.2

*add cm-r-v1.4 check to prevent running in 1.3.1

##########################

todo items:

-downgradefs support for ext4

##########################