Wednesday, October 17, 2012

Resize Linux ext4 partition using Parted Magic Live CD

I accidentally created a partition too small.

The system was the self contained version of cPanel running on top of CentOS 5.x, under the free version of vmware,

Luckily the file system I needed to expand was at the end of the disk (/dev/sda5):

root@cpanel-dev [~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda5             9.2G  4.3G  4.5G  49% /

Using vmware I expanded the disk by simply adding space to the existing disk, after which the disk now has 26gb of space:

Model: VMware Virtual disk (scsi)
Disk /dev/sda: 26.8GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type      File system  Flags
 1      32.3kB  313MB   313MB   primary   ext3         boot 
 2      313MB   2459MB  2147MB  primary   ext3              
 3      2459MB  6662MB  4203MB  primary   linux-swap        
 4      6662MB  17.2GB  10.5GB  extended                    
 5      6663MB  17.2GB  10.5GB  logical   ext3 

In order to resize the disk, I downloaded a copy of the parted magic live cd.

Reboot the system and boot off the parted live cd.

The first thing that needed to be done was resize the extended partition 4 to the end of the disk.   After this was completed, I resized partition 5 to the end of the disk.

Apply changes.


The disk and filesystem was automatically resized:

root@cpanel-dev [~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda5              18G  4.3G   13G  26% /

1 comment:

  1. Eh I got stuck about half way through that, this guide seemed to have a few of the missing steps, that at least confused me. I am new at this lol.

    Dunno if I can post anything here or not but here it is

    Lots of screenshots are nice.