[How-to] How I expanded my app storage (repartitioning)

Search This thread

eldarerathis

Senior Member
Jun 21, 2010
159
316
I took some time today to play with the partition layout on my Kindle Fire and I decided I wanted to share my method in case anyone else found it interesting. The reason I did this is because I know that I'm not going to be putting much of anything onto the KF's /sdcard directory. Instead of having 1 GB for data/apps (and books?) and 5 GB for media, I wanted to more-or-less reverse those numbers. What I settled on was 4.5 GB for data/apps and about 1.7 GB of "external" storage. In other words, I can install 4 times as many apps as I could have on a stock layout, but can only store about 1/3 as much music/pictures/etc.

BIG HONKING DISCLAIMER: I have ONLY tested this on my own personal Kindle Fire. There is some very real potential that you could render your system unbootable if you're not careful, so if you want to try this or something similar, please BE CAREFUL, and please don't try to hold me responsible if something gets messed up. You've been fairly warned! You also stand the chance of losing your data partition by doing this. If you have anything you don't want to lose, please make a backup of some sort. That being said, as long as you're careful when doing this it should be fairly safe and you shouldn't lose your data, either.

1. Preparation

1.1 Installing a custom bootloader (FIREFIREFIRE)

Strictly speaking, this is somewhat "optional", but it makes things a whole lot easier. I strongly suggest that you head on over to pokey9000's thread and install his custom bootloader. Not only will this get you into recovery much more easily, but it will give you access to fastboot on every boot up (which will be very helpful if something goes wrong). I won't repeat the installation instructions here, just head over there and follow the instructions!

1.2 Installing a custom recovery (ClockworkMod)

The second thing you'll need is ClockworkMod recovery. Again, the heavy lifting is mostly done, and you can jump over to JackpotCalvin's installation and info thread to get it. Don't worry about the fact that you can't navigate the recovery menu - we won't be using that. The only purpose of the recovery is that it gives us an environment to safely work in with the /data and /cache partitions unmounted (i.e. not being used).

1.3 Root your Kindle Fire

You could do most of this (maybe all of the partitioning, in fact) without rooting, but at best you would lose everything on your /data partition. I'm not even positive if you could do the partitioning without root since...well, I was already rooted when I tried this. In any case, head over to this thread, get SuperOneClick, and root your KF. You'll be voiding your warranty by doing the rest of this anyway :)

1.4 ADB connection

Make sure you have ADB set up on your computer. You can follow the rooting guide to get this working. You can't do anything else in this post without working ADB.

1.5 (Optional) The parted and e2fsprogs binaries

This is somewhat optional since CWM has the utilities you need already, but it's not a bad idea to have a backup copy of the parted utility and the various e2fsprogs binaries (e2fsck, tune2fs, etc). You can grab this zip file and set it aside somewhere in case you need it. Here is the documentation for parted (applies to both the CWM binaries and the standalone ones).

2. Repartitioning your device

2.1 Backup your data

I cannot stress this enough: backup anything you don't want to lose. And don't just back it up to the external storage, either - move it to your computer or dropbox or something. I also highly recommend following the instructions in the FIREFIREFIRE thread to pull images of your various partitions in their current layout, in case you need to restore through fastboot (or you need them later down the line). Backing up your external data is as simple as copying it to your computer. To backup your /data partition, you can do the following:

Code:
C:\> adb shell
$ su
# cd /data
# tar -cvpzf /sdcard/data.tar.gz .

Note the "." at the end of the last line (in *nix this means "the current directory"). This will create an archive on your external storage named data.tar.gz. You should copy this to your computer for now, to make sure nothing happens to it. This could take a few minutes depending on how much stuff you already have on your /data partition, of course (mine was ~500 MB compressed).

Once you've backed up everything you want, reboot your Kindle by turning off and back on again. You should land at the FIREFIREFIRE bootloader (a yellow triangle with a flame in it). When you see the bootloader come up, press the power button (I had to hold it for a few seconds) to boot into ClockworkMod.

3. Repartitioning

3.1 External storage (/sdcard)

Time for the fun part :)

Use adb to shell into your device, and then run 'mount' with no parameters to see what's already mounted. You should see /cache has been mounted, and since we'll be moving it later we'll go ahead and unmount it now:

Code:
C:\> adb shell
~ # umount /cache

At this point, your /cache, /data and /sdcard partitions should all be unmounted. Now you need to start up the parted partition manager, which should be included with CWM (it's in /sbin). Fire it up and check your current partition layout by doing the following. Note that
Code:
(parted)
is the prompt that parted gives you after you start it up.

Code:
~ # parted /dev/block/mmcblk0
GNU Parted 1.8.8.1.179-aef3
Using /dev/block/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
print
print
Model: MMC M8G2FA (sd/mmc)
Disk /dev/block/mmcblk0: 7734MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name        Flags
 1      131kB   262kB   131kB                xloader
 2      262kB   524kB   262kB                bootloader
 3      524kB   11.0MB  10.5MB               dkernel
 4      11.0MB  212MB   201MB   ext4         dfs
 5      212MB   229MB   16.8MB               recovery
 6      229MB   296MB   67.1MB  ext4         backup
 7      296MB   307MB   10.5MB               boot
 8      307MB   312MB   5243kB  ext4         splash
 9      312MB   849MB   537MB   ext4         system
10      849MB   2041MB  1192MB  ext4         userdata
11      2041MB  2309MB  268MB   ext4         cache
12      2309MB  7690MB  5381MB  fat32        media       msftres

(parted)

I highly recommend that you store this in a text file somewhere. I saved a copy to my Dropbox to make sure I don't lose it. The reason I say this is because I don't know how a custom partition layout will affect things like OTA updates. If you ever want to go back to the default layout, you'll need these numbers handy.

Now you can go ahead and resize your external partition, which is block 12 ("media"). Make sure you don't try to make it smaller than its contents, or else it will probably error out. For example, if you have 2 GB of music on your /sdcard storage, you won't want to shrink it to 1 GB. What you want to do to shrink the partition is increase the start value. If you were looking at this graphically, it would be equivalent to moving the start of the partition to the right. So, for example, I moved the start of my external partition from the default 2309 to 5809 (5809 - 2309 = 3500, so I made it 3.5 GB smaller). You can choose whatever size you want, and then set it like this:

Code:
(parted) resize 12 5809 7690

This says "resize partition 12 so that it starts at 5809 and ends at 7690 (same as the current end point, which is the end of the disk). As long as you don't see any errors, this should not affect your sdcard's data. I did not lose any of my data by doing this. If you want, you can reboot now to test and make sure everything is in good shape, but it's not required.

3.2 The /cache partition

Since data is partition 10, cache is 11, and media is 12, we now have a gap between the end of cache and the beginning of media. In order to expand the data partition to fill that gap, we need to move the cache partition so that it is next to media again. Unfortunately, parted doesn't support moving an ext4 partition, so we have to make some magic happen first. Basically, we're going to erase the current cache partition, create a new one that is ext2 in the proper spot, and then "upgrade" it to an ext4 partition.

To erase the cache partition (which will erase /cache's data - no big deal), do the following in parted:

Code:
(parted) rm 11
(parted) mkpartfs primary ext2 <begin> <end>
(parted) name 11 cache

To figure out the "begin" value, take the beginning value you used for your external partition and subtract 268. This will be the beginning of the cache partition (assuming you want it to stay the same size as before - this is what I recommend). For the "end" value, use the same number that you entered for the beginning of your media partition. Using my example, 5809 - 268 = 5541, so I used 5541 for the beginning and 5809 for the end. If you enter the "print" command again, you should now see that your cache partition has effectively been moved so that it's right next to your media partition again. Now we need to exit parted to "upgrade" the partition to ext4 by enabling some filesystem features and letting e2fsck run a check on the filesystem. It may say that it's fixing some group descriptor checksums - don't worry, this is normal.

Code:
(parted) quit
~ # tune2fs -j /dev/block/mmcblk0p11
~ # e2fsck -fDp /dev/block/mmcblk0p11
~ # tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p11
~ # e2fsck -fDp /dev/block/mmcblk0p11

If e2fsck complains that it needs to be run manually, you should omit the -p flag. This happened to me the second time I ran through this process, but the first time it did not. I'm not entirely sure why. In that case, the e2fsck commands simply become:

Code:
~ # e2fsck -fD /dev/block/mmcblk0p11

Which will cause it to ask if you want to fix the group descriptors. Just answer 'Y' and let it run through.

3.3. The userdata partition (/data)

The last thing we need to do is expand the userdata partition to use up the space we freed up by shrinking media. Once again, since we can't resize an ext4 partition directly, we're going to have to delete it, re-create it as an ext2 partition, and then "upgrade" it.

STOP. DO NOT PASS GO. DO NOT COLLECT $200
This will wipe your /data partition. Double check to make sure you have a copy of your backed up data, because it's going to be gone after this.

Code:
~ # parted /dev/block/mmcblk0
(parted) rm 10
(parted) mkpartfs primary ext2 849 <end>
(parted) name 10 userdata

Here the value of <end> should simply be the same as the beginning of your cache partition (in my case this was 5541). This creates the new partition between system and cache, and it takes up all of the available space. Next we need to enable the ext4 features, so we'll do the same thing we did with cache:

Code:
(parted) quit
~ # tune2fs -j /dev/block/mmcblk0p10
~ # e2fsck -fDp /dev/block/mmcblk0p10
~ # tune2fs extents,uninit_bg,dir_index /dev/block/mmcblk0p10
~ # e2fsck -fDp /dev/block/mmcblk0p10

At this point you can fire up parted again and use print to see your shiny new partition layout:

Code:
# parted /dev/block/mmcblk0
parted /dev/block/mmcblk0
GNU Parted 1.8.8.1.179-aef3
Using /dev/block/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
print
print
Model: MMC M8G2FA (sd/mmc)
Disk /dev/block/mmcblk0: 7734MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name        Flags
 1      131kB   262kB   131kB                xloader
 2      262kB   524kB   262kB                bootloader
 3      524kB   11.0MB  10.5MB               dkernel
 4      11.0MB  212MB   201MB   ext4         dfs
 5      212MB   229MB   16.8MB               recovery
 6      229MB   296MB   67.1MB  ext4         backup
 7      296MB   307MB   10.5MB               boot
 8      307MB   312MB   5243kB  ext4         splash
 9      312MB   849MB   537MB   ext4         system
10      849MB   5541MB  4692MB  ext4         userdata
11      5541MB  5809MB  268MB   ext4         cache
12      5809MB  7690MB  1881MB  fat32        media       msftres

As you can see, the userdata partition is now 4692 MB :) You'll also notice that Titanium Backup will report the new size, so you can keep track of how much space you've used up.

4. Restoring your data from the archive

Don't reboot your Kindle Fire yet! Remember the data we backed up earlier into the data.tar.gz archive? Now we need to restore it to your nice new data partition. First mount your /data partition so you can get at it from the recovery shell:

Code:
~ # mount /dev/block/mmcblk0p10 /data

Now push your backup to your phone. From a command shell on our computer, just use adb push to move it over:

Code:
C:\> adb push /path/to/data.tar.gz /data

Now you can go back to your adb shell and extract everything you backed up earlier. Once it finishes extracting you can go ahead and remove the backup from your /data partition and reboot:

Code:
~ # cd /data
/data # tar -xvpzf data.tar.gz
/data # rm data.tar.gz
/data # reboot

And that's it! Now you should have a larger /data partition, and you can go on an app installation spree.

5. Credits/Thanks/Etc

Just want to give a quick thanks to JackpotCalvin and pokey9000 for CWM and the custom bootloader, since I obviously needed those to make this happen. Also thanks to all the other devs working on the KF for all the great work so far!

If something doesn't work, feel free to drop a reply here. I'll see what I can do to help, but bear in mind that this is intended to be for power users or extreme tweakers. I'd definitely be interested in hearing some success stories if anybody else decides to give this a try.

I also want to add a shoutout/plug for the Android Enthusiasts website, hosted by StackExchange. It's a Q&A site dedicated to power users of Android devices. Stop by if you have a question, I'm always hanging around!
 
Last edited:

SikYou

Senior Member
Oct 18, 2010
438
77
Very impressive tuto! I haven't tried it because I haven't run out of space yet but sounds great and I'm glad to know that it is here when I need it. Thanks!

Sent from my Kindle Fire using Tapatalk
 

eldarerathis

Senior Member
Jun 21, 2010
159
316
Very impressive tuto! I haven't tried it because I haven't run out of space yet but sounds great and I'm glad to know that it is here when I need it. Thanks!

Sent from my Kindle Fire using Tapatalk

Thanks! I got motivated to play around with it today when I realized I'd already eaten through 500 MB of my internal storage. All those "wifi only" game downloads really add up...

Also, here's a screenshot of Ti after I repartitioned. Note that my internal storage is at 3.73GB out of 4.61GB at the bottom :)
 

Attachments

  • shot_000001.jpg
    shot_000001.jpg
    24.6 KB · Views: 3,137
  • Like
Reactions: forest1971

foxdog66

Senior Member
Jul 28, 2010
471
53
Sweet! Made me double check my space and yeah.... Those games do eat up a lot of space
 

renegade027

Senior Member
Jul 29, 2010
106
23
Kingston upon Thames, UK
WOW!!! Great!

I was thinking of what would it take to go the other way, actually. I mean,

1) I don't care about any future OTA updates from Amazon, so I definitely don't need a 500+ Mb /system partition.

2)/512 Mb will be more than enough for me on /data - anything I can't fit in that, I'll be able to just move to the /media partition.

3) Since I won't be flashing any OTA updates, I don't need this huge /cache partition either - I have 2Mb on my phone, but I think there's a script in the ROM that actively avoids using the cache partition for anything really.

4) What is /dfs and why do we need 200 Mb there...

This all adds up to nearly 2GB more space I can definitely use in the /media partition....

Do you guys think this could work? I.e - apply the same approach to /system - back up/shrink/restore?
 

eldarerathis

Senior Member
Jun 21, 2010
159
316
WOW!!! Great!

I was thinking of what would it take to go the other way, actually. I mean,

1) I don't care about any future OTA updates from Amazon, so I definitely don't need a 500+ Mb /system partition.

2)/512 Mb will be more than enough for me on /data - anything I can't fit in that, I'll be able to just move to the /media partition.

3) Since I won't be flashing any OTA updates, I don't need this huge /cache partition either - I have 2Mb on my phone, but I think there's a script in the ROM that actively avoids using the cache partition for anything really.

4) What is /dfs and why do we need 200 Mb there...

This all adds up to nearly 2GB more space I can definitely use in the /media partition....

Do you guys think this could work? I.e - apply the same approach to /system - back up/shrink/restore?

I would think you could do this as long as you make sure you get a good backup of /system and it restores properly, but I've never tried. You'd just need to be a little careful since you would have to erase and repartition it since parted doesn't understand ext4, although as long as you can get into recovery and fastboot you could partition back to normal and flash a stock system image if something went wrong (at least you should be able to). I'm probably not going to try that since I'm fine with this layout and I've only got my personal KF, but it doesn't sound unreasonable.

I'm not sure what /dfs, /dkernel or /backup are, either. I thought I saw a thread somewhere that had some talk about them, but I don't remember where it was. /dkernel is actually the same size as the /boot partition - which made me suspicious - but I can't unpack the image with my usual unpack/repack scripts so I'm not sure what it really is and I don't want to mess with it :(
 

eldarerathis

Senior Member
Jun 21, 2010
159
316
Assuming you do everything right, how long would you expect this process to take?

I'd wager you could probably knock this out in about 20-30 minutes, depending on how much stuff is on your /data partition.

The longest part, by far, was archiving and unarchiving /data. All of the partitioning commands together would only take, like, 10 minutes or so (they execute very fast). Archiving the /data partition alone took about 4 or 5 minutes for me and my archive was ~500 MB. Unzipping the archive later was another 3-5 minutes.

Altogether it probably took me about 45 minutes of actual time since I was playing with numbers and writing stuff down periodically.

I know it looks like it would take a lot longer, but I just have a tendency to write very, uh, "thorough" documentation. It's mostly out of habit (I'm a software developer).
 
Last edited:
  • Like
Reactions: forest1971

rmagruder

Senior Member
Aug 5, 2009
323
59
Right there with you.

I'm not feeling brave enough to do this right now because I'm not sure I would get EVERYTHING backed up and sorted properly...but as I've now run out of app install space several times, my tolerance for it is steadily decreasing!

Randy
 

drExel

Member
Feb 4, 2007
36
7
Bronx, Ny
Good Friggin Stuff

eldarerathis,

This guide was excellent and worked fantabulously for me. Thanks for an excellent walk-thru.

One Caveat. In this section:-

3.3. The userdata partition (/data)

...

Code:
~ # parted
...

The executed parted command in should read:-

Code:
~ # parted /dev/block/mmcblk0
...

Also, in setting up the /cache partition, after initiating this command:-

Code:
tune2fs -j /dev/block/mmcblk0p11

Thanks for pointing out the potential for the need to fix 'group descriptor checksums'. Though, in order to ensure the filesystem was marked clean, I had to initiate an extra step of running f2sck manually:-

Code:
~ # e2fsck -fD /dev/block/mmcblk0p11

(note the lack of the -p switch)

Again: Good work putting this together for the KF community. I, for one, had the immediate consideration of a small /media partition (and an inflated apps area) as this is mostly for books / apps / games for the kids whom would not use this for locally stored content and would stream any media they desired.

One question: can any of this be scripted in any way?

Cheers.
 
  • Like
Reactions: eldarerathis

eldarerathis

Senior Member
Jun 21, 2010
159
316
eldarerathis,

This guide was excellent and worked fantabulously for me. Thanks for an excellent walk-thru.

One Caveat. In this section:-



The executed parted command in should read:-

Code:
~ # parted /dev/block/mmcblk0
...

Also, in setting up the /cache partition, after initiating this command:-

Code:
tune2fs -j /dev/block/mmcblk0p11

Thanks for pointing out the potential for the need to fix 'group descriptor checksums'. Though, in order to ensure the filesystem was marked clean, I had to initiate an extra step of running f2sck manually:-

Code:
~ # e2fsck -fD /dev/block/mmcblk0p11

(note the lack of the -p switch)

Again: Good work putting this together for the KF community. I, for one, had the immediate consideration of a small /media partition (and an inflated apps area) as this is mostly for books / apps / games for the kids whom would not use this for locally stored content and would stream any media they desired.

One question: can any of this be scripted in any way?

Cheers.

Oops, you're right. I *always* forget the device parameter when I use parted (even when I'm actually running it; I do it the first time without a param constantly and parted yells at me), so I'm not surprised I missed one of them. Thanks, I'll fix that.

Per your second comment: I actually did this a second time because I changed my mind and decided to go with 3.5 GB /data and 2.5 GB /media, and I also had to run e2fsck manually. The first time I did this I didn't need to, and I'm not entirely sure why that is. Thanks for reminding me to add that note, though.

If I have some time I could try to put together a script for this. I was thinking about doing that since you should be able to do all of the parted stuff with command line parameters, but I haven't had time between work and the holidays. I might try to take a look at it again this weekend if I have a chance.
 
  • Like
Reactions: forest1971

airmaxx23

Senior Member
Jun 25, 2010
4,681
1,392
Colton, NY
Oops, you're right. I *always* forget the device parameter when I use parted (even when I'm actually running it; I do it the first time without a param constantly and parted yells at me), so I'm not surprised I missed one of them. Thanks, I'll fix that.

Per your second comment: I actually did this a second time because I changed my mind and decided to go with 3.5 GB /data and 2.5 GB /media, and I also had to run e2fsck manually. The first time I did this I didn't need to, and I'm not entirely sure why that is. Thanks for reminding me to add that note, though.

If I have some time I could try to put together a script for this. I was thinking about doing that since you should be able to do all of the parted stuff with command line parameters, but I haven't had time between work and the holidays. I might try to take a look at it again this weekend if I have a chance.

I'd make a donation to you if you get this done in a script. :D
 

drExel

Member
Feb 4, 2007
36
7
Bronx, Ny
Per your second comment: I actually did this a second time because I changed my mind and decided to go with 3.5 GB /data and 2.5 GB /media, and I also had to run e2fsck manually.

Having done this with your original method, I totally understand why you might have had to revisit and partition as you did the second go-around. It seems most game downloads cache the initial files on the media partition before actually 'installing' the data to the SYSTEM partition. As a result, in no time at all (especially with Gameloft titles) you begin to receive 'LOW SPACE' warnings when downloading some of the extremely large game-data (ie. Dungeon Hunter 2 requires 900+ megs free available) so there is potential for required manual clean-up to see things through.
 

Hydrocharged

Senior Member
Aug 20, 2010
121
2
Does this work with TWRP installed? I actually want to increase my media storage, as I use my Kindle Fire mainly for reading things online and watching movies/anime (not porn you nasty people). I'm not so sure I would want to install ClockworkMod if I have TWRP already on here.
 

eldarerathis

Senior Member
Jun 21, 2010
159
316
Does this work with TWRP installed? I actually want to increase my media storage, as I use my Kindle Fire mainly for reading things online and watching movies/anime (not porn you nasty people). I'm not so sure I would want to install ClockworkMod if I have TWRP already on here.

Yes, this should work fine. TWRP 2.0 has the utilities you need, to my knowledge.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 38
    I took some time today to play with the partition layout on my Kindle Fire and I decided I wanted to share my method in case anyone else found it interesting. The reason I did this is because I know that I'm not going to be putting much of anything onto the KF's /sdcard directory. Instead of having 1 GB for data/apps (and books?) and 5 GB for media, I wanted to more-or-less reverse those numbers. What I settled on was 4.5 GB for data/apps and about 1.7 GB of "external" storage. In other words, I can install 4 times as many apps as I could have on a stock layout, but can only store about 1/3 as much music/pictures/etc.

    BIG HONKING DISCLAIMER: I have ONLY tested this on my own personal Kindle Fire. There is some very real potential that you could render your system unbootable if you're not careful, so if you want to try this or something similar, please BE CAREFUL, and please don't try to hold me responsible if something gets messed up. You've been fairly warned! You also stand the chance of losing your data partition by doing this. If you have anything you don't want to lose, please make a backup of some sort. That being said, as long as you're careful when doing this it should be fairly safe and you shouldn't lose your data, either.

    1. Preparation

    1.1 Installing a custom bootloader (FIREFIREFIRE)

    Strictly speaking, this is somewhat "optional", but it makes things a whole lot easier. I strongly suggest that you head on over to pokey9000's thread and install his custom bootloader. Not only will this get you into recovery much more easily, but it will give you access to fastboot on every boot up (which will be very helpful if something goes wrong). I won't repeat the installation instructions here, just head over there and follow the instructions!

    1.2 Installing a custom recovery (ClockworkMod)

    The second thing you'll need is ClockworkMod recovery. Again, the heavy lifting is mostly done, and you can jump over to JackpotCalvin's installation and info thread to get it. Don't worry about the fact that you can't navigate the recovery menu - we won't be using that. The only purpose of the recovery is that it gives us an environment to safely work in with the /data and /cache partitions unmounted (i.e. not being used).

    1.3 Root your Kindle Fire

    You could do most of this (maybe all of the partitioning, in fact) without rooting, but at best you would lose everything on your /data partition. I'm not even positive if you could do the partitioning without root since...well, I was already rooted when I tried this. In any case, head over to this thread, get SuperOneClick, and root your KF. You'll be voiding your warranty by doing the rest of this anyway :)

    1.4 ADB connection

    Make sure you have ADB set up on your computer. You can follow the rooting guide to get this working. You can't do anything else in this post without working ADB.

    1.5 (Optional) The parted and e2fsprogs binaries

    This is somewhat optional since CWM has the utilities you need already, but it's not a bad idea to have a backup copy of the parted utility and the various e2fsprogs binaries (e2fsck, tune2fs, etc). You can grab this zip file and set it aside somewhere in case you need it. Here is the documentation for parted (applies to both the CWM binaries and the standalone ones).

    2. Repartitioning your device

    2.1 Backup your data

    I cannot stress this enough: backup anything you don't want to lose. And don't just back it up to the external storage, either - move it to your computer or dropbox or something. I also highly recommend following the instructions in the FIREFIREFIRE thread to pull images of your various partitions in their current layout, in case you need to restore through fastboot (or you need them later down the line). Backing up your external data is as simple as copying it to your computer. To backup your /data partition, you can do the following:

    Code:
    C:\> adb shell
    $ su
    # cd /data
    # tar -cvpzf /sdcard/data.tar.gz .

    Note the "." at the end of the last line (in *nix this means "the current directory"). This will create an archive on your external storage named data.tar.gz. You should copy this to your computer for now, to make sure nothing happens to it. This could take a few minutes depending on how much stuff you already have on your /data partition, of course (mine was ~500 MB compressed).

    Once you've backed up everything you want, reboot your Kindle by turning off and back on again. You should land at the FIREFIREFIRE bootloader (a yellow triangle with a flame in it). When you see the bootloader come up, press the power button (I had to hold it for a few seconds) to boot into ClockworkMod.

    3. Repartitioning

    3.1 External storage (/sdcard)

    Time for the fun part :)

    Use adb to shell into your device, and then run 'mount' with no parameters to see what's already mounted. You should see /cache has been mounted, and since we'll be moving it later we'll go ahead and unmount it now:

    Code:
    C:\> adb shell
    ~ # umount /cache

    At this point, your /cache, /data and /sdcard partitions should all be unmounted. Now you need to start up the parted partition manager, which should be included with CWM (it's in /sbin). Fire it up and check your current partition layout by doing the following. Note that
    Code:
    (parted)
    is the prompt that parted gives you after you start it up.

    Code:
    ~ # parted /dev/block/mmcblk0
    GNU Parted 1.8.8.1.179-aef3
    Using /dev/block/mmcblk0
    Welcome to GNU Parted! Type 'help' to view a list of commands.
    (parted) print
    print
    print
    Model: MMC M8G2FA (sd/mmc)
    Disk /dev/block/mmcblk0: 7734MB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    
    Number  Start   End     Size    File system  Name        Flags
     1      131kB   262kB   131kB                xloader
     2      262kB   524kB   262kB                bootloader
     3      524kB   11.0MB  10.5MB               dkernel
     4      11.0MB  212MB   201MB   ext4         dfs
     5      212MB   229MB   16.8MB               recovery
     6      229MB   296MB   67.1MB  ext4         backup
     7      296MB   307MB   10.5MB               boot
     8      307MB   312MB   5243kB  ext4         splash
     9      312MB   849MB   537MB   ext4         system
    10      849MB   2041MB  1192MB  ext4         userdata
    11      2041MB  2309MB  268MB   ext4         cache
    12      2309MB  7690MB  5381MB  fat32        media       msftres
    
    (parted)

    I highly recommend that you store this in a text file somewhere. I saved a copy to my Dropbox to make sure I don't lose it. The reason I say this is because I don't know how a custom partition layout will affect things like OTA updates. If you ever want to go back to the default layout, you'll need these numbers handy.

    Now you can go ahead and resize your external partition, which is block 12 ("media"). Make sure you don't try to make it smaller than its contents, or else it will probably error out. For example, if you have 2 GB of music on your /sdcard storage, you won't want to shrink it to 1 GB. What you want to do to shrink the partition is increase the start value. If you were looking at this graphically, it would be equivalent to moving the start of the partition to the right. So, for example, I moved the start of my external partition from the default 2309 to 5809 (5809 - 2309 = 3500, so I made it 3.5 GB smaller). You can choose whatever size you want, and then set it like this:

    Code:
    (parted) resize 12 5809 7690

    This says "resize partition 12 so that it starts at 5809 and ends at 7690 (same as the current end point, which is the end of the disk). As long as you don't see any errors, this should not affect your sdcard's data. I did not lose any of my data by doing this. If you want, you can reboot now to test and make sure everything is in good shape, but it's not required.

    3.2 The /cache partition

    Since data is partition 10, cache is 11, and media is 12, we now have a gap between the end of cache and the beginning of media. In order to expand the data partition to fill that gap, we need to move the cache partition so that it is next to media again. Unfortunately, parted doesn't support moving an ext4 partition, so we have to make some magic happen first. Basically, we're going to erase the current cache partition, create a new one that is ext2 in the proper spot, and then "upgrade" it to an ext4 partition.

    To erase the cache partition (which will erase /cache's data - no big deal), do the following in parted:

    Code:
    (parted) rm 11
    (parted) mkpartfs primary ext2 <begin> <end>
    (parted) name 11 cache

    To figure out the "begin" value, take the beginning value you used for your external partition and subtract 268. This will be the beginning of the cache partition (assuming you want it to stay the same size as before - this is what I recommend). For the "end" value, use the same number that you entered for the beginning of your media partition. Using my example, 5809 - 268 = 5541, so I used 5541 for the beginning and 5809 for the end. If you enter the "print" command again, you should now see that your cache partition has effectively been moved so that it's right next to your media partition again. Now we need to exit parted to "upgrade" the partition to ext4 by enabling some filesystem features and letting e2fsck run a check on the filesystem. It may say that it's fixing some group descriptor checksums - don't worry, this is normal.

    Code:
    (parted) quit
    ~ # tune2fs -j /dev/block/mmcblk0p11
    ~ # e2fsck -fDp /dev/block/mmcblk0p11
    ~ # tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p11
    ~ # e2fsck -fDp /dev/block/mmcblk0p11

    If e2fsck complains that it needs to be run manually, you should omit the -p flag. This happened to me the second time I ran through this process, but the first time it did not. I'm not entirely sure why. In that case, the e2fsck commands simply become:

    Code:
    ~ # e2fsck -fD /dev/block/mmcblk0p11

    Which will cause it to ask if you want to fix the group descriptors. Just answer 'Y' and let it run through.

    3.3. The userdata partition (/data)

    The last thing we need to do is expand the userdata partition to use up the space we freed up by shrinking media. Once again, since we can't resize an ext4 partition directly, we're going to have to delete it, re-create it as an ext2 partition, and then "upgrade" it.

    STOP. DO NOT PASS GO. DO NOT COLLECT $200
    This will wipe your /data partition. Double check to make sure you have a copy of your backed up data, because it's going to be gone after this.

    Code:
    ~ # parted /dev/block/mmcblk0
    (parted) rm 10
    (parted) mkpartfs primary ext2 849 <end>
    (parted) name 10 userdata

    Here the value of <end> should simply be the same as the beginning of your cache partition (in my case this was 5541). This creates the new partition between system and cache, and it takes up all of the available space. Next we need to enable the ext4 features, so we'll do the same thing we did with cache:

    Code:
    (parted) quit
    ~ # tune2fs -j /dev/block/mmcblk0p10
    ~ # e2fsck -fDp /dev/block/mmcblk0p10
    ~ # tune2fs extents,uninit_bg,dir_index /dev/block/mmcblk0p10
    ~ # e2fsck -fDp /dev/block/mmcblk0p10

    At this point you can fire up parted again and use print to see your shiny new partition layout:

    Code:
    # parted /dev/block/mmcblk0
    parted /dev/block/mmcblk0
    GNU Parted 1.8.8.1.179-aef3
    Using /dev/block/mmcblk0
    Welcome to GNU Parted! Type 'help' to view a list of commands.
    (parted) print
    print
    print
    Model: MMC M8G2FA (sd/mmc)
    Disk /dev/block/mmcblk0: 7734MB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    
    Number  Start   End     Size    File system  Name        Flags
     1      131kB   262kB   131kB                xloader
     2      262kB   524kB   262kB                bootloader
     3      524kB   11.0MB  10.5MB               dkernel
     4      11.0MB  212MB   201MB   ext4         dfs
     5      212MB   229MB   16.8MB               recovery
     6      229MB   296MB   67.1MB  ext4         backup
     7      296MB   307MB   10.5MB               boot
     8      307MB   312MB   5243kB  ext4         splash
     9      312MB   849MB   537MB   ext4         system
    10      849MB   5541MB  4692MB  ext4         userdata
    11      5541MB  5809MB  268MB   ext4         cache
    12      5809MB  7690MB  1881MB  fat32        media       msftres

    As you can see, the userdata partition is now 4692 MB :) You'll also notice that Titanium Backup will report the new size, so you can keep track of how much space you've used up.

    4. Restoring your data from the archive

    Don't reboot your Kindle Fire yet! Remember the data we backed up earlier into the data.tar.gz archive? Now we need to restore it to your nice new data partition. First mount your /data partition so you can get at it from the recovery shell:

    Code:
    ~ # mount /dev/block/mmcblk0p10 /data

    Now push your backup to your phone. From a command shell on our computer, just use adb push to move it over:

    Code:
    C:\> adb push /path/to/data.tar.gz /data

    Now you can go back to your adb shell and extract everything you backed up earlier. Once it finishes extracting you can go ahead and remove the backup from your /data partition and reboot:

    Code:
    ~ # cd /data
    /data # tar -xvpzf data.tar.gz
    /data # rm data.tar.gz
    /data # reboot

    And that's it! Now you should have a larger /data partition, and you can go on an app installation spree.

    5. Credits/Thanks/Etc

    Just want to give a quick thanks to JackpotCalvin and pokey9000 for CWM and the custom bootloader, since I obviously needed those to make this happen. Also thanks to all the other devs working on the KF for all the great work so far!

    If something doesn't work, feel free to drop a reply here. I'll see what I can do to help, but bear in mind that this is intended to be for power users or extreme tweakers. I'd definitely be interested in hearing some success stories if anybody else decides to give this a try.

    I also want to add a shoutout/plug for the Android Enthusiasts website, hosted by StackExchange. It's a Q&A site dedicated to power users of Android devices. Stop by if you have a question, I'm always hanging around!
    5
    A little status update, since I found time for this again.

    I removed dfs and dkernel (they are actually useless partitions, surprise surprise) and put cache in their place. I then extended sdcard to take the place of the old cache. Rebooted and I was right back at my home screen. Sweet.

    Final result: 212MB cache on partition 3, 6.75GB sdcard on partition 4 (make sure to edit /etc/fstab in CWM and vold.fstab in Android!), only goes up to 11 partitions. Oh, and my system partition is shrunk to less than 320MB and my apps are happily sitting at 400MB (I've never used more than this, but if I ever need to I can easily move apps to SD).

    6.75GB of pure, unfettered storage. 212MB cache. All without any usability sacrifices.

    WHAT ARE YOU WAITING FOR, PEOPLE? Go forth to glory! ;)
    3
    So did the recovery go?

    Yes it worked. This is what I did to get it to work and by work I mean I am able to boot into the latest ICS build by jackpotcalvin but I did lose ALL data on my device.

    READ THE ENTIRE POST BEFORE ATTEMPTING

    You need to have fastboot working for this to work.
    Run:
    Code:
    fastboot -i 0x1949 boot twrp-blaze-2.0.0RC0.img
    Make sure you point to the correct location for the recovery image.
    Once that boots your KF will say installation complete and have a reboot button.
    DO NOT REBOOT. Although if you do just repeat the last step.
    This should give you adb access
    Code:
    adb shell
    Now run parted on /dev/block/mmcblk0
    Code:
    ~ # parted /dev/block/mmcblk0
    you should see
    Code:
    parted /dev/block/mmcblk0
    GNU Parted 1.8.8.1.179-aef3
    Using /dev/block/mmcblk0
    Welcome to GNU Parted! Type 'help' to view a list of commands.
    (parted)
    now rum print to give a list of partitions
    Code:
    (parted) print
    print
    print
    Model: MMC MMC08G (sd/mmc)
    Disk /dev/block/mmcblk0: 7818MB
    Sector size (logical/physical): 512B/512B
    Partition Table: loop
    
    Number  Start  End     Size    File system  Flags
     1      0.00B  7818MB  7818MB  ext4

    Note the "Partition Table" is set to "loop" it needs to be gpt!
    To do that we need to change the "label type"

    Using parted's "mklabel" command we can create the gpt label. The new disk label will have no partitions. This command (normally) won't technically destroy your data, but it will make it basically unusable

    Code:
    (parted) mklabel gpt

    run print to see outcome

    Code:
    (parted) p
    p
    p
    Model: MMC MMC08G (sd/mmc)
    Disk /dev/block/mmcblk0: 7818MB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    
    Number  Start   End     Size    File system  Name        Flags

    Now you should have the correct gpt partition table.

    This is where the fun begins. You now need to recreate all of the partitions. Its important to only use the "mkpart" command not the "mkpartfs" at least for the non-labeled file system partitions.

    The stock partitions look like this

    Code:
    (parted) print
    print
    print
    Model: MMC M8G2FA (sd/mmc)
    Disk /dev/block/mmcblk0: 7734MB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    
    Number  Start   End     Size    File system  Name        Flags
     1      131kB   262kB   131kB                xloader
     2      262kB   524kB   262kB                bootloader
     3      524kB   11.0MB  10.5MB               dkernel
     4      11.0MB  212MB   201MB   ext4         dfs
     5      212MB   229MB   16.8MB               recovery
     6      229MB   296MB   67.1MB  ext4         backup
     7      296MB   307MB   10.5MB               boot
     8      307MB   312MB   5243kB  ext4         splash
     9      312MB   849MB   537MB   ext4         system
    10      849MB   2041MB  1192MB  ext4         userdata
    11      2041MB  2309MB  268MB   ext4         cache
    12      2309MB  7690MB  5381MB  fat32        media       msftres

    Start from 1 and go sequentially.

    Code:
    mkpart xloader 131kb 262kb

    print and you should see something like
    Code:
    (parted) print
    print
    print
    Model: MMC M8G2FA (sd/mmc)
    Disk /dev/block/mmcblk0: 7734MB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    
    Number  Start   End     Size    File system  Name        Flags
     1      131kB   262kB   131kB

    I dont know why the name doesn't stick but all you do is

    Code:
    (parted) name 1 xloader

    repeat for all 12 partitions and you should get something like

    Code:
    (parted) p
    p
    p
    Model: MMC MMC08G (sd/mmc)
    Disk /dev/block/mmcblk0: 7818MB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    
    Number  Start   End     Size    File system  Name        Flags
     1      131kB   262kB   132kB                xloader
     2      262kB   524kB   262kB                bootloader
     3      524kB   11.0MB  10.5MB               dkernel
     4      11.0MB  212MB   201MB               dfs
     5      212MB   229MB   17.0MB               recovery
     6      229MB   296MB   67.0MB               backup
     7      296MB   307MB   11.0MB               boot
     8      307MB   312MB   5000kB               splash
     9      312MB   849MB   537MB                system
    10      849MB   4541MB  3692MB               userdata
    11      4541MB  4809MB  268MB                cache
    12      4809MB  7690MB  2881MB               media

    The partitions are created but we have no file systems. For this I did not use parted's "mkfs" command for fear it would damage any data needed to boot the bootloader, this is probably not an issue because the bootloader partition doesn't have a file system.

    So instead I used mke2fs. The first partition to need a fs is 4.

    Code:
    (parted)quit
    ~# mke2fs -m 0 /dev/block/mmcblk0p4

    this will give you an ext2 fs on 4. to convert to ext4 do

    Code:
    ~ # tune2fs -j /dev/block/mmcblk0p4
    ~ # e2fsck -fDp /dev/block/mmcblk0p4
    ~ # tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p4
    ~ # e2fsck -fDp /dev/block/mmcblk0p4
    If e2fsck complains that it needs to be run manually, you should omit the -p flag. This happened to me the second time I ran through this process, but the first time it did not. I'm not entirely sure why. In that case, the e2fsck commands simply become:

    Code:
    ~ # e2fsck -fD /dev/block/mmcblk0p4
    Which will cause it to ask if you want to fix the group descriptors. Just answer 'Y' and let it run through.

    repeat replacing /dev/block/mmcblk0p4 with ,6,8,9,10,11

    I did run into an issue on 8 "slpash" when running
    Code:
    ~ # tune2fs -j /dev/block/mmcblk0p11
    it complained about not having enough space. I just left it as ext2.

    the last thing to partition is 12 "media" for this do

    Code:
    ~# parted /dev/block/mmcblk0

    Code:
    (parted) mkfs 12 fat32

    when finished you should have something like

    Code:
    (parted) p
    p
    p
    Model: MMC MMC08G (sd/mmc)
    Disk /dev/block/mmcblk0: 7818MB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    
    Number  Start   End     Size    File system  Name        Flags
     1      131kB   262kB   132kB                xloader
     2      262kB   524kB   262kB                bootloader
     3      524kB   11.0MB  10.5MB               dkernel
     4      11.0MB  212MB   201MB   ext4         dfs
     5      212MB   229MB   17.0MB               recovery
     6      229MB   296MB   67.0MB  ext4         backup
     7      296MB   307MB   11.0MB               boot
     8      307MB   312MB   5000kB  ext2         splash
     9      312MB   849MB   537MB   ext4         system
    10      849MB   4541MB  3692MB  ext4         userdata
    11      4541MB  4809MB  268MB   ext4         cache
    12      4809MB  7690MB  2881MB  fat32        media       msftres
    
    (parted)

    Note I resized my userdata and media partitions while i was doing this. It is not necessary.

    all in all its works ok. there are some small discrepancies between final partition size but it worked for me. I would suggest setting the splash partition ~300kb bigger that way you can change it to ext4.

    After all that is done reboot and uses fastboot to flash twrp and then re-install the ICS or whatever os you want
    2
    Just a little info:
    dboot and dfs are a debug system that amazon put on the tablet, no clue how it's booted, but it is a full android system. I forgot to save the kernel, but I do have dfs saved.
    But, they can both be removed, also backup and splash.

    There is also 128MB at the end of the flash that isn't used either, so media could be resized to the last 128MB (media ends at 7690MB, flash ends at 7818MB).

    Just be careful that the partitions have the same numbers that the original map has, otherwise ROMs won't mount the correct partition, unless you want to make your own initrd and edit init.omap4430.rc accordingly.

    Also, if media isn't partition 12, then you'll also have to edit vold.fstab to point to the correct partition.

    Edit:
    Oh, there is also like 100k at the beginning of the flash as well, before xloader, but I didn't bother with it... Not really worth while, plus I didn't feel like bothering with reflashing the bootloader stuff.
    2
    Does this work with TWRP installed? I actually want to increase my media storage, as I use my Kindle Fire mainly for reading things online and watching movies/anime (not porn you nasty people). I'm not so sure I would want to install ClockworkMod if I have TWRP already on here.

    Yes, this should work fine. TWRP 2.0 has the utilities you need, to my knowledge.