Forked from srijanshetty/package-vagrant-box.md
Last active
January 28, 2022 17:31
-
-
Save infamousjoeg/067c405d7753900bbc32fba2345b2d47 to your computer and use it in GitHub Desktop.
Clean up a vagrant box before packaging
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/bash | |
# We’re now going to clean up disk space on the VM so when we package it into a new Vagrant box, it’s as clean as possible. First, remove APT cache | |
sudo apt-get clean | |
# Then, “zero out” the drive (this is for Ubuntu): | |
sudo dd if=/dev/zero of=/EMPTY bs=1M | |
sudo rm -f /EMPTY | |
# Lastly, let’s clear the Bash History and exit the VM: | |
cat /dev/null > ~/.bash_history && history -c && exit | |
# We’re now going to repackage the server we just created into a new Vagrant Base Box. It’s very easy with Vagrant: | |
vagrant package --output mynew.box |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment