SDSPLIT repartition your SDcard on phone (w/o a PC)

Search This thread

MartinFick

Senior Member
Mar 12, 2009
214
2
Boulder, CO
www.theficks.name
!!!OBSOLETE!!! 2009-11-26: This script was very useful in the beginning, but is now obsolete. There are superior methods such as sdparted using better tools, and this script likely no longer works properly on modern builds.

As the title says, this script will repartition your sdcard so that you will have a FAT and an EXT2 partition. This is particularly useful for running apps off of the sdcard.

The app is called sdsplit, it has a strong focus on error prevention and recovery. Use at your own risk and please do let me know if you have any problems. As partitioning your card is inherently risky (especially if you are trying to preserve data from it), this script may help backup your data and any system config scripts which it modifies.

Instead of describing all of the features of the script, I will simply post the help message here since I spent a lot of time trying to make it comprehensive. The design of the script tries to make it easy for you to understand where a failure occurs if one does, and to pick up where you may have left off due to the failure after you work around it.


See the HowTo for Dummies for exact steps, but here is the general idea:

* Download sdsplit to your phone and give it execute permissions.
* Run script as root
* Do not run it from a subdirectory of /sdcard
* Run it with as few applications running as possible (to avoid having files open on the sdcard.)

The script logs its output to /data/sdsplit.log, please post the relevant bits from here if you encounter a problem and want help. But first, check out the FAQ for answers to most questions!!!


Code:
# sdsplit --help

Usage(v1.7):  sdsplit [options]


'sdsplit' will by default perform all of its default actions in sequence. Specifying a
specific action will tell sdsplit to only perform that action and skip the others.  You
may instead prefix an action with 'no' to prevent that specific action from being
performed while all the others are run.  For debugging purposes, all output of sdsplit
will be logged (appended) to /data/sdsplit.log

PREREQUISITES:

* This is desgined to work with the Jesus Freke updates (tested on JF1.43ADP/JF1.5).
Here is why you need a JF update:  for busybox, DNS, so the /init.rc invokes /system/init.rc,
and so the ext2.ko module is under /system/modules/2.6.27-00392-g8312baf/kernel/fs/ext2.

* If you are making a FAT partition greater than 2GB and have a pre1.5 android
environment, you will likely need a new 'mkdosfs' executable or internet access
from your phone so that sdsplit can download and install it for you.  If a capable
mkdosfs is not found somewhere in your path (or where specified by --pmkdosfs),
sdsplit will attempt to download and install it for you from my repo.  This executable
came from a Haykuro 1.5 build.

* Additionally, you will need a 'mke2fs' executable for arm-eabi or internet access
from your phone so that sdsplit can download and install it for you.  If mke2fs is
not found somewhere in your path (or where specified by --pmke2fs), sdsplit will
attempt to download and install it for you from my repo.  I got this executable from
here:  http://sites.google.com/site/juanjosec/android



ACTIONS:

 --backup|-b       Perform a backup of the /sdcard directory to /data/sdcard
 --nobackup|-nb    (See --pbackup)

 --config|-c       Configure the system to handle a new ext2 partition on the
 --noconfig|-nc    sdcard.  This involves adding mount options to /system/init.rc and
                   to /system/etc/mountd.conf along with creating the /system/sd mount
                   point for the ext2 partition on (see --pext2). Backups of the
                   original files will be made (.orig).  You should use this for
                   a JF1.5 build.

 --partition|-p    Wipe the partition table of the sdcard and create two new
 --nopartition|-np partitions, first a 500M FAT32 one (see --fatsize) and then
                   a Liunx one (for EXT2) on the remainder of the sdcard (see --ext2size).

 --mkfs|-mk        Make the FAT32 (see --fat[16|32]) and EXT2 filesystems. (partitioning
 --nomkfs|-nm      only allocates the space for them).  This requires the mke2fs
                   exectuable on the G1/ADP (see --pmke2fs).

 --restore|-r      Restore the original sdcard backup from /data/sdcard back to /sdcard
 --norestore|-nr

Along with the above actions there is one additional action if you do not care to
save your original sdcard data:

 --nodata|-nd      Equivalent to: --nobackup --norestore


OPTIONS:

 -h|--help                Usage (short) | Help (this)

 --forces|-f              Force exectution without prompting up front
 --forcemkfs|-fm          Force even if the mke2fs executable cannot be found and/or
                          if the mkdosfs executable is not suitable for large
                          partitions.
 --forceumount|-fu        Force even if partition already mounted at /system/sd.
                          Use with care, if you have an already existing EXT2
                          partition this will delete everything on it!!

 --fatsize|-fs SIZE[KM]   Set the size of the FAT partition in bytes, K or M.
                          (defaults to 500M)
 --ext2size|-es SIZE[KM]  Set the size of the EXT2 partition in bytes, K or M.
                          (default to the remainder)  If you set this, it will not
                          set the FAT parition to the remainder, it will remain
                          500M unless you explicitly set it to something else.
                          The only reason to use this is if you want to leave space
                          for another partition.

 --fat[16|32]             Make the FAT partition of type 16 or 32.  The default is
                          32 since 16 does not seem to work with my ADP.

 --pbackup|-pb PATH       Set the location of the sdcard backup dir.
 --pmke2fs|-pme PATH      Set the path to the mke2fs executable (if not already in
                          your PATH.)
 --pmkdosfs|-pmd PATH     Set the path to the mkdosfs executable (if not already in
                          your PATH.)
 --pext2|-pe PATH         Set the mount point for the new ext2 partition (defaults
                          to /system/sd)


COPYRIGHT:                Martin Fick <mogulguy@yahoo.com>  GNU GPL2 or above

ChangeLog:
v1.7 2009-05-10 (usability improvements)
* Prompt on startup (confirm requested actions), use -f to override.
* Log invocation string to sdsplit.log
* Removed error when sdcard is empty
* If no ext2.ko is found output a message instead of an error.
more...

 
Last edited:

tubaking182

Senior Member
Mar 28, 2008
1,081
10
WOW i don't need the script since i have my card partitioned, but i didn't even know this was possible. i congratulate your efforts and hope that this works for everyone. would certainly help people that have bad computers or USB lower than 2.0 on their computers. i really don't know what to say, i am looking at the script right now and it's about 10 levels above my coding ability. great job on this
 
U

unknown.soul

Guest
I was reluctant to try partitioning my SD card again after two failures, now I'll have to try this tomorrow. Thank you very much, MartinFick! :cool:
 

xtrip0dx

Member
Jan 23, 2009
14
0
i was beginning to wonder why this hasn't been done before...
i applaud you in your efforts sir, ill be sure try this tomorrow.
thank you
 

Binary100100

Retired Forum Moderator
Apr 6, 2008
6,470
1,649
Detroit, Mi
Has anyone tried this yet? I already have mine set up but I'm dying to know.

This could make LucidREM's job easier too!
 

All~G1

Senior Member
Jan 9, 2009
826
14
Great work MartinFick!!! I also have a partitioned card, but this is a great addition to the wonderful mods that already exsist in our community. I do hope it works and I'm sure it will help out many.

I refused an offer of $$$ to mod two phones (from root to apps on sd) because I lost the ability to use paragon (trial over), and "customers" not wanting to give their email address. Now that this may take care of that I might start doing it. I'll wait for reviews. Thanks again MartinFick!!!
 

kizer

Senior Member
Mar 31, 2009
926
9
www.links4jeeps.com
So if I read this correctly. Using the following command would give me a 1gig EXT2 partion and the rest goes to FAT32?

sdsplit -es 1000[M]

I'm not ready to try it since I don't have my 8gig card yet, but Id be willing to give it a go. ;)

Another question I notice it sets the default of the FAT to 500meg. Shouldn't that be the other way around? I mean if I dump tons of songs, videos and what not you would think that the majority of the card should be FAT to use it opposed to EXT2.
 

MartinFick

Senior Member
Mar 12, 2009
214
2
Boulder, CO
www.theficks.name
So if I read this correctly. Using the following command would give me a 1gig EXT2 partion and the rest goes to FAT32?

sdsplit -es 1000[M]

No, there is no simple way (that I know of) with fdisk to make the frist partition take a remainder of the disk, so that feature is only available to the second partition. Since the first partition (I believe) will need to be FAT for most hacks to work (and my script currently), that makes EXT2 the second one.

So you must figure out how big you want your FAT partition no matter what (default is 500M). The EXT2 partition can then either be the remainder of the disk or a smaller amount (if you later wanted a third partition.) If you have an 8G disk and you want only 1000M for the EXT2 partition, simply use:

Code:
sdsplit -fs 7000M

which will give you a 7G FAT and a remainder of 1G for the EXT2. Make sense? Since this was confusing, I will try to add a note about this.


Another question I notice it sets the default of the FAT to 500meg. Shouldn't that be the other way around? I mean if I dump tons of songs, videos and what not you would think that the majority of the card should be FAT to use it opposed to EXT2.

I guess that is probably a personal decision, I am not sure why we even need the FAT at all (except for interoperability with other devices)?

Due to the limitations that I explained in the first section, I could only hardcode a limit on the FAT partition, not the EXT2. And, since I figured that people with a 1G card would probably want at least 500M EXT2, I opted for the 500M FAT default.

If I figure out a clean way to specify the EXT2 size and let FAT be the remainder, I will consider your suggestion. I was basing the fact that FAT should be first on rules that I read in other threads (this is not an inherent disk partitioning limit). If someone could explain to me why (I assume other components in the android system expect this), perhaps this could be worked around? Another solution if FAT absolutely needs to be P1 and EXT2 P2, is to try and simply put P2 first on the partition (fdisk will usually let you do this.) This way, the EXT2 partition could be set to a fixed size and the FAT one could use the remainder (be second on disk,) but stay numbered P1. Anyone have any thoughts on that suggestion?
 

kizer

Senior Member
Mar 31, 2009
926
9
www.links4jeeps.com
Awesome. So basically set the FAT and the EXT2 would set its self to the rest. I by no means was questioning why you did it the way you did it. I just didn't have a clue and it makes complete sense now.

Like I said I can't try this the 7th because the cards I ordered do not arrive until then.
 

LPChris

Senior Member
Jul 14, 2007
207
0
So if we do select 7GB for the first partition, it'll format it FAT32 correct? As FAT can't use that much space.
 

MartinFick

Senior Member
Mar 12, 2009
214
2
Boulder, CO
www.theficks.name
Bug Fix Release Update

I update the original post with v1.1 which has some bug fixes in it. The partitioning worked fine in the original script, but my repeated testing seems to have masked some bugs in the automounting of the new partition.

Can somebody post a how to execute this coz i downloaded it and can't understand wat to do next

While I am more confident about this version (more personal testing), I would be happier if someone who knew how to recover from potential disasters (someone knows how to use recovery mode) and with a basic linux understanding tried it first.

But, to answer your question, download the new one first (v1.1 which I uploaded after you posted your question), then save this file (perhaps remove the .txt extension) to somewhere in your path (/data/local/bin), and give it execute permissions: chmod 777 /data/local/bin/sdsplit and run it specifying the size of the FAT partition that you want (sample for a 1G FAT partition):

Code:
sdsplit -fs 1000M 2>&1 | tee /data/local/tmp/sdsplit.log
 

raukodur

Senior Member
Apr 4, 2009
55
0
But, to answer your question, download the new one first (v1.1 which I uploaded after you posted your question), then save this file (perhaps remove the .txt extension) to somewhere in your path (/data/local/bin), and give it execute permissions: chmod 777 /data/local/bin/sdsplit and run it specifying the size of the FAT partition that you want (sample for a 1G FAT partition):

Code:
sdsplit -fs 1000M 2>&1 | tee /data/local/tmp/sdsplit.log

Hmm, you need to simplify it further for simpletons like myself.

What we need is a step by step (and I mean step by step, i.e. every single thing you need to do to your phone no matter how obvious) guide on what to to from downloading the app, to ending up with a partitioned SD card.

So, e.g, I have an 8gb SD card, I have some data on that card, I wish to make a partition of 1gb for the EXT2 part, and 7gb for the FAT32. I also dont wish to lose my data.

Should I manually copy my data to my computer, then format the SD card and run the app, or is there a built in thing in the app to backup the SD card (on what though?) and allow you to transfer it back after the partition?

Some questions to clarify (which is why the step by step guide for idiots is needed):

1) do you download the app via the app store, and install it on the phone, or do you download the app onto your computer and transfer to your SD card via USB cable?

2) Do you need to change the file (you say you MAY want to remove the .txt. extension, that a yes or a no?)

3) save the file to somewhere in your path? What does that mean? and where exactly?

4) How do you give it 'execute' permissions? By typing in "chmod 777 /data/local/bin/sdsplit", where do you type this in?

5) are all of these instructions carried out in the command / dos type area of the phone, where you can type in these controls? I am assuming so.

These are just some of the things I do not understand (sorry for my ignorance), which is why we need someone to really clarify the whole process so even a monkey can follow it.

I hope someone has the time and inclination, since I am really pissed of with the android since I ran out of space on my internal memory, makes me want to throw the phone away.
 

Lieu10ant

Senior Member
Nov 10, 2008
437
42
yeah :( i have the same questions as him ^^^^^

i have an 8 gig sd card. i want to have my EXT2 to have 800 MB and the rest FAT32. how much do i give the FAT32 portion?
 

borodin1

Senior Member
Jan 3, 2009
1,436
45
Minneapolis MN
First of all, THANK YOU! This is just what many people need. Great job on making it as simple as possible.
I too would second the request to give us a step by step directions on using this (ie press this button and then....(have to say this in Homer Sipmson's voice))
I could most likely figure it out myself but I don't want to take chances, especially since my card is alrealdy fomatted and works, I wouldn't mind changing the size of my partitions at some point but don't want to take risk of losing 110+ apps..

Once more, BIG THANKS for this piece, I'm sure a lot of people will use it.
 

faithnolonger

Senior Member
Jan 23, 2009
66
0
Martin I just want to say thank you on behalf of the community.

I reset my phone this evening and tested this out on JF rc33. It's brilliant. You've done a great thing here.

I hope you don't mind but I've posted a how to over on the android section of nokia apps at the request of a few users! Of course i linked to this page and gave full credit!