This knowledge base article explains how to convert your existing OpenVZ VPS to a minimal Alpine Linux installation using a community script.
This method utilizes a script originally shared on Low End Talk to install a recent version of Alpine Linux on a running OpenVZ container. Alpine Linux is an extremely lightweight and security-focused distribution, making it ideal for low-resource VPS environments.
READ THESE CAREFULLY BEFORE PROCEEDING.
Data Loss: The script will wipe all existing data on your VPS. Ensure you have backed up any necessary files before running the command.
Container Type: This script is designed specifically for OpenVZ containers (often referred to as VPS or Container, not KVM/full virtualization). It may not work on all OpenVZ kernels/setups.
OS Requirements: The original script was tested on base installations of CentOS 7, Debian 8, and Ubuntu 16.04. It is also known to work on Debian 12
You must run this command as the root user on your OpenVZ VPS.
Log in to your OpenVZ VPS via SSH as root and run the following command. This command fetches the script and pipes it directly to the shell for execution.
wget -O - https://gist.githubusercontent.com/trimsj/c1fefd650b5f49ceb8f3efc1b6a1404d/raw/alpine.sh | sh
The script will automatically download the Alpine Linux root filesystem, configure basic network settings (using your existing IPv4 address), install OpenSSH and Bash, and then forcibly reboot the container (reboot -f).
Note: The script attempts to preserve your current root password and SSH keys/configuration by copying /etc/shadow and /root/.ssh/ into the new system.
Your VPS should reboot into Alpine Linux. Wait a few minutes, then try to SSH back in using your existing IP address and root password.
If the script was successful, your system is now running a minimal, systemd-free Alpine installation, typically using around 8MB of RAM and 36MB of disk space.
Alpine Linux uses apk for package management.
Update repositories: apk update
Install a package: apk add <package_name>
apk upgradeAlpine Linux uses OpenRC for service initialization. The script automatically adds sshd, mdev, and devfs to the startup runlevels.
Start a service: rc-service <service_name> start
rc-update add <service_name> default