This guide will show you how to install Arch Linux on an OVH VPS.
As you may have noticed, OVH does not have an Arch image, which is a problem. Follow these instructions to install Arch using recovery mode.
Assume anything reffered to as low ram vps
in the guide to be a VPS with <8gb ram
This guide assumes the following:
- Your VPS has one drive
- The following partition layout is used:
PARTITION | DEVICE | TYPE |
---|---|---|
Boot | /dev/sdX1 | BIOS Boot (4) |
Bootstrap (only low ram vps) | /dev/sdX2 | Linux Filesystem (ext4) |
Root | /dev/sdX10 | Linux Filesystem (ext4) |
Please follow these instructions carefully. Make sure you understand arch installation and don't blindly copy paste commands. Ignore bootstrap partition if your VPS can fit an arch bootstrap image on tmpfs, which makes it a lot simpler. Assume if your VPS has <8gb ram you need a bootstrap partition
Go to VPS Panel, choose Boot -> Reboot and select recovery mode.
Check your email for the IP and Password for recovery OS.
SSH to it.
ssh [email protected]
If you get a hostkey mismatch, remove ~/.ssh/known_hosts
. This happens because the recovery os uses a temporary ssh fingerprint.
You need to download arch bootstrap image to be able to do anything.
tip: change the date to last iso date. see last one at https://mirror.rackspace.com/archlinux/iso/latest/
cd /tmp
wget https://mirror.rackspace.com/archlinux/iso/2022.05.01/archlinux-bootstrap-2022.05.01-x86_64.tar.gz
tip: the gzipped image itself will fit on tmpfs even on starter vps, so you dont need to do anything special here if you have a smaller vps, but you will have to later
tip: you can use another mirror closer to you, I chose rackspace because it's a global CDN. https://archlinux.org/download/
list drives: fdisk -l
tip: choose the biggest drive. The 1GB drive will be the recovery livecd, which we don't want to overwrite.
wipe drive: wipefs -a /dev/sdX
tip: it doesn't make sense to use other partition types than ext4 here really, because OVH likely has RAID on their servers and most features of the other filesystems wont be useful in a virtualized environment
fdisk /dev/sdX
Parition the drive like you would normally. Refer to Archwiki install guide for partitioning tips.
Use GPT disklabel.
OVH uses BIOS with GPT, so don't bother with EFI partition. However, you have to make bios boot like mentioned in the table at the start of the guide.
Create a Linux filesystem partition spanning the whole drive.
This will be tricky, as we need to get the bootstrap image loaded on the drive before we extract it.
For this, create your main partition, which will span the entire drive, minus 6 gigabyes.
To make this easier, just say -6G
when fdisk asks you for the last sector
Now you need to make another partition, which will span the 6 gigabytes you left free for bootstrap image. Don't worry, you will be able to reclaim the space later. For this, I recommend just selecting fdisk defeaults as it will pick the last sector correctly.
mkfs.ext4 /dev/sdX10
# Only if using low-ram vps:
mkfs.ext4 /dev/sdX2
mkdir /bootstrap
mount -t tmpfs tmpfs /bootstrap
mkdir /bootstrap
mount /dev/sdX2 /bootstrap
cd /bootstrap
tar xzf /tmp/archlinux-bootstrap-*-x86_64.tar.gz --numeric-owner
mv root.x86_64/* .
rmdir root.x86_64
mount /dev/sdX10 /bootstrap/mnt
Bootstrap system is very barebones, so we have to do this before chrooting.
# uncomment a mirror, e.g the rackspace one
sed -e /etc/pacman.d/mirrorlist 's/"#Server = https:\/\/mirror.rackspace.com"/"Server = https:\/\/mirror.rackspace.com"/
Save some time while downloading packages
sed 's/#ParallelDownloads/ParallelDownloads/' -i /etc/pacman.conf
/bootstrap/bin/arch-chroot /bootstrap
pacman-key --init
pacman-key --populate archlinux
pacstrap /mnt base linux-lts linux-firmware openssh grub
genfstab -U /mnt >> /mnt/etc/fstab
tip: you can use another kernel, linux-lts is optimal for servers though as you won't make use of new features in a virtual environment anyways
Now exit your bootstrap chroot:
exit
/bootstrap/bin/arch-chroot /bootstrap/mnt/
default config is fine, but you can make it better.
# change GRUB_TIMEOUT= to a lower value for faster boot
sed 's/GRUB_TIMEOUT=.*/GRUB_TIMEOUT=2/' /etc/default/grub
# remove everything from GRUB_CMDLINE_LINUX_DEFAULT=, hiding logs is useless and makes debugging harder
sed 's/GRUB_CMDLINE_LINUX_DEFAULT.*/GRUB_CMDLINE_LINUX_DEFAULT=""/' -i /etc/default/grub
grub-install --target=i386-pc /dev/sdX
grub-mkconfig -o /boot/grub/grub.cfg
Your Arch is ready by now. But you should do some post-config steps to make it work better
systemctl enable systemd-networkd
cat << EOF > /etc/systemd/network/20-ovh.network
[Match]
Name=en*
[Network]
DHCP=true
EOF
echo "nameserver 1.1.1.1" > /etc/resolv.conf
pacman -Syu
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
echo "LANG=en_US.UTF-8" >> /etc/locale.conf
locale-gen
pacman -S reflector
reflector --latest 20 --sort rate --save /etc/pacman.d/mirrorlist
This will take a while depending on VPS network speed, as it should test and choose the fastest mirror.
echo "archvps" > /etc/hostname
mkinitcpio -P
passwd
sed 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' -i /etc/ssh/sshd_config
systemctl enable sshd
exit
umount /bootstrap/mnt
umount /bootstrap
exit
Now go to ovh panel and reboot the VPS. It should boot right into Arch.
If you can't ssh to it, connect using KVM in the OVH panel and debug the issue.
Remember the bootstrap partition we made? Yeah, we don't need that anymore.
fdisk /dev/sdX
Then type d
and choose partition number 2. This will remove useless partition.
Now, the tricky part: also remove partition 10. Type d
, followed by 10. BUT, when it asks you, DO NOT erase the ext4 header, otherwise you will have to redo the process.
Now make another partition with id 10 and fill entire drive with it. Write the changes with w
and reboot
. It should automatically fsck
the filesystem and fix up stuff. Now the filesystem is reclaimed.
Thanks, I’ll check it out