Resize Partitions in ODROID MicroSD Card

I purchased an ODROID-U3 (Community Edition) from HardKernel a couple of days ago. It runs much faster than what I expected. Anyway, I’d love to share my experience related to this board. So, here we go. The first chapter: Resize partitions in the microSD card.

Requirement

  • A functional Linux* device (ODROID-U3 itself doesn’t count)
  • A microSD card reader

*: Other UNIX-like OS may do the work as well, but I didn’t test it.

Procedures

Let me write the procedures in advance.

  1. Back up the data from microSD card partitions.
  2. Using fdisk to modify the disk partition table.
  3. Make new partitions
  4. Restore the data

Why don’t we just use resize2fs? Because I need to enlarge the first partition whose format is vfat. So I have to move the second partition right, which means changing the second partition’s header. I don’t know how to manage that, so let us just go the old-fashioned way.

Back Up

  1. Insert the microSD card into microSD card reader. Then insert the microSD card reader into Linux PC (I assume your Linux device is a PC).
  2. Mount partitions (both of them) of microSD card.
  3. Running commonds below in terminal.

    sudo tar cpzf /tmp/boot.tar.gz /media/BOOT
    sudo tar cpzf /tmp/root.tar.gz /media/ROOT
    #Note: /media/BOOT and /media/ROOT are paths where you mount the first and second partition of microSD card respectively.

  4. Running sudo blkid and remember the UUID of second partition which is the root (/) partition. In my case, it’s 99aa990c-c3e6-4dc8-9da7-ddd34200da20.

  5. Once it finished. Unmount them and re-insert the microSD card reader.

Modify Disk Partition Table

  1. Running sudo fdisk -l to find out the device, which should be /dev/sdb in most cases.
  2. Running sudo fdisk /dev/sdb. Change /dev/sdb if needed.
  3. Enter p. Remeber the Start of /dev/sdb1. In my case, it’s 4096.
  4. Deleting all these partitions by d. Just follow the hints.
  5. Enter n to create a new partition, then press p (Primary Parition). Input the Start value as you remembered previously. In my case, it’s 4096 as I said in Step 3. Then just follow the hints, i.e. if you want a 256MB BOOT partition, enter +256MB.
  6. Enter p to print table. Remember the End of your newly created partition. i.e. 65535.
  7. Enter n to create another new partition, press p to choose Primary Parition. And input the End +1 (i.e. 65536) when it asks you to input the Start sector. Then just press enter to use the entire spare disk.
  8. Enter w to write this new disk partition table to microSD.
  9. Quit fdisk.
  10. Re-insert the microSD card reader.

Make New Partitions

  1. Running sudo mkfs.vfat -F 32 -n BOOT /dev/sdb1 to format /dev/sdb1 as FAT32 partition.
  2. Running sudo mkfs.ext4 -b 4096 -U 99aa990c-c3e6-4dc8-9da7-ddd34200da20 /dev/sdb2 to format /dev/sdb2 as EXT4 partition. Parameter -U would set this partition’s UUID. You should change 99aa990c-c3e6-4dc8-9da7-ddd34200da20 to what you remembered previously in Step 4 of Back Up.
  3. (Optional) Check new partitions by fsck.

Restore

  1. Mount the partitions as we did in Back Up.
  2. Running commands below in terminal.

    sudo tar zxvf /tmp/boot.tar.gz -C /media/BOOT
    sudo tar zxvf /tmp/root.tar.gz -C /media/ROOT

  3. Once it’s finished. Unmount partitions. You may need to wait awhile to let data be truly and completely written.

By specifying UUID of newly created ROOT partition in Make New Partitions, we avoid modifying boot.scr. If you didn’t specify UUID as the orignal one, you may have to generate a new boot.scr (remember changing the UUID in boot.txt in advance), or the microSD card would become unbootable.

Comments