Last active
January 1, 2016 00:09
-
-
Save oreh/8064497 to your computer and use it in GitHub Desktop.
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
apt-get update | |
apt-get install -y git build-essential linux-headers-$(uname -r) | |
mkdir -p /root/.ssh | |
chmod og-rwx /root/.ssh | |
touch /root/.ssh/authorized_keys | |
cat >> /root/.ssh/authorized_keys << EOF | |
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCrj72pssAp3W1DO59AiaNUcaVoBP55+500aTle/rm1qzbTZRqlAlIXf3oI45brrhmDPu5nDeO8B5b55lT0gfLWff96uI+o0+BAcvFaWiG60+zJt5cwCqMpLCtTLNYmmnNBXLVluKFhRYtu/EOzWLTKv3cvlzJoGmhzyfnt/bYfpMFwk65QC81kGhQaZfAoeXgvKpUTroi5R1NFfHzgrp+DPLACsrXuPi2FF0ujz2lXYRbpCSDI+BQGUf/RMnFFVWxA+SXs/Q4YrjMEngTHRNmkI5JeJQ9ieD6SS7OxM1UKu+bASdktcMTvG4lLyQz8oFVtKHkE+F+j/CVi0kmOEStx | |
EOF | |
mount /dev/cdrom /mnt | |
/mnt/VBoxLinuxAdditions.run | |
umount -l /mnt | |
#!/bin/bash | |
# Credits to: | |
# - http://vstone.eu/reducing-vagrant-box-size/ | |
# - https://github.com/mitchellh/vagrant/issues/343 | |
# Remove APT cache | |
apt-get clean -y | |
apt-get autoclean -y | |
# Zero free space to aid VM compression | |
dd if=/dev/zero of=/EMPTY bs=1M | |
rm -f /EMPTY | |
# Remove bash history | |
unset HISTFILE | |
rm -f /root/.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; | |
swappart=`cat /proc/swaps | tail -n1 | awk -F ' ' '{print $1}'` | |
swapoff $swappart; | |
dd if=/dev/zero of=$swappart; | |
mkswap $swappart; | |
swapon $swappart; | |
rm /etc/udev/rules.d/70-persistent-net.rules |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment