Showing posts with label gparted. Show all posts
Showing posts with label gparted. Show all posts

Thursday, October 04, 2012

shrinking a "growable" VMware disk (VMDK file)

Just a quick note on shrinking VMware VMDK files.  In short, it's an option WITHIN the VM guest, under VMware Tools or through vdiskmanager command line:
http://www.vmware.com/support/ws5/doc/ws_disk_shrink.html

















or a command like:
"C:\Program\VMware\VMware Server\vmware-vdiskmanager.exe" -k "XP.vmdk"

Backstory
I noticed my XP VM had ballooned to 200GB on the filesystem.  Woah!
[sodo@computer ~]$ ll Virtual\ Machines/XP
total 351188880
drwxr-xr-x. 3 sodo sodo        4096 Jul 25  2011 caches
--rw-rw-rw-  1 sodo sodo 199013260658 Oct  4 13:35 XP.vmdk


The size of single logical C: partition was set to 232GB and it utilized about 1/2 of that in actual files (about 120GB).  Wow.  Bloated!  I had to do something, but quick.  Here's what I did:
1) deleted all extraneous files (~45GB)
2) as I'll be migrating to Win7 soon, I deleted all my XP Hotfix uninstall directories.  This yielded an inCREDible 5GB of data..just in uninstall files!
3) defragged my XP guest

Resize NTFS and Create a Partition
At this point, there was about 45GB left in actual files.  I decided to do two things using gParted
1) resize the NTFS partition down as much as possible with room to spare for other files
2) create a second partition out of the blank space left over.  I did this because VMware Tools can't shrink empty partition space.  See a deeper technical discussion under "Disk Space" on this page.

1a) The resize from 232GB down to 74GB:






























2) Create a new partition



























My Shrink!
Once these two steps were completed, I was then able to go back and perform the shrink within the VM guest using VMware Tools, Shrink tab:

















The shrink took about two hours, but once completed, I was left with a 47GB VMDK!

[sodo@computer ~]$ ll Virtual\ Machines/XP
total 51222880
drwxr-xr-x. 3 sodo sodo        4096 Jul 25  2011 caches
--rw-rw-rw-  1 sodo sodo 49013260288 Oct  4 13:35 XP.vmdk


Awesome!
TAG

References

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:
http://partedmagic.com/doku.php?id=downloads

Overview
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

Detail
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


Shrink
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.

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