Resize Raspberry PI partition.: Difference between revisions

From munkjensen.net/wiki
No edit summary
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 8: Line 8:
Then delete partitions by selecting ''d'', and create a new with ''n''. You can view the existing table with ''p''.
Then delete partitions by selecting ''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
* ''p'' [Enter] to see the current start of the main partition
* ''d 2'' to delete the main partition
* ''d [Enter] 2 [Enter]'' to delete the main 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 Minibian image from 2015-11-12 starts at 125056, but the start of your partition might be different. Check the p output!
* ''n [Enter] p [Enter] 2 [Enter]'' to create a new primary partition
* ''w'' to write the new partition table
* Now you need to enter the start of the old main partition - Use the initial p output from above!
Now you need to reboot.
* Then the size you wish for the new partition. Press [Enter] for complete the SD card.
* ''w'' to write the new partition table. Ignore the fail to re-read.
* Now you need to reboot. Execute the command ''sudo init 6''
 
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.
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.


<pre>resize2fs /dev/mmcblk0p2</pre>
<pre>sudo resize2fs /dev/mmcblk0p2</pre>
This will take a few minutes, depending on the size and speed of your SD card.
This will take a few minutes, depending on the size and speed of your SD card.


Line 23: Line 26:


Source: http://minibianpi.wordpress.com/how-to/resize-sd/
Source: http://minibianpi.wordpress.com/how-to/resize-sd/
[[Category:RaspBerry Pi]]

Latest revision as of 16:57, 7 May 2016

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 by selecting d, and create a new with n. You can view the existing table with p.

  • p [Enter] to see the current start of the main partition
  • d [Enter] 2 [Enter] to delete the main partition
  • n [Enter] p [Enter] 2 [Enter] to create a new primary partition
  • Now you need to enter the start of the old main partition - Use the initial p output from above!
  • Then the size you wish for the new partition. Press [Enter] for complete the SD card.
  • w to write the new partition table. Ignore the fail to re-read.
  • Now you need to reboot. Execute the command sudo init 6

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

Source: http://minibianpi.wordpress.com/how-to/resize-sd/