I came up an idea recently about making a robot with Raspberry Pi, I have tried to make one on Arduino before and since Raspberry Pi is not only has more High Level Tools but also has more interfaces and computing powers, etc. So I decide to jump into it and try to make a WIFI remote car with a camera on It or something like that. However, I am new to raspberry and has only limited experience on Linux, I have just used to do some basic work like build a LAMP server and Glassfish Server on it. And I realized that the root partition is only got 3.7GB after I flash the Raspbian into the SD Card and boot the Pi and my SD Card has 8GB totally. On purpose to save my time and organize the file in a relatively properly way. I decide to resize the root partition I got from the Pi.
First of all I have done some survey for it and I found that it is not very hard to do so and seems to be common problem of Raspberry Pi.
Here is the solution of it:
http://raspberrypi.stackexchange.com/questions/499/how-can-i-resize-my-root-partition
And in case of the link become dead I make a quick quote of it.
The Short Version:
- Backup your system
- Remove the main and swap partitions (leaving the boot partition alone)
- Recreate the main partition to utilize the remaining disk space (excluding the boot partiton). Make sure to reuse the same start sector as the original root partition.
- reboot the system
- resize the new boot root partition to utilize the full partition size.
Step by Step Instructions
First make a backup of your SD Card using the instructions found here in case something goes wrong.
From the command line or a terminal window enter the following
sudo fdisk /dev/mmcblk0
then type
p
to list the partition tableyou should see three partitions. if you look in the last column labeled System you should have
- W95 FAT32
- Linux
- Linux Swap
make a note of the start number for partiton 2, you will need this later. though it will likely still be on the screen (just in case).
next type
d
to delete a partition.You will then be prompted for the number of the partition you want to delete. In the case above you want to delete both the Linux and Linux swap partitions.
So type
2
then type
d
again and then type3
to delete the swap partition.Now you can resize the main partition.
type
n
to create a new partition.This new partition needs to be a primary partition so type
p
.Next enter
2
when prompted for a partition number.You will now be prompted for the first sector for the new partition. Enter the start number from the earlier step (the Linux partition)
Next you will be prompted for the last sector you can just hit enter to accept the default which will utilize the remaining disk space.
Type
w
to save the changes you have made.Next reboot the system with the following command:
sudo reboot
once the system has reboot and you are back at the commandline enter the following command:
sudo resize2fs /dev/mmcblk0p2
Note: this can take a long time (depending on the card size and speed) be patient and let it finish so you do not mess up the file system and have to start from scratch.
Once it is done reboot the system with the following command:
sudo reboot
You can now verify that the system is using the full capacity of the SD Card by entering the following command:
df -h
Origin From Steve Robillard