I like Alpine Linux. I don't mind OVH. OVH doesn't offer Alpine Linux as an installable OS, though. So, I have to do a bit of trickery to get my way.
Summary
What we'll do is use QEMU to run a (pseudo) virtual machine to mount the root disk as well as the Alpine installation media. This will enable us to perform the installation! Of course, the root disk can't be in use, so we'll have to reboot into the rescue shell to do all this.
Let's get started.
Procedure
Logging into rescue mode
First, reboot your VPS into rescue mode from the OVH UI. When you do this, you'll get an email from them with a link to reveal your root password for the rescue session.
SSH into the VPS's rescue mode shell with the password you just received:
ssh root@vps-ab010101.vps.ovh.ca # Obviously use your actual VPS hostname here
The rescue mode shell is Debian-based. So, let's get started.
First, we'll install the packages we'll be using:
apt update
apt install -y gpg gpg-agent qemu-system-x86
Fetching the Alpine ISO
Now let's fetch the installation media (I'm doing a little bit of bash-fu here to save lines):
# Set a variable to keep track of our desired Alpine version
export ALPINE_VERSION=3.23.4
# You can set your preferred mirror, too
export ALPINE_MIRROR="https://dl-cdn.alpinelinux.org"
# Download the Alpine ISO and its hash and signature
curl -LOOO "${ALPINE_MIRROR}/alpine/v${ALPINE_VERSION%.*}/releases/x86_64/alpine-virt-${ALPINE_VERSION}-x86_64.iso,{,.asc,.sha256}"
# Download and import Alpine's signing key
curl https://alpinelinux.org/keys/ncopa.asc | gpg --import ;
# Verify the image
sha256sum -c alpine-${ALPINE_VERSION}.iso.sha256
gpg --verify alpine-${ALPINE_VERSION}.iso.asc alpine-${ALPINE_VERSION}.iso
Booting into Alpine from the rescue shell
Now we're ready to begin the installation. We'll spin up a QEMU pseudo virtual machine, mounting the VPS's root disk and the installation ISO. This will enable us to complete the installation:
qemu-system-x86_64 \
-cpu host \
-enable-kvm \
-m 1G \
-net nic \
-net user \
-drive file=/dev/sdb,format=raw,index=0,media=disk \
-cdrom alpine-virt-${ALPINE_VERSION}-x86_64.iso \
-nographic \
-boot d
If all goes well, you should see the following:
Booting from DVD/CD...
Welcome to Alpine Linux 3.23
Kernel 6.18.33-0-virt on x86_64 (/dev/ttyS0)
localhost login:
Perform the installation
As usual, you can log in with root without a password. You can then go through the usual setup script:
# Optionally, set ROOTFS
# export ROOTFS=btrfs
setup-alpine
Most of the answers here are obvious:
- Hostname: I like to use the name of the VPS as it appears in the OVH UI
- Networking: Simply use
dhcpand even though it will be given a private IP (like10.x.y.z) that will work. Don't worry about it - Installation disk is
sda - OVH hosts an APK repo mirror at
http://alpinelinux.mirrors.ovh.net, which may be faster for you depending on where your VPS is located. - Everything else is exactly as normal
That being said, I highly recommend creating another non-root user. Give it an SSH key and password, of course. Then, you can disable the root user later.
Wrapping up
Now that Alpine is installed, you can hop out of the QEMU session:
localhost:~# poweroff
[RESCUE] root@vps-ab010101:~ $
And then reboot the VPS from the OVH UI. Obviously, you'll need to purge the temporary SSH identity that you first recorded when you SSH'd into the rescue shell:
ssh-keygen -R vps-ab010101.vps.ovh.ca
Now you can log into your shiny new Alpine VPS!
ssh root@vps-ab010101.vps.ovh.ca
Welcome to Alpine!
The Alpine Wiki contains a large amount of how-to guides and general
information about administrating Alpine systems.
See <https://wiki.alpinelinux.org/>.
Now's a good time to disable the root user, harden the sshd daemon, etc
Acknowledgements
This was almost entirely ripped off from Phil Pirozhkov's blog post. So big thank you to him!