minimize file size of appliances

Discussions about using Linux guests in VirtualBox.
Post Reply
richardbronosky
Posts: 2
Joined: 20. Feb 2011, 07:23
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Linux

minimize file size of appliances

Post by richardbronosky »

I'd like to compile a list of good TODOs for cleaning up a Linux guest before exporting as an appliance.
currently I do:
1. Clean out all of the cloned repos.
This may seem odd, but the fact is whenever someone uses this appliance the open source projects are going to be out of date so an update would be needed. Why transmit outdated code? I do this with:

Code: Select all

# from my src dir where all the code lives
cur=$PWD;
for g in $(find . -type d -name .git | sort | sed 's/.\{5\}$//');
do
    echo $g;
    (cd $g; [[ $PWD != $cur ]] && rm -rf * .git/refs/*/* .git/objects/* .git/branches/*)
done
2. Clean up the package manager (Debian/Ubuntu)
sudo localepurge
sudo apt-get purge
sudo apt-get autoremove

I'd love to hear more suggestions. I've used du to find the heavy directories but do not feel comfortable removing things in these dirs:

Code: Select all

131M  /lib
42M   /usr/bin
24M   /usr/include
363M  /usr/lib
72M   /usr/local
4.9M  /usr/sbin
272M  /usr/share
81M   /usr/src
3.4M  /var/backups
36M   /var/cache
123M  /var/lib
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: minimize file size of appliances

Post by Sasquatch »

And in exactly what way does this have to do with VB? All I see is some generic Linux stuff to remove unneeded files and packages. What do you plan to accomplish with this? Because the VDI won't get smaller by just doing this.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
richardbronosky
Posts: 2
Joined: 20. Feb 2011, 07:23
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Linux

Re: minimize file size of appliances

Post by richardbronosky »

Sasquatch wrote:And in exactly what way does this have to do with VB? All I see is some generic Linux stuff to remove unneeded files and packages. What do you plan to accomplish with this? Because the VDI won't get smaller by just doing this.
I was very disappointed to experience what you predict here (the disk not getting smaller) after hours of effort to shrink OVA. I would appreciate any NON-Windows (defrag etc.) instructions on how to prepare a Linux (Ubuntu specifically) host for appliance export.

I tried installing secure-delete and running sfill -llz to zero out the frees pace. However, before the temp file could be removed the drive went into read-only and would never boot again. Since I have an export (albiet excessively large) I didn't spend much time trying to recover the disk.
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: minimize file size of appliances

Post by Sasquatch »

Well, you had to run sdelete instead (never ran it, so maybe your command is part of it) and once it's done, run VBoxManage modifyhd --compact.

Another option was to use Mpack's CloneVDI tool and clone the VDI and shrink it at the same time. You can tell it to keep the VDI UUID the same, which should help in the mounting inside the Guest.
Which reminds me of the next thing: if you export it to an appliance for importing, the mouting of the root file system might fail due to UUID mismatch inside. To avoid that, modify /etc/fstab and change the UUID notation to a device notation, like /dev/sda1.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
Post Reply