Install NixOS on OVH VPS
Contents
-
Backup your data.
-
Reboot into rescue mode with the control panel.
-
Connect to KVM with the control panel.
You can also SSH into the host with login credentials from KVM.
-
Download NixOS image.
Likely you won’t have enough disk space in rescue mode so use ramfs.
1 2 3 4
mkdir /mnt/ramdisk mount -t ramfs ramfs /mnt/ramdisk cd /mnt/ramdisk wget https://channels.nixos.org/nixos-21.11/latest-nixos-minimal-x86_64-linux.iso
-
Load image with qemu.
1 2
apt install qemu-kvm qemu-system-x86_64 -netdev type=user,id=mynet0 -device virtio-net-pci,netdev=mynet0 -m 2048 -enable-kvm -drive index=0,media=disk,if=virtio,file=/dev/sdb -cdrom latest-nixos-minimal-x86_64-linux.iso -boot d
-
Connect to the installer inside QEMU guest.
On your local machine, forward the VNC port locally.
1
ssh -o "UserKnownHostsFile=/dev/null" -NL 5900:localhost:5900 root@${YOUR_HOST}
Then connect to
vnc://localhost
with your VNC client. “Screen Sharing.app” on macOS somehow didn’t work for me. -
Install as usual inside VNC.
Follow instructions in https://nixos.org/manual/nixos/stable/index.html#sec-installation. Use
vda
wheneversda
is referenced.1 2 3 4 5 6 7 8 9 10 11 12
sudo -i parted /dev/vda -- mklabel msdos parted /dev/vda -- mkpart primary 1MiB -8GiB parted /dev/vda -- mkpart primary linux-swap -8GiB 100% mkfs.ext4 -L nixos /dev/sda1 mkswap -L swap /dev/sda2 mount /dev/disk/by-label/nixos /mnt swapon /dev/vda2 nixos-generate-config --root /mnt vi /mnt/etc/nixos/configuration.nix # uncomment boot.loader.grub.device and set it to "/dev/vda" nixos-install
-
Shutdown the qemu guest.
1
shutdown -h now
-
Reboot with the control panel into non-rescue mode.
-
Now that we are no longer in rescue mode, change
/dev/vda
back to/dev/sda
.1
vi /etc/nixos/configuration.nix
-
Done.
Author SEIAROTg
LastMod 2022-05-02