Skip to content

Instantly share code, notes, and snippets.

@rujmah
Created December 8, 2016 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rujmah/9a0b82b6650ff22cdf18adbd753b6a54 to your computer and use it in GitHub Desktop.
Save rujmah/9a0b82b6650ff22cdf18adbd753b6a54 to your computer and use it in GitHub Desktop.
Resizing Centos 6 8GB root partition with Fdisk

From this forum post:

Here are the steps i used to fix it.
Note that any mistake in recreating the partion will result in losing all data and/or the server will not reboot.
I would do this as the first step on a newly created instance.

I have marked the steps with <<#>> in the block below, so the are not a part of the command.
You need root permissions, so do a "sudo sh" if you are not root.

<<1>> Look at the filesystem, it is 6G
<<2>> Look at the disk and the partition, the disk is 21.5 GB but the partition is 6 GB (6291456 blocks)
<<3>> Start fdisk for that disk (xvda, so not the partition xvda1)
<<4>> Switch to sector display.
<<5>> Print the partition(s), and remember the start sector (2048 in the example).
<<6>> Delete the partition.
<<7>> Create a new partition.
<<8>> Make it primary.
<<9>> First partition.
<<10>> Enter the old start sector, do NOT make any typo here!!! (2048 in the example) 
<<11>> Hit enter to accept the default (this is the remainder of the disk)
<<12>> Print the changes and make sure the start sector is ok, if not restart at <<6>>
<<13>> Make the partition bootable. do NOT forget this!!!
<<14>> Enter your partition number (1 in the example)
<<15>> Write the partition info back, this will end the fdisk session.
<<16>> Reboot the server, and wait for it to come up (this may take longer than usual).
<<17>> Verify the filesystem size.
<<18>> If the filesystem is not around 20Gb as expected, you can use this command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment