Saturday 29 October 2011

How to resize a partition and filesystem to use unallocated sectors

If you cloned a CentOS disk using clonezilla and if your source disk is smaller than the destination disk, it's possible that there will be unallocated sectors at the end. To fix it you need to do two things:

1. Resize the last parition to use the unallocated sectors at the end using fdisk or Gparted.
2. Resize the filesystem to make it aware of the resized partition.






Step1: Resizing the last partition.
fdisk -l
fdisk /dev/sda
Hit "v" to verify the unallocated sectors.
delete the last partition.
create a new partition to start with the same cylinder and end with the last cylinder on the disk.
Save the partition table and reboot.

Step2:
Boot using gparted.
OPen a terminal
sudo resize2fs /dev/sda5
It says please run e2fsck
sudo e2fsck -f /dev/sda5
sudo resize2fs /dev/sda5

No comments:

Post a Comment