views:

41

answers:

2

I'm trying to re-partition an SDCard on Android, with root access.

I have the 512 byte MBR file, and it shows up as this:

 Pos MBRndx Type/Name  Size Active Hide Start Sector   Sectors
 --- ------ ---------- ---- ------ ---- ------------ ------------
  0    0    0C-FAT32X  5.9G   No    No            64   12,124,096
  1    1    0C-FAT32X  1.9G   No    No    12,124,160    3,932,160

What I'm trying to do is resize the 5.9GB partition into 3GB, and then make an EXT partition with the remaining space. I can think of two ways to do this, but I'm a bit stumped in doing either of them:

1) Cross-compile GNU parted, and run it on Android to modify the filesystem in place. This would be my preferred method, but I've been trying to statically compile parted using scratchbox and haven't had much luck, and I haven't been able to dynamically compile for Android in scratchbox either.

2) Directly modify the 512 byte MBR using some utility on my computer, and then dd the file on Android. I have a tool to view the MBR (mbrwiz), but I don't know how to edit it.

Does anybody have any suggestions for either, or possibly a third route?

+3  A: 

Maybe I'm not seeing the problem, but it does not look like you want to automate this or make a program with that functionality. So, why not take the SD card out of the Android device and partition it in a card reader on your desktop machine? You could even do a full backup beforehand and avoid losing any data with the partitioning.

Dubu
Ah.. I wish I could! This is a Samsung Galaxy S - The SD card is non-removable!
RyanZA
Well, I don't own that phone, and maybe the Galaxy S available in your country is different from the German one, but by googling I found a video (http://www.youtube.com/watch?v=ncMxv5AfJx0#t=2m40s) where someone inserted a new microSD card. It should be right next to the SIM card.
Dubu
Haha yeah, but it has an 8GB or 16GB internal memory too. At stock, it is formatted as in my question.
RyanZA
I've actually managed to edit the partitions using an fdisk binary I could port over -- but it turns out that the kernel will reset the MBR on boot! And of course, fdisk requires a reboot for the kernel to read the MBR changes! So I'm stuck needing to find a way to port gnu parted over to Android - and this seems to be very very difficult!
RyanZA
A: 

You could use fdisk instead of parted, as we used for years before the later tool came about.

Many of the android community roms include a busybox-based fdisk, which with care you could probably install without replacing the actual rom (which may not yet have a fully functional galaxy version)

Not sure how this helps the kernel changing it back problem. You could have a look in /init.rc and see if there's something you can comment out there (you would need to extract, modify, and reflash the ramdisk to make a change to that, splitting and recombining it from the kernel if they did it the same way as the htc phones)

It may also be possible to partition it with external tools when it's in usb mount mode - if the usb storage gadget just treats it as a sea of blocks, presumably you could put a partition table on it?

Chris Stratton