Sei sulla pagina 1di 5

Compacting VirtualBox Disk Images - Linux Guests

6/7/14 10:36 am

" home

# about us

$ leadership

& solutions

! news

' contact us

% services

Click For Menu

! news
Compacting
VirtualBox Disk
Images - Linux
Guests
Friday, October 18, 2013
This article explains the steps
needed to compact a VirtualBox
Disk Image where the guest
operating system is Linux.
S S S S M

10

VirtualBox is a Net Reliant favorite when it comes to


virtualization. It is a professional, enterprise grade
solution that runs on Windows, Linux, Macintosh, and
http://www.netreliant.com/news/8/17/Compacting-VirtualBox-Disk-Images-Linux-Guests.html#.U7g0YRYt3nc

Page 1 of 5

Compacting VirtualBox Disk Images - Linux Guests

Solaris hosts.
VirtualBox allows for flexible storage management by
allowing for the creation of dynamically allocated guest
images. Most users go for the dynamically expanding
images in VirtualBox as they do not want to limit
themselves to a small virtual disk size and at the same
time do not want to waste disk space on their host while
the guest doesn't actually need it. Although these
images will initially be very small and occupy minimal
storage space, over time the images will grow. This is
due to the image expanding every time a disk sector
(virtual) is written to for the first time.
To help reduce excess disk usage, VirtualBox provides a
mechanism for compacting dynamically allocated guest
images. Below are the steps to follow if your guest
operating system is Linux:
1. Start the Linux virtual machine;
2. Clean the free space on the disk of the Linux virtual
machine;
3. Shutdown the Linux virtual machine;
4. Use the VirtualBox VBoxManage utility to compact
the Linux guest image.

6/7/14 10:36 am

Tweets
Net Reliant
@NetReliant

Show Summary
Net Reliant
@NetReliant

26 Jun

#Google quietly entered the #domain


registration business on Monday via Google
Domains, an invite-only beta service:
pcworld.com/article/236706
Show Summary
Net Reliant
@NetReliant

21 Jun

#Health and #fitness #app usage is up 62%


in the past 6 months and growing 87% faster
than any other app category
mashable.com/2014/06/20/hea

Show Photo Details


Tech-FAQ
@tech_faq

21 Jun

The best way to have a good idea is to have


a lot of ideas. - Dr. Linus Pauling
Retweeted by Net Reliant
Expand
Net Reliant
@NetReliant

Step 2: Clean any free disk space


The most effective way to clean free disk space on a
Linux drive is to use the Linux dd utility which is a bitstream duplicator. Open up a terminal window and type
the following command:

26 Jun

Thanks to a leading #Japanese #robotics


expert and Osaku University prof, your next
#companion could be an #android:
finance.yahoo.com/news/woman-mac

Step 1: Start the Linux Virtual Machine


Start the Linux Virtual Machine and log in with
administrative rights.

Follow

20 Jun

Interested in obtaining the Portfolio


Management Professional (#PfMP)
credential? You can now apply to sit the

Tweet to @NetReliant

http://www.netreliant.com/news/8/17/Compacting-VirtualBox-Disk-Images-Linux-Guests.html#.U7g0YRYt3nc

Page 2 of 5

Compacting VirtualBox Disk Images - Linux Guests

6/7/14 10:36 am

dd if=/dev/zero of=zerofillfile bs=1M

This command will zero-fill any free disk space on the


virtual Linux drive.
if= specifies the input file;
/dev/zero indicates a bit-stream of zeros
of= specifies the output file
zerofillfile name of the file containing the bitstream of zeros
bs= indicates the block size
1M indicates that the block size will be 1 megabyte
Once the dd has completed, you will see a message in
your terminal window indicating that there is no space
left on the device:

dd: writing 'zerofillfile': No space left on device

You can now remove zerofillfile using the Linux


rm utility:

rm zerofillfile

Step 3: Shutdown the Linux Virtual Machine


End your session and shutdown the Linux Virtual
Machine.
Step 4: Compact the Linux guest image
To compact the Linux guest image, use the VirtualBox
VBoxManage utility. Assuming a Windows host, use the
following command at the DOS prompt:

http://www.netreliant.com/news/8/17/Compacting-VirtualBox-Disk-Images-Linux-Guests.html#.U7g0YRYt3nc

Page 3 of 5

Compacting VirtualBox Disk Images - Linux Guests

6/7/14 10:36 am

VBoxManage modifyhd --compact "[drive]:\[path_to_imag


e_file]\[name_of_image_file].vdi"

Ensure that you replace the items in square brackets


with your parameters.
If your Windows host complains that VBoxManage
cannot be found or is an invalid command, you may
need to explicitly specify the path to the VirtualBox
executables. So a complete example for compacting a
Linux guest image at the DOS prompt is as follows:

C:\> path C:\Program Files\Oracle\VirtualBox


C:\> VBoxManage modifyhd --compact "C:\netreliant_VMs
\linux_001.vdi"

Once the VirtualBox VBoxManage utility is running you


will see progress indicators in 10% increments starting
from 0% to 100%. And once the process is complete,
you should have a smaller disk image file.

Sitemap
" Home

Follow Us
on Twitter

Contact Us
(

3 Ellesmere Street,
Suite 519
Richmond Hill, Ontario
Canada L4B 4N2

+1.289.637.3325

'

inquiries@netreliant.co
m

# About Us
$ Leadership

via our newsfeed

% Services
& Solutions
! News
' Contact Us

http://www.netreliant.com/news/8/17/Compacting-VirtualBox-Disk-Images-Linux-Guests.html#.U7g0YRYt3nc

Page 4 of 5

Compacting VirtualBox Disk Images - Linux Guests

Copyright 2014 - All Rights Reserved - Net Reliant

http://www.netreliant.com/news/8/17/Compacting-VirtualBox-Disk-Images-Linux-Guests.html#.U7g0YRYt3nc

6/7/14 10:36 am

Privacy Policy | Terms of Use

Page 5 of 5

Potrebbero piacerti anche