Skip to content

Instantly share code, notes, and snippets.

@waako
Created August 27, 2013 18:13
Show Gist options
  • Save waako/6357021 to your computer and use it in GitHub Desktop.
Save waako/6357021 to your computer and use it in GitHub Desktop.
cleaning up vagrant box before packaging
guest$ vagrant ssh
vagrant$ sudo su
# Total upgrade
apt-get update && apt-get upgrade
apt-get dist-upgrade
# Ensure the box is minimally provisioned
apt-get -q -y install puppet zerofree
# This seems too dangerous - for now!
#aptitude purge cpp-4.3 gcc-4.3-base
#aptitude purge cpp-4.4 gcc-4.4-base g++-4.4
#aptitude purge python2.6 python2.6-minimal
# Dangerous: selectively remove packages you don't think you need
#orphaner --purge
#debfoster
# Clear as many apt caches as we can
apt-get update -qq
apt-get clean
# Delete lots and lots of files
rm -rf /home/vagrant/.bash_history \
/root/.bash_history \
/usr/src/vboxguest* \
/usr/share/doc \
/var/lib/dhcp*/*
find /var/cache -type f -exec rm -rf {} \;
find /var/log -type f | while read f; do echo -ne '' > $f; done;
# Zero the free space - this first command WILL fire an error
dd if=/dev/zero of=/EMPTY bs=1M
rm -f /EMPTY
# Optional, if it's running: clear memcache
etc/init.d/memcache restart
exit # log out of sudo
exit # log out of the instance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment