Install Fedora on headless remote servers

Context

I run this website on a dedicated server hosted by OVH from their Kimsufi product range. I've had this server for a long time now and even though they publicly advertise that one can install Fedora (and many other) distribution on that product line, they cannot (or don't want to) give me the option to do it on my dedicated server, therefore I had to come up with something to install Fedora without OVH giving me the option to do so.

I did this 2 years ago, it was painful but I thought it was a one time thing to do, so I didn't document the process. Fast forward to about a month ago, I started the Fedora 34 upgrade. When the packages are installed, Fedora reboots into a very simple system where old version packages are replaced by new version packages. In that scenario, obviously no network is needed so the server does not respond to pings. Turns out I had monitoring of my server enabled and the technician seeing a logging screen but no ping hard rebooted my server while it was upgrading. I tried to recover it for a day, gave up and went through a day and half of pain to reinstall Fedora. The hard thing with those servers is that there's no console access, only SSH is available, so if your distribution does not setup the network or does not boot, you have no indication on what went wrong. Now that I've struggled twice, it's time for me to document the process so that next time my server is messed up or I change my server, I can reinstall Fedora in the blink of an eye.

Steps

wget https://mirror.karneval.cz/pub/linux/fedora/linux/releases/34/Server/x86_64/os/images/pxeboot/initrd.img
wget https://mirror.karneval.cz/pub/linux/fedora/linux/releases/34/Server/x86_64/os/images/pxeboot/vmlinuz
menuentry 'FedoraNetInstall' {
   load_video
   set gfxpayload=keep
   insmod gzi
   insmod part_msdos
   insmod ext2
   set root='hd0,msdos1'
   linux16 /boot/vmlinuz-fc34 ip=dhcp inst.repo=https://download.fedoraproject.org/pub/fedora/linux/releases/34/Server/x86_64/os inst.vnc inst.vncpassword=test123
   initrd16 /boot/initrd-fc34.img
}

N.B.: on Debian 9 and Fedora 34, the linux16 and initrd16 are respectively linux and initrd but the content stays the same (+- the /boot prefix).

N.B.2: Check that the settings before linux16 are similar to the ones you have in entries listed in /boot/grub2/grub.cfg, specifically the set root one.

N.B.3: Quadruple check that there are no typo anywhere in this file (I lost a few hours because I put /boot/initramfs-fc34.img instead of the above after initrd16)

Source: