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

Search This thread

ICBM

Senior Member
Feb 10, 2009
66
0
Hey MartinFick... I tried this out, and it basically stops after a while. Here's a capture of the Term Emulator output. Would the log file be more useful?

As you can see, at the very end, it throws a warning and just stops. I'm not sure what to do with it now.

$ su
# sdsplit -nd -fs 7126M 2>&1 | tee /data/local/tmp/sdsplit.log
--------------------------------------
+Cannot find mke2fs executable, see if we can download it from http://www.theficks.name/bin/lib/droid/mke2fs
Connecting to www.theficks.name (64.105.21.209:80)
mke2fs 100% |*******************| 247k 00:00:00 ETA
--------------------------------------
+Backing up and Updating /system/init.rc
--------------------------------------
+Backing up and Updating /system/etc/mountd.conf
--------------------------------------
+Partitioning sdcard
--------------------------------------
+ Backup partition table/wipe/create FAT32 7126M/create EXT2

The number of cylinders for this disk is set to 1957.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that the previous content
won't be recoverable.

The number of cylinders for this disk is set to 1957.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): Command action
e extended
p primary partition (1-4)
Partition number (1-4): First cylinder (1-1957, default 1): Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1957, default 1957):
Command (m for help): Selected partition 1
Hex code (type L to list codes): Changed system type of partition 1 to b (Win95 FAT32)

Command (m for help):
Disk /dev/block/mmcblk0: 8017 MB, 8017412096 bytes
186 heads, 43 sectors/track, 1957 cylinders
Units = cylinders of 7998 * 512 = 4094976 bytes

Device Boot Start End Blocks Id System
/dev/block/mmcblk0p1 1 1741 6962237+ b Win95 FAT32

Command (m for help): Command action
e extended
p primary partition (1-4)
Partition number (1-4): First cylinder (1742-1957, default 1742): Using default value 1742
Last cylinder or +size or +sizeM or +sizeK (1742-1957, default 1957): Using default value 1957

Command (m for help): Partition number (1-4): Hex code (type L to list codes):
Command (m for help):
Disk /dev/block/mmcblk0: 8017 MB, 8017412096 bytes
186 heads, 43 sectors/track, 1957 cylinders
Units = cylinders of 7998 * 512 = 4094976 bytes

Device Boot Start End Blocks Id System
/dev/block/mmcblk0p1 1 1741 6962237+ b Win95 FAT32
/dev/block/mmcblk0p2 1742 1957 863784 83 Linux

Command (m for help): The partition table has been altered!

Calling ioctl() to re-read partition table
failed.
--------------------------------------
+Creating FAT32 Filesystem
opening /dev/block/mmcblk0p1
lseek returned -1
meta data exceeds file system size
warning: FAT type limits file system to 2151677903 sectors
 

MartinFick

Senior Member
Mar 12, 2009
214
2
Boulder, CO
www.theficks.name
Sorry, I am not sure why the partition table was not able to be re-read.

No need for the log file, that should be enough info. If you still have access to your command prompt, you may be able to complete the process by rerunning the script like this:

# umount /sdcard
# sdsplit -m 2>&1 | tee /data/local/tmp/sdsplit2.log

Let me know if that works.

Thanks for the report perhaps that is the same thing that SolemnWishing saw. I have an idea what might be the problem, but I cannot be sure. I think there is a timing issue, I will look for a way to avoid a race.
 

ICBM

Senior Member
Feb 10, 2009
66
0
Same result -
--------------------------------------
+Creating FAT32 Filesystem
opening /dev/block/mmcblk0p1
lseek returned -1
meta data exceeds file system size
warning: FAT type limits file system to 2151677903 sectors
 

MartinFick

Senior Member
Mar 12, 2009
214
2
Boulder, CO
www.theficks.name
It appears that the partitioning succeeded, so the sizes should be preserved. If a filesystem is mounted on a drive that is repartitioned, the kernel will refuse to reread the partition table, this appears to be the case, but I don't know why anything would be mounted, the script should have unmounted everyting or spit out an error. Perhaps a mount daemon remounted the dos fs instantly somehow and prevented the table reread in which case you may need to reboot, but I am not sure that is a good idea (if things will boot correctly). It should be safe for you to rerun the partitioning and mkfs actions as many times as it takes to get it to work like this:

# sdsplit -p -fs 7168M -m 2>&1 | tee /data/local/tmp/sdsplit2.log
 

ICBM

Senior Member
Feb 10, 2009
66
0
I can't unmount through the front end. I'll try restarting, unmounting the SD card, then running

sdsplit -p -fs 7168M -m 2>&1 | tee /data/local/tmp/sdsplit2.log

Make sense?
 

ICBM

Senior Member
Feb 10, 2009
66
0
No luck. Updated log - albeit, it doesn't look like it's different at all. I'm going to try to restore my nandroid backup, then try it again.

$ su
# sdsplit -p -fs 7168M -m 2>&1 | tee /data/local/tmp/sdsplit4.log
--------------------------------------
+Partitioning sdcard
--------------------------------------
+ Backup partition table/wipe/create FAT32 7168M/create EXT2
WARNING: /data/local/tmp/partitions.orig backup /data/local/tmp/partitions.orig.orig already exists!

Do you want to overwrite it? y/N
y

The number of cylinders for this disk is set to 1957.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that the previous content
won't be recoverable.

The number of cylinders for this disk is set to 1957.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): Command action
e extended
p primary partition (1-4)
Partition number (1-4): First cylinder (1-1957, default 1): Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1957, default 1957):
Command (m for help): Selected partition 1
Hex code (type L to list codes): Changed system type of partition 1 to b (Win95 FAT32)

Command (m for help):
Disk /dev/block/mmcblk0: 8017 MB, 8017412096 bytes
186 heads, 43 sectors/track, 1957 cylinders
Units = cylinders of 7998 * 512 = 4094976 bytes

Device Boot Start End Blocks Id System
/dev/block/mmcblk0p1 1 1751 7002227+ b Win95 FAT32

Command (m for help): Command action
e extended
p primary partition (1-4)
Partition number (1-4): First cylinder (1752-1957, default 1752): Using default value 1752
Last cylinder or +size or +sizeM or +sizeK (1752-1957, default 1957): Using default value 1957

Command (m for help): Partition number (1-4): Hex code (type L to list codes):
Command (m for help):
Disk /dev/block/mmcblk0: 8017 MB, 8017412096 bytes
186 heads, 43 sectors/track, 1957 cylinders
Units = cylinders of 7998 * 512 = 4094976 bytes

Device Boot Start End Blocks Id System
/dev/block/mmcblk0p1 1 1751 7002227+ b Win95 FAT32
/dev/block/mmcblk0p2 1752 1957 823794 83 Linux

Command (m for help): The partition table has been altered!

Calling ioctl() to re-read partition table
fdisk: WARNING: rereading partition table failed, kernel still uses old table: Device or resource busy
failed.
--------------------------------------
+Creating FAT32 Filesystem
opening /dev/block/mmcblk0p1
lseek returned -1
meta data exceeds file system size
warning: FAT type limits file system to 2151677903 sectors
 
Last edited:

madetosink

Member
Mar 26, 2009
24
1
Nashville
Uhh Ohh

So I tried this and achieved a similar result as ICBM...basically the card is useless as it will not show up when in phone through USB cable. I don't have a card reader on hand that I can use to reformat it...so it's an extremely light paperweight right now. I've been searching for a way to format it through the G1, but to no avail. Any suggestions would be appreciated, but worst case scenario is I have to wait a day or two. Basically, everything went smooth until I entered

A) # sdsplit -fs size 2>&1 | tee /data/local/tmp/sdsplit.log

B) # sdsplit -nd -fs size 2>&1 | tee /data/local/tmp/sdsplit.log

It started copying everything to the phone and ran out of room. Any ideas? Should I have formatted the card first and then attempted this?

Edit: Also the phone itself will not show up on computer. Drivers cannot be found...no matter what I choose.
 

ICBM

Senior Member
Feb 10, 2009
66
0
OK, I've been working through this with Martin, then some more on my own. It looks like my phone starts screwing up when i try to create a FAT partition of more than 7000M. The script works like a champ for -fs 7000M, but not for any more. It's kind of weird.

Anyways, 7000M is fine for me, so no issues. Can someone else try this and make sure my issue isn't SD Card or Phone specific?
 

ICBM

Senior Member
Feb 10, 2009
66
0
Hey madetosink. I'm assuming you have a bigger card, with a lot of data. You really want to use your computer to back up the card, and use the B) option. This will ensure no backup is created on your phone potentially using up a bunch of space.
 

MartinFick

Senior Member
Mar 12, 2009
214
2
Boulder, CO
www.theficks.name
HowTo for Dummies

I moved this here because I was running into character limits in the original post and did not want to keep fighting it.

!!!WARNING!!! 2009-06-05: While this procedure seems to be fairly reliable from the reports, I feel that it is only fair to point out that those who do not read the instructions and follow them properly sometimes create serious problems with their phones (looping after rebooting), when performing this action on a 1.5+ build, in conjunction with a non unionfs apps2sd procedure.

When performing this action on a 1.5+ build, your phone may end up believing that your sdcard is damaged. Of course, it is not, you just happened to repartition it from underneath your phone. It may then continue to request that you reformat the sdcard, if you do this, of course, you will undo what the sdsplit script just did!

Now this in itself should not be a major problem, it would put you right back where you started. However, if you have in the mean time done an apps2sd conversion (which is what most of the people seem to be using this script for) without unionfs, then you now have a dependency on your EXT2 partition which you have just potentially wiped away with the phone GUI popup reformat option! The result of this is that your phone will not boot properly and it will loop at the android logo.

The moral of the story: DO NOT REFORMAT YOUR SDCARD FROM THE PHONE'S POPUP GUI after using this procedure!!! -> Reboot your phone instead to eliminate this nagging prompt!

--------------------------------------------------------------------

Please read through all these steps before continuing (including the warning above!). If you have a problem, please see the Problem Report section at the bottom before asking a question!!!

1) Install a JF update (beyond the scope of this HowTo) see: http://xdaforums.com/showthread.php?t=475381
(if you want to try another build, read the prerequisites in the help of the first post)

2) Install the sdsplit executable to your phone. To so this, open the 'terminal' application and type the following commands at the prompts:
(Note: you will need an internet connection on your phone for this step)

$ su
# cd /data
# wget http://64.105.21.209/bin/lib/droid/sdsplit
# chmod 555 sdsplit
# exit

3) Decide the size of your FAT partition:

You should use one of two approaches to decide the size of your FAT partition. The first one involves simply directly deciding this size (i.e. I want a 5G FAT partition). In this case, the EXT2 partition will be the remainder of the card.

The second method is based upon the fact that you want to decide the size of the EXT2 partition and would like the FAT partition to be the remainder of the card. In this case, the size of the FAT partition will be based on the size of your sdcard and the size of the EXT2 partition that you want. Use this formula to calculate it:

size_of_sdcard - size_of_ext2_partition = size

So, if you have an 8G sdcard and want 1GB of space for apps on your EXT2 partition, use 7000M for the FAT size.

No matter which method you use, you will need to specify either bytes (no parameter), K or M. So, for a 5G partition would use a 5000M size parameter.

Note: The size parameter is currently case sensitive, use 7500M, not 7500m!


4) Decide on a FAT partition backup strategy, I will outline two:
A) I have minimal data on my FAT partition (almost new phone) and will not be upset if something goes wrong and it gets deleted.

B) I have a lot of data on my FAT partition or I really will be upset if it is lost. 'A lot' is defined as more than can be backed up on your internal /data drive.

Note: To figure out how much data (in K) you have on you FAT partition, you can type the following in your terminal:

$ du -s /sdcard

Note: to find out how much free space is left on your /data partition type (see available):

$ df /data



The remainder of the steps will be split into A & B depending on what you answered above.

5) Backup your data:
If you chose 4A) you do not have to do anything special, sdsplit will take care of things and give you an error message if it can't (if you have too much data to back up.)

If you chose 4B) you should now use your PC to backup you sdcard (beyond the scope of this HowTo).

6) Run sdsplit. Use the size from step 3 below (do not forget the M in size if you are specifying megabytes):
(Note: you will need an internet connection on your phone for this step)
$ su

Note: If you are using the 1.5+ update, you should put a -nc at the end of the commands below since system configuration is not needed! Also, if you see a nagging "sd card is damaged" notification after completing this step, reboot your phone (later) to eliminate it. DO NOT REFORMAT YOUR CARD FROM THE POPUP on your phone or you may prevent your phone form booting!!!

If you chose 4A) # /data/sdsplit -fs size
or
If you chose 4B) # /data/sdsplit -nd -fs size

You will see a message describing the actions you have invoked. If you agree with them type y, if not, type n and start this step over with the correct command.

# exit

Please, remember to record the output of this stage if you run into a problem. There will be a permanent record of it in, /data/sdsplit.log. I really need to see the relevant lines from this if you want any help!!! Also, please post your exact command line entered above.



7) Restore/cleanup your data
If you chose 4A) When sdsplit is done, it should prompt you if you want to delete your data backup form /data/sdcard. If you do not see any error messages in your output you may enter yes now, or delete things manually yourself later when you are comfortable that things are good (you did want more room on your partitions right?) Manual delete (to do when you feel secure, if you chose no):

$ su
# rm -r /data/sdcard
# exit

If you chose 4B) Restore your data from your PC. (Again, beyond the scope of this HowTo).


8) You're done! You should have two partitions now on your sdcard. The FAT one mounted at /sdcard and the EXT2 one mounted at /system/sd.

--------------------------------------------------------------------
DO IT AGAIN:

If you simply want to change the size of your partitions because you are not happy with them after the first run, and you have not wiped or reinstalled your system in the mean time, repeat step 6 with the -fu and -nc options at the end. Be aware that this will delete any data you have put on the EXT2 partition. You may do this as many times as you like.

If you chose 4A) # /data/sdsplit -fs size -fu -nc
or
If you chose 4B) # /data/sdsplit -nd -fs size -fu -nc

--------------------------------------------------------------------
PROBLEM REPORTS:

First step, check out the FAQ for answers to most questions!!!

If your run into any serious problems, try to send me the file /data/sdsplit.log if you can get it off your phone. One easy way to do this is:
$ su
# cat /data/sdsplit.log

Then you can use the menu email option to email the output to me or yourself so that you can post it.

The amount of inadequate problem reports is too high for me to continue supporting things at this rate. If you do not have real data posted about your problem: at least your command line typed, and preferably the appropriate portion of the log file, I will start ignoring your reports. If you don't get a response, consider this as a possible reason why (or your questions has been already answered and explained). If you feel like your question is similar, but not the same as one already asked/explained, please be sure to explain why so that I can see that you at least attempted to figure things out on your own. For those of you who understand all this well already, sorry for the lecture and please believe me when I say that many others do not seem to get this. :)

Lastly, please do not post questions about apps to sd here (unless they are specific to sdsplit). I have not yet done this (apps2sd) and I will not help you. Yes, there are many other threads about this, yes they are large, that is not an excuse to post your questions here. Please be considerate and keep this thread on topic.

 
Last edited:

madetosink

Member
Mar 26, 2009
24
1
Nashville
Yeah its a 4gb sdhc card..There was about a gig worth of stuff on there. Ill try again once it's formatted and let u guys know what happens..

Sorry meant to ask...is there a way to actually format the card through term emulator...I mean basically just start over again...format to FAT32 and then try again? If not no worries
 
Last edited:

MartinFick

Senior Member
Mar 12, 2009
214
2
Boulder, CO
www.theficks.name
OK, I've been working through this with Martin, then some more on my own. It looks like my phone starts screwing up when i try to create a FAT partition of more than 7000M. The script works like a champ for -fs 7000M, but not for any more. It's kind of weird.

Yes, that is very weird. I don't know why there would be a 7G limit? Thanks for figuring that out and being patient.

Also, I believe that when you ran it the first time with the wrong size and it succeeded it cause the subsequent times to fail. I just tested that myself and do see problems.

When I originally designed it, I was leery of making it too easy to start over once there existed and EXT2 partition since it would mean data loss on that partition. I just redesigned it to have a check for this case up front and if so, to quit. This will making a user have to choose to force it if they really want to do this.
 
Last edited:

MartinFick

Senior Member
Mar 12, 2009
214
2
Boulder, CO
www.theficks.name
Basically, everything went smooth until I entered

A) # sdsplit -fs size 2>&1 | tee /data/local/tmp/sdsplit.log

B) # sdsplit -nd -fs size 2>&1 | tee /data/local/tmp/sdsplit.log

You were supposed to pick either A or B depending on your backup choice! I am sorry if that was unclear, I updated the HowTo to make this a little more obvious. I am guessing that you wanted option B and ended up running option A since it was listed first. But, if you actually wanted option B, did you first backup your data to the PC?

If this is indeed what happened, and you do have backed up data on your PC, you just need to get things formatted properly now. Try downloading the new 1.3 version and run it like this:

# sdsplit -m -p -fs size 2>&1 | tee -a /data/local/tmp/sdsplit.log
# mount /dev/block/mmcblk0p2 /system/sd

That should probably complete things for you. Then you can restore from your PC.

If you do not have that 1G backed up on your PC, was that a conscious decision, or was there something unclear in my HowTo that made you think you didn't need it in your case? (I ask so that I can fix it)
 
Last edited:

madetosink

Member
Mar 26, 2009
24
1
Nashville
Reading back through the instructions I see where I made the mistake...

I didn't lose anything important during this process...I thought A formatted and B partitioned...so now I should try v1.3? When I put that card in my phone doesn't even recognize it I don't think.
 

SolemnWishing

Senior Member
Feb 26, 2009
642
12
Oregon
Sorry for your problems, can you post the error or email me the log file, were you able to capture the log file?

It should not be too hard to recover your disk by simply reformatting it, either on windows or on the G1. I will gladly work with you to solve this, but I need more info.

First off, I would like to say thank you. Not only did you reply quickly you are quick to help. Unfortunately, I have given up this for now. As, after the failed repartition, my G1 actually was unable to boot and would hang at the boot screen, so I had to wipe everything and reinstall JF 1.42, and I did this several times as I tried many times to repartition the card. However, in the end it still didn't work. I should have kept an error log, but I didn't next time I attempt this I will let you know!

Thanks,
Solemn

PS: I believe this is a user error and a fault on my side, not your script.
 

MartinFick

Senior Member
Mar 12, 2009
214
2
Boulder, CO
www.theficks.name
Reading back through the instructions I see where I made the mistake...

I didn't lose anything important during this process...I thought A formatted and B partitioned...so now I should try v1.3? When I put that card in my phone doesn't even recognize it I don't think.
Yeah, I see how you could interpret it that way. I just updated it more, is it much clearer?

It's OK if your phone doesn't recognize it now. Yes, with 1.3, I think the instructions in my previous post will fix it. Let me know if they don't.
 

MartinFick

Senior Member
Mar 12, 2009
214
2
Boulder, CO
www.theficks.name
First off, I would like to say thank you. Not only did you reply quickly you are quick to help. Unfortunately, I have given up this for now. As, after the failed repartition, my G1 actually was unable to boot and would hang at the boot screen, so I had to wipe everything and reinstall JF 1.42, and I did this several times as I tried many times to repartition the card. However, in the end it still didn't work. I should have kept an error log, but I didn't next time I attempt this I will let you know!
Sounds like you did the right thing to recover. Is your card OK? Out of curiosity, what size card is it? What size FAT partition were you making?
 

jordiga

Member
Apr 7, 2009
18
0
Question

I have read on your instructions that you need a JF version and I was wondering why. Shouldn't an ADP1 1.1 with busybox be enough? I was about to try it this evening, but you scared me a little with the requirements. My SD card is brand new, so no data to loose if something goes wrong. Any suggestions?