↓ Skip to main content

Shrinking Linux VMware images

·2 mins

I’ve been putting together a VMware image based on RedHat over the past couple of weeks and the last step was to try and reduce it in size from a massive 18Gb (28Gb if you included the snapshots). Given that 5Gb of this was free space, this should have been relatively easy to achieve. The original disk wasn’t created at a fixed size and, having removed any snapshots and set the disk to be independent-persistent the Shrink panel of VMware tools finally became active. Unfortunately, it only showed the boot partition.

The next step was to try and use vmware-vdiskmanager to shrink the image from the outside. The instructions suggest that you need to mount each volume individually first and prepare them before shrinking. Unfortunately the DiskMount utility only supports FAT and NTFS partitions. After a bit of searching around on the VMware forums I eventually found a thread with the solution. You need to zero out the unused disk space first before performing the shrink. They recommended the command dd if=/dev/zero of=/empty_file; rm empty_file although I never got as far as the remove because the disk was full! Still, it did the trick and the image is now down to 13Gb. It’s still going to take me 9 hours to upload the 8Gb zip to the US though!

Related

Laptop sanity restored

·1 min
Over the past month or so my laptop has been driving me slowly insane. It’s performance has been absolutely dire, particularly when trying to work under VMWare. I’ve spent many hours staring at the task manager looking for rogue processes that might explain the constant disk thrashing but to no avail. Process Explorer (one of the Sysinternals tools now owned by Microsoft) came to the rescue indicating that, for example, when running VMWare, 50% of the CPU was being used to handle hardware interrupts.

More space

·1 min
Christine’s laptop has been creaking under the weight of our photos so some more storage was long overdue. I was tempted by a cheapo LaCie USB hard drive but the reviews reported a few too many disk failures for my liking. Instead went for a Western Digital My Book 250GB Essential. Plugged it in and it worked. Reformatted it as NTFS and it still works. Only time will tell how reliable it is.

Canon 400D announced

·1 min
As Andy reports, my “new” camera has already been trumped by the recently announced Canon 400D. Improvements include a 10MP self-cleaning sensor and a larger LCD. You can’t win with electronic gadgets though: there is always something better just round the corner. Just think how much I’m saving on disk space though.

4 archived comments

These comments were left on the original WordPress version of this site. Comments are now closed.

  1. Ben

    Thanks so much for mentioning the empty_file trick. (The thread to which you referred is no longer valid.) Performing this on my FC8 VM – in conjunction with Shrink – has resulted in a smaller “clean” image than was otherwise being achieved. So far, you’re the only person I’ve found to make mention of zeroing-out unused data on Linux…

  2. DaveAuthor

    Thanks Sachin. Not sure what happened there - I’ve corrected it now.

  3. nobody

    Thank you so much for this post! I searched for ages trying to find out why shrinking my VMWare image wasn’t making it any smaller, but zeroing out the empty space finally did the trick.