Sunday, April 17, 2011

resizing a linux partition using Parted Magic

I was running out of space on the root filesystem of my OpenSuSE 11.4 virtual machine. I needed a few extra gig, so I wanted to enlarge the root filesystem from 18GB to 22GB:
sfrase@linux-8u67:~> df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 14G 4G 22% /
devtmpfs 372M 88K 372M 1% /dev
tmpfs 372M 1.1M 371M 1% /dev/shm
Thinking I could use Gparted, I stumbled upon something even easier..the Parted Magic OS. Parted Magic is a compilation of open source partitioning utilities in one smooth-looking OS in bootable iso format. The bootable iso is about 160MB and is available here:

I had to do a few things to get the filesystem resized.
1) resized the virtual disk that VMware uses
2) booted the VM with the Parted Magic ISO in the virtual CD of the VM
3) ran GParted and expanded my filesystem
4) rebooted the system to see the expanded disk

I'll show you the steps in depth below:

In VMware Player settings, select the hard disk, click the Utilities link and press "Expand":

Specify a new maximum disk size:

After VMware resizes the virtual disk, I got a success message:

I mounted the ISO in the virtual CD drive:

Next, I booted the virtual machine. I pressed ESC (escape) while the vm is booting to display the boot menu:

I highlighted CDROM and press enter to start booting the Parted Magic iso:

Parted Magic has a really nice interface. Love the system monitors on the desktop!

Next, I double-clicked the icon labeled "partition editor". This is Gparted, the GNOME partition manager:

I double-clicked the filesystem I wanted to resize. In order to expand the size of the filesystem, I pulled the right tab in the graphic from its current position all the way to the right.

I clicked the resize button and saw the change I made:

I clicked Apply to confirm the changes:

It took a minute or two to resize the filesystem:

I checked out the steps the resize performs by clicking the little twisty:

Once resized, I rebooted the machine:

Now my disk has the extra 4GB of space that I needed! Hooray!
sfrase@linux-8u67:~> df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 22G 14G 8G 22% /
devtmpfs 372M 88K 372M 1% /dev
tmpfs 372M 1.1M 371M 1% /dev/shm

You can also shrink filesystems. For instance, I wanted to reduce the size of my root partition from 38GB to 7GB. Again, I used GParted and PartedMagic CD for the task.

Here's the Resize screen after I dragged the right arrow almost to the area on the filesystem that is used, as indicated by the yellow color:

Here's the screen while the job is in progress:

Once finished you'll see a message "All operations successfully completed." The job took about five minutes to complete.

So far, I've used GParted on ext3 and ext4 filesystems without issue.

Please, don't forget to donate a few dollars to the nice folks who compiled this very useful set of utilities.


No comments:

Feel free to drop me a line or ask me a question.