Last active
September 16, 2015 18:38
-
-
Save rogerhu/43b235613acc003c4f31 to your computer and use it in GitHub Desktop.
Updated Vagrant purge.sh script for Ubuntu 14.10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Revised for Ubuntu 14.10. | |
# Credits to: | |
# - https://gist.githubusercontent.com/adrienbrault/3775253/raw/da59136ef0414af151b917bd25a06882f0107947/purge.sh | |
# - http://vstone.eu/reducing-vagrant-box-size/ | |
# - https://github.com/mitchellh/vagrant/issues/343 | |
aptitude -y purge ri | |
aptitude -y purge installation-report landscape-common wireless-tools wpasupplicant | |
aptitude -y purge python-dbus libnl1 python-smartpm python-twisted-core libiw30 | |
aptitude -y purge python-twisted-bin python-pexpect python-pycurl python-serial python-gobject python-pam python-openssl | |
# Remove APT cache | |
apt-get clean -y | |
apt-get autoclean -y | |
# Zero free space to aid VM compression | |
# http://stackoverflow.com/questions/20081116/vagrant-no-space-left-on-device-error | |
dd if=/dev/zero of=/EMPTY bs=1M | |
rm -f /EMPTY | |
# Remove bash history | |
unset HISTFILE | |
rm -f /root/.bash_history | |
rm -f /home/vagrant/.bash_history | |
# Cleanup log files | |
find /var/log -type f | while read f; do echo -ne '' > $f; done; | |
# Whiteout root | |
count=`df --sync -kP / | tail -n1 | awk -F ' ' '{print $4}'`; | |
let count-- | |
dd if=/dev/zero of=/tmp/whitespace bs=1024 count=$count; | |
rm /tmp/whitespace; | |
# Whiteout /boot | |
count=`df --sync -kP /boot | tail -n1 | awk -F ' ' '{print $4}'`; | |
let count-- | |
dd if=/dev/zero of=/boot/whitespace bs=1024 count=$count; | |
rm /boot/whitespace; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment