Created
August 16, 2013 03:09
-
-
Save datherra/6246951 to your computer and use it in GitHub Desktop.
Very nice script to shrink the size of you Vagrant box before distribution.
http://vstone.eu/reducing-vagrant-box-size/
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
cat - << EOWARNING | |
Author: @Jan_vStone | |
WARNING: This script will fil up your left over disk space. | |
DO NOT RUN THIS WHEN YOUR VIRTUAL HD IS RAW!!!!!! | |
You should NOT do this on a running system. | |
This is purely for making vagrant boxes damn small. | |
Press Ctrl+C within the next 10 seconds if you want to abort!! | |
EOWARNING | |
sleep 10; | |
echo 'Cleanup bash history' | |
unset HISTFILE | |
[ -f /root/.bash_history ] && rm /root/.bash_history | |
[ -f /home/vagrant/.bash_history ] && rm /home/vagrant/.bash_history | |
echo 'Cleanup log files' | |
find /var/log -type f | while read f; do echo -ne '' > $f; done; | |
echo '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; | |
echo '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; | |
swappart=`cat /proc/swaps | tail -n1 | awk -F ' ' '{print $1}'` | |
swapoff $swappart; | |
dd if=/dev/zero of=$swappart; | |
mkswap $swappart; | |
swapon $swappart; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment