If you are new to the Vultr Marketplace, please see the documentation overview to get started.
After you've installed the required software, configured your application, and set up Marketplace Variables, we strongly suggest optimizing the server before making the snapshot. Some steps to consider are:
You should adapt the suggested code snippets that follow based on your needs and your OS distribution.
These steps are also available as an example shell script in our GitHub repository.
Verify the /tmp
directory exists and has the proper permissions.
# mkdir /tmp
# chmod 1777 /tmp
For yum-based distributions:
# yum update -y
# yum clean all
For apt-based distributions:
# apt-get -y update
# apt-get -y upgrade
# apt-get -y autoremove
# apt-get -y autoclean
Clean the temporary directories.
# rm -rf /tmp/*
# rm -rf /var/tmp/*
Clean SSH Keys.
# rm -f /root/.ssh/authorized_keys /etc/ssh/*key*
# touch /etc/ssh/revoked_keys
# chmod 600 /etc/ssh/revoked_keys
Clean the logs.
# find /var/log -mtime -1 -type f -exec truncate -s 0 {} \;
# rm -rf /var/log/*.gz
# rm -rf /var/log/*.[0-9]
# rm -rf /var/log/*-????????
# echo "" >/var/log/auth.log
Clean old cloud-init information.
# rm -rf /var/lib/cloud/instances/*
Clean the session history.
# history -c
# cat /dev/null > /root/.bash_history
# unset HISTFILE
Update the mlocate
database.
# /usr/bin/updatedb
Wipe the random seed file.
# rm -f /var/lib/systemd/random-seed
Distributions that use systemd
should wipe the machine identifier to prevent boot problems.
# rm -f /etc/machine-id
# touch /etc/machine-id
Clear the login log history.
# cat /dev/null > /var/log/lastlog
# cat /dev/null > /var/log/wtmp
Wipe unused disk space with zeros for security and compression.
# dd if=/dev/zero of=/zerofile
# sync
# rm /zerofile
# sync
Not all Linux distributions support fstrim
, but you may consider running this final step before making the snapshot.
# fstrim /
Vultr can snapshot a running server, but you may prefer a clean shutdown. If so, consider halting and powering off the server before taking the snapshot.
# shutdown -h now
To power off:
After you've created your snapshot, add it to your Vultr Marketplace app as the live image.
This guide is part of the Vultr Marketplace documentation. Please see the documentation overview for more information.