Many VPS (or cloud) providers offer a Fedora image; if yours doesn’t, ask them to consider doing so. Fedora 29 cloud images are available here https://alt.fedoraproject.org/cloud/. However, in that case this article gives you an alternative to try.

In some cases the provider will allow you to load a custom image (raw or QCOW format). They may even let you mount an ISO and perform an installation from scratch. Another use case for booting into an installation from the GRUB menu is a remote server without physical access (or via some out of band remote management console). In this case you cannot insert an USB key or an installation DVD to boot. What if you want to use your preferred distribution in any case, and not be forced to use what is provided?

The solution

One possible way to solve this is to start the Fedora installer using GRUB2. As a prerequisite to the following steps, you’ll need a VM (or baremetal machine) running CentOS 7, with a working network and internet connection.

Be aware that the following instructions come with caveats such as noted. It depends on:

The kind of virtualization used by the provider (KVM or VMWare should be fine), and

Whether they allow to start the installed system from the disk volume, or if they use some alternative method to load a different kernel that is not the one shipped by the distribution.

Also, whenever you are modifying the GRUB menu with grub2-mkconfig there is the potential to end up booting into the GRUB shell if the menuentry ends up with an error.

Downloading vmlinuz and initrd

To get the initrd.img and the vmlinuz files issue the following commands one after the other.

curl -L -o /boot/initrd-fedora.img https://download.fedoraproject.org/pub/fedora/linux/releases/29/Server/x86_64/os/isolinux/initrd.img



curl -L -o /boot/vmlinuz-fedora https://download.fedoraproject.org/pub/fedora/linux/releases/29/Server/x86_64/os/isolinux/vmlinuz

Take some notes

Take note of the current IP address, the MAC address, and the default gateway.

ip a

ip route

And take note of the UUID of the boot partition using the command

blkid

In some cases /boot could be a directory inside the root partition, so you need its UUID.

Add a new menu entry to GRUB

Edit this file /etc/grub.d/40_custom and add this entry (similar to other entries you can find in /etc/grub2.cfg):

menuentry 'FedoraNetInstall' {

load_video

set gfxpayload=keep #Keep gfxmode

insmod gzio #Load the gzio module

insmod part_msdos #Load the MS DOS partition module

insmod ext2 #Load the ext2 partition module

set root='hd0,msdos1' #Set Grub root

if [ x$feature_platform_search_hint = xy ];

then

search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' <UUID>

else

search --no-floppy --fs-uuid --set=root <UUID>

fi

linux16 /vmlinuz-fedora ip=<IP>::<Gateway>:<Netmask>:eth0:none nameserver=<DNS> ifname=eth0:<MAC address> inst.repo=https://download.fedoraproject.org/pub/fedora/linux/releases/29/Server/x86_64/os inst.lang=en_US inst.keymap=en

initrd16 /initrd-fedora.img

}

Change the values (UUID, IP, gateway and so on) accordingly to reflect your configuration. If you are using DHCP for networking, you don’t need to enter any networking information. If /boot is not a separate partition, you will have to prepend /boot to /vmlinuz-fedora, and also to /initrd-fedora.img in the menuentry.

Generate the new GRUB configuration file

Before generating your grub.cfg file with grub2-mkconfig it is strongly recommended to copy the original grub.cfg file to another name, such as grub.cfg.bak. Also in the /etc/grub.d directory any files not being used to generate the menuentry should be made non-executable with chmod a-x <filename>. CentOS 7 uses 00_header, 00_tuned, 01_users, and 10_linux when generating grub.cfg. Those files and 40_custom need to remain executable for grub2-mkconfig to work as expected.

To make a new grub.cfg file in /boot/grub2 issue the following command as root or preferably with sudo:https://fedoramagazine.org/howto-use-sudo/

grub2-mkconfig -o /boot/grub2/grub.cfg

Then set up the default menu entry that will be selected upon reboot.

grub2-reboot FedoraNetInstall

Reboot into your new GRUB menu

After reboot, you should see the typical web console that cloud providers usually offer in their management dashboard. If the boot is successful, you should find yourself following a regular Fedora installation.

By adding inst.text here:

linux16 /vmlinuz-fedora inst.text ip=<IP>::<Gateway>:<Netmask>:eth0:none [...]

You could perform the installation in text mode instead of graphical mode.

If GRUB2 is not installed

If the machine is running grub legacy, edit /etc/grub.conf and add these lines:

title Fedora Inst

root (hd0,0)

kernel /boot/vmlinuz-fedora

ip=<IP>::<Gateway>:<Netmask>::eth0:none nameserver=<DNS> ifname=eth0:<MAC address>

inst.repo=https://download.fedoraproject.org/pub/fedora/linux/releases/29/Server/x86_64/os inst.lang=en_US inst.keymap=en

initrd /boot/initrd-fedora.img

Then issue the following command, where vdX is the VM primary disk.

grub-install /dev/vdX

If you get an error stating No suitable drive was found in the generated device map, try to install GRUB manually. Issue the grub command, then run these commands:

grub> find /boot/grub/stage1 find /boot/grub/stage1 (hd0,0)

grub> root (hd0,0)

root (hd0,0)

Filesystem type is ext2fs, partition type 0x83

grub> setup (hd0)

setup (hd0)

Checking if "/boot/grub/stage1" exists... yes

Checking if "/boot/grub/stage2" exists... yes

Checking if "/boot/grub/e2fs_stage1_5" exists... yes

Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 27 sectors are embedded. succeeded

Running "install /boot/grub/stage1 (hd0) (hd0)1+27 p (hd0,0)/boot/grub/stage2 /boot/grub/grub.conf"... succeeded

Done.

grub> quit

Final notes and troubleshooting

This installation method works best with the VM (or baremetal machine) equipped with at least 2GB of RAM. The CentOS installation should be a default install to begin with, and is expected to use the ext2 filesystem as per the examples.

Pay special attention when partitioning the disk, leave the partition table as is, and format the existing partitions.

For more information on grub2 and how to use the tools provided to better customize your GRUB boot experience, check out this Fedora documentation on the GRUB boot loader.

If you do find yourself in the GRUB shell, you can boot from the backup you made earlier (grub.cfg.bak), by doing something like the following:

grub> ls (hd0), (hd0,msdos1), (hd0,gpt2)

grub> ls (hd0,msdos1)/ efi/ grub2/ initramfs.img vmlinuz

grub> ls (hd0,msdos1)/grub2 device.map grub.cfg grub.cfg.bak

grub> configfile (hd0,msdos1)/grub2/grub.cfg.bak

grub> boot