LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 04-13-2009, 12:13 PM   #1
chris1606
LQ Newbie
 
Registered: Apr 2009
Posts: 2

Rep: Reputation: 0
Reduce virtual image size of Linux guest in VirtualBox


I'm trying to reduce the size of a Linux virtual image that I want to use as a base image for further work. Initially I picked a 16 GB dynamically expanding disk. Then I installed Ubuntu server with the packages I need. Disk size: ~500MB. Then I upgraded all packages to the latest version. Disk size in the guest OS: ~520MB. Disk size of the .vdi virtual image: more than 1GB! Compacting the .vdi doesn't reduce its size.

What I need is a tool to clean up the unused disk space and fill it with zeros so that VirtualBox can compact the .vdi file back to 520MB.

There's a lot of documentation out there on how to do this for Windows (delete unnecessary files with CCleaner, defrag and then fill the free space with zeros using some tool called sdelete.exe)

I've found several links suggesting that creating a huge file full of zeros would do the trick (e.g. dd if=/dev/zero of=~/zeros) but that only increased the size of the .vdi image in the end.

I guess it's a problem with the ext3 file system that Ubuntu uses. I don't know much about it, but a large file doesn't work...

So far the only way to handle it was to create a new virtual hard disk, copy the whole installation over and fix the bootloader. That's hardly practical to do... Isn't there some better way?
 
Old 04-13-2009, 02:46 PM   #2
ophirg
Member
 
Registered: Jan 2008
Location: Israel
Distribution: Kubuntu 13.10
Posts: 134

Rep: Reputation: 34
try using the reiserfs filesystem. it can handle small files very well.
maybe that will help.
but i'm not sure about that huge file with zeros. although it will fill the image with many zeros, the filesystem will have to create a lot of metadata to go with those zeros(i think).
 
Old 04-13-2009, 08:05 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,445

Rep: Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068
Seems it's been removed - do you get the "Error: Shrink hard disk operation is not implemented! " message ?.
Open ticket here
 
Old 04-14-2009, 07:51 AM   #4
chris1606
LQ Newbie
 
Registered: Apr 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Yes, the "shrink" feature in VirtualBox is gone since version 2.1 or so. But you can still do it with the "clonehd" command, which creates a shrinked version.

I've tried the ReiserFS briefly, and on a freshly created .vdi it seems to work!!!! Thanks for the tip!
 
  


Reply

Tags
ext3, vdi, virtualbox


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VirtualBox virtual disk image backup? .vdi .sav brianpbarnes Linux - Software 3 07-17-2009 03:12 PM
Zenwalk 4.8 does not work as a Linux guest in Virtualbox 1.5 paulsiu Zenwalk 7 11-21-2007 01:14 PM
How can I reduce and image size with php's GD library? abefroman Linux - Software 1 10-18-2005 12:29 PM
reduce the kernel image size further abirami Linux - Networking 1 10-05-2004 11:06 AM
Using Gimp to reduce size of image for web esteeven Linux - Software 2 10-01-2002 10:08 AM


All times are GMT -5. The time now is 05:50 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration