App Review: Calculating Your Android Calculator Options

Sure, everyone has a default Calculator and its something that you dont think about … more

MultiROM Once Again Available for the Galaxy S4

Multiboot, or the ability to select betweenmultiple operating systems on a single device at … more

Build an Impractical But Awesome Lego Mindstorm Dock

The vast majority of what we cover here on the XDA-Developers News Portal relates to … more

MultiROM Makes its Way Over to the HTC One (M8)

While browsing our forum, you will undoubtedly find more than a few enticing ROMs available … more
Post Reply

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

3rd April 2009, 05:48 AM   |  #1  
MartinFick's Avatar
OP Senior Member
Flag Boulder, CO
Thanks Meter: 2
 
214 posts
Join Date:Joined: Mar 2009
More
!!!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 by MartinFick; 26th November 2009 at 06:36 PM. Reason: Adding obsolete message
3rd April 2009, 06:51 AM   |  #2  
tubaking182's Avatar
Senior Member
Thanks Meter: 13
 
1,088 posts
Join Date:Joined: Mar 2008
Donate to Me
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
unknown.soul
3rd April 2009, 07:06 AM   |  #3  
Guest
Thanks Meter: 0
 
n/a posts
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!
3rd April 2009, 09:31 AM   |  #4  
Junior Member
Thanks Meter: 0
 
14 posts
Join Date:Joined: Jan 2009
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
3rd April 2009, 10:05 AM   |  #5  
Binary100100's Avatar
Retired Forum Moderator
Flag Detroit, Mi
Thanks Meter: 1,122
 
5,453 posts
Join Date:Joined: Apr 2008
Donate to Me
More
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!
3rd April 2009, 01:20 PM   |  #6  
LucidREM's Avatar
Senior Member
Flag Baltimore
Thanks Meter: 5
 
1,569 posts
Join Date:Joined: Jan 2009
More
Quote:
Originally Posted by MartinFick

Well, here is my paltry contribution to the community. I spent entirely too much time on this! I hope it can help at least one person.

ok .. so maybe you DID spend entirely too much time but i would hardly call it paltry .. just skimming thru the code .. looks pretty nice .. i'm sure people will be happy to have the assistance
3rd April 2009, 03:48 PM   |  #7  
Senior Member
Thanks Meter: 12
 
806 posts
Join Date:Joined: Jan 2009
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!!!
3rd April 2009, 06:47 PM   |  #8  
mlevin's Avatar
Senior Member
Flag Fairfax, VA
Thanks Meter: 0
 
290 posts
Join Date:Joined: Dec 2008
More
Wow, I'm very impressed. Nice work.
3rd April 2009, 07:08 PM   |  #9  
kizer's Avatar
Senior Member
Thanks Meter: 9
 
919 posts
Join Date:Joined: Mar 2009
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.
3rd April 2009, 07:34 PM   |  #10  
MartinFick's Avatar
OP Senior Member
Flag Boulder, CO
Thanks Meter: 2
 
214 posts
Join Date:Joined: Mar 2009
More
Quote:

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.


Quote:

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?

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes