Extend partitions with fdisk

Another post about my new Cubieboard. The image I used had a fixed size of 2 GB. Because I wanted to use my whole 4 GB SD Card I had to extend my rootfs partition (in my case /dev/mmcblk0p2).

When doing some research about resizing partitions on Linux I saw many posts about LVM. Of course I don’t have a LVM setup on my Cubieboard so I had to find another solution.

Eventually I found a solution for LVM and tried it for my setup.

  • fdisk /dev/mmcblk0
  • p (remember the start sector of partition 2)
  • d (remove partition, choose partition 2)
  • n (create new partition, number 2, start sector of step 2, leave end sector as default)
  • w (write changes to disk and exit)

After this I had to reboot my system for the changes to take effect. The system still worked!

The partition has been extended but there was no file system on the extended space, so the usable space was still 2 GB. To create a filesystem on the extended space I executed the following command: resize2fs /dev/mmcblk0p2. A few seconds later my rootfs was 4 GB!

Leave a Reply

Your email address will not be published. Required fields are marked *