[UTIL] sdparted v0.6 - easy sdcard partitioning, upgrading to ext3/4

Search This thread

51dusty

Senior Member
Feb 11, 2009
144
13
bville, md
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


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

Code:
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

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

Attachments

  • sdparted.txt
    15.7 KB · Views: 15,053
Last edited:

SyXbiT

Senior Member
Aug 29, 2007
139
3
great.
i'm new to android, so i have a question.
I'm guessing when you go to settings and eject SD card, it only unmounts the FAT32 partition, right?
So does that mean the only safe way to eject the card is shutting down?

great job!
 

Chahk

Senior Member
Apr 11, 2009
1,373
234
New York
Samsung Galaxy Z Fold 5
great.
i'm new to android, so i have a question.
I'm guessing when you go to settings and eject SD card, it only unmounts the FAT32 partition, right?
So does that mean the only safe way to eject the card is shutting down?

great job!

That depends which ROM you are running and how it's set up. CyanogenMod for example, will automatically use the Ext partition for Apps-to-SD if it finds one. Ejecting a card while the phone is using it as part of its internal memory would be a Bad Thing™.

If you are running the stock firmware, it would be safe to remove the card after ejecting it in settings.
 

htcclay

Inactive Recognized Developer
Sep 7, 2008
841
376
Atlanta
Could anyone at their convenience post directions for using this with console,
and where to place text attached? Funny, I've done this the manual way but don't know the simple things.
Thanks in advance for your work and patience. =)
 
Last edited:

crunkcory

Senior Member
Jul 29, 2007
81
0
sacredsoul, Make sure you have the latest Cyanogen's Recovery Image, which I used 1.4. I got the same error using 1.31. I then updated to 1.4 and it worked perfectly. great Post 51dusty.
 

pReTTyUnG1

Senior Member
Mar 13, 2009
65
0
i am tryin to do this...hw do i get in recovery mode and wat exactly im i typin?..i hav a 4gig
 

ctheory83

Senior Member
May 28, 2009
106
13
Tampa
I don't get it, am I mounting first, placing the file on the SD, then rebooting into recovery? The instructions make it sound as if I can just boot into console and pull it off my machine. Many people might find that confusing.
 

51dusty

Senior Member
Feb 11, 2009
144
13
bville, md
I don't get it, am I mounting first, placing the file on the SD, then rebooting into recovery?
...i don't say to mount anything.


The instructions make it sound as if I can just boot into console and pull it off my machine.
actually, you can...but you push instead.
to install from computer, download, boot into cm-recovery-v1.4, goto console, and adb push /path-to/sdparted.txt /sbin/sdparted, then adb shell chmod 755 /sbin/sdparted. you can now run the script from adb(in recovery) or from g1 recovery console.


i will edit post to make installation less "confusing"...done.
 
Last edited:

NSingh95

Senior Member
Aug 8, 2009
217
8
Columbus, OH
Hey dusty i been struggling with this for like a week now and finally decided to post! so i got the adb thing running on my pc, windows 32-bit and it finds my device when i put the command "adb devices", so that far im fine but then your instructions tell us to boot the phone into recovery console and the type "adb shell" the result comes up "no adb found", at this point i have tried it with my phone plugged into the pc and unplugged without mounting it from the G1... please help what am i doing wrong im really confused! thanks!
 

NSingh95

Senior Member
Aug 8, 2009
217
8
Columbus, OH
The script is great i finally figured it out how to work this thing, but i just a bit of an issue now, when i keep installing apps my internal storage is also getting reduced a bit, i have installed about 100mb of apps and my internal storage reduced to 67 from 70mb, i have already cleared cache, using the app to move it to sd card, and also turned my phone off and took out the battery and rebooted, but its standing at 67mb... does this possibly have anything to do with protected apps??? please help!!
 

ronaldraygun

Member
Mar 23, 2007
16
0
so my problem is that im not quite sure on what you mean by the path in the following command

adb push /path-to/sdparted.txt /sbin/sdparted

i know that you mean where ever the file is located but, for instance i just put mine in the c drive, so it should be adb push /c drive/sdparted.txt /sbin/sdparted

what is the correct way that should look?

edit: ok so i found my problem, i tried to install it from the adb shell, that was wrong, and this is the string in windows cmd i used for sdparted located just on the c drive
"adb push %cd%\sdparted.txt /sbin/sdparted" it then says the speed it was written, etc. does that mean it is correctly installed? from here, im not too sure how to go about setting up my partitions, again im very new to this.
 
Last edited:

51dusty

Senior Member
Feb 11, 2009
144
13
bville, md
Everything went okay, only the last stap with running from adb i dont understand.

What command is that ?

i have edited first post to clarify how to run.

to run, from adb:
1. boot into cm-recovery-v1.4, goto console(alt-x)
2. at windows prompt, type adb shell and hit enter.
3. once connected via adb, you can now run script (ie. sdparted -efs ext4).
 

Top Liked Posts

  • There are no posts matching your filters.
  • 5
    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


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

    Code:
    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

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

New posts