UPDATE August 05, 2010:

I added a tiny bit more verbosity in the error messages given. Also, I included another alternative line for determinig the last partition of the SD card using "ls -la $DISK*" instead of "fdisk -l $DISK". This was just in case "fdisk -l" output gives different output on different machines. If you're getting error messagse about "Valid T.S. partition not found!", try uncommenting the alternative line and commenting out the original line.

md5sum: d41961d8c3114cbcb4eea3a347ffc6b6

UPDATE June 16, 2010:

I'm not sure what happened, but for a while there a different, non-working version of the grow_sd script was published here. I have corrected it and made some changes/modifications/corrections to make it more robust. I tested it out on a 16GB SD card and it worked well. So, if you were having issues with the script before, or it just didn't work for you, give it another shot. It's actually a pretty neat script if I do say so myself. ;)
Again, you can download it here: grow_sd.
md5sum: 189c9683b732cda13d5a6ab58d01fd0d

UPDATE May 07, 2010:

I had taken some time to create a script that will take care of all this automatically (and without the gparted dependancy). It can be found here (right-click and "save link as" to download): grow_sd. Simply call it like grow_sd /dev/sdb and it will resize the last partition to the end of the disk. It works with both JFS and EXT3 partitions. As always, backup your data!


This tutorial will walk you through how to use gparted to expand the fourth partition of a Technologic Systems image. Most commonly, this is desired when copying an image meant for a 512MB SD card to a larger SD card like 2GB and you want to take advantage of the full 2GB capacity.

You'll need administrative access to a Linux box and the USB SD card reader. Be sure that your SD card has been inserted into the Linux box and a terminal window is open and we'll get to it...

{content in brackets are comments not to be typed into the terminal}
  1. Become root on the system:
  2.    {if running Debian based distro:}
       su
    
       {if running Red Hat based distro:}
       su -
    
  3. Install the gparted and jfsutils packages:
  4.    {if running Debian based distro:}
       apt-get install gparted jfsutils
       
       {if running Red Hat based distro:}
       yum install gparted jfsutils
    
  5. Before we launch gparted, make sure that your SD card is not mounted (otherwise, no changes can be made.):
  6.    {This is assuming that your SD card is located at "/dev/sdb".  Use 'fdisk -l'
        to verify this location}
       umount /dev/sdb*
    
       {Verify that all partitions have been unmounted. The output should look like 
       the following if they are. If not, run the above command until all four are 
       listed as not mounted}
    
       [root@DerekLinux ~]# umount /dev/sde*
       umount: /dev/sde: not mounted
       umount: /dev/sde1: not mounted
       umount: /dev/sde2: not mounted
       umount: /dev/sde3: not mounted
       umount: /dev/sde4: not mounted
    
  7. Launch gparted (remember, you must have root privileges):
  8.    gparted
    
  9. Gparted should now be running. In the upper right hand corner of the screen, you'll see a drop down menu. Select "/dev/sde" to select your SD card device. Refer to Screenshot1 below:


  10. The next step is to select/highlight the fourth partition on the SD card in gparted, then select menu item "Partition -> Resize/Move" or click on the large "Resize/Move" button.
  11. Drag the handle on the right side to and stretch it to the end of the grey area. Refer to screenshot2 below:


  12. Select "Resize/Move" and finally "Apply". Refer to screenshot3 below:


At this point, simply allow the gparted program to do its magic and you'll be finished.

If you have problems or errors, it's more than likely a corrupted partition. In this case, you'll need to run the following command:

   jfs_fsck -f /dev/sdb4