March 12, 2016

How to re-size Rapi partition SD card

Recently, I bought Raspberry Pi 3 for my own project and I install ubuntu mate OS in my raspi3. However, due to the image file, if you using the Ubuntu mate for your raspi OS, after you build the image, you have to resize your SD card so that you could have the full size of yout SD card.
  For example, I use 32G Kingston SD card, before re-sizing, my storage usage was only 64M!!!
 I could not even do anything in my raspi3 hahhaa, however, I fould a awesome tutorial that teach you by step how to resize your SD card.
There are many ways to resize your SD card, in my opinion, you could use the GUI Gparted or command line "fdisk" are both good. in my case, I use fdisk.

IF you are interested in other details, go check into the turotial : http://elinux.org/RPi_Resize_Flash_Partitions

Manually resizing the SD card on Raspberry Pi

You can also resize the partitions of the SD card that your Pi is running on.
First you need to change the partition table with fdisk. You need to remove the existing partition entries and then create a single new partition than takes the whole free space of the disk. This will only change the partition table, not the partitions data on disk. The start of the new partition needs to be aligned with the old partition!
Start fdisk:
sudo fdisk /dev/mmcblk0
Then delete partitions with d and create a new with n. You can view the existing table with p.
  • p to see the current start of the main partition
  • d  to delete 
  • 2  to point the delete to second partition
  • n p 2 to create a new primary partition, next you need to enter the start of the old main partition and then the size (enter for complete SD card). The main partition on the Debian image from 2012-04-19 starts at 157696, but the start of your partition might be different. Check the p output!
  • w write the new partition table
Now you need to reboot:
 sudo reboot
After the reboot you need to resize the filesystem on the partition. The resize2fs command will resize your filesystem to the new size from the changed partition table.
sudo resize2fs /dev/mmcblk0p2
This will take a few minutes, depending on the size and speed of your SD card.
When it is done, you can check the new size with:
df -h

2 comments :