How to perform an automated Fedora and Debian installation when using virt-install?

Contents:


How to actually install Fedora or Debian in an automated way?

To perform an automated Fedora installation, we use Kickstart.
Briefly, Kickstart allows us to make the installation process to be either fully or partially automated. It can be useful when you want to deploy a wide range of workstations or servers.

A Kickstart file simply contains the answers to the questions that arise during the installation process.

A Kickstart file is highly customizable, it enables the execution of scripts both before and after the installation (with or without chroot).

Kickstart was created by Red Hat.

Regarding Debian, we use preseeding also known as Debian Preseed.

Similar to Kickstart, preseeding allows us to make the installation process to be either fully or partially automated. It’s also a file containing answers to questions asked during the installation.

Debian Preseed is developed by the Debian community.

Now, let’s move forward to perform an automated Fedora or Debian installation within virt-install thanks to Kickstart (for Fedora) and Debian Preseed (for Debian).

Use a Kickstart file with virt-install

To use a Kickstart file with virt-install, two options are required.

--initrd-inject, it enables injecting a file to the initrd (the --location option must be used).
-x, --extra-args, it enables to pass additional kernel command-line arguments.

So, to deploy a virtual machine with the Fedora operating system through virt-install in an automated way thanks to Kickstart, we use for example this basic command (with the Kickstart file, ks.cfg in the current directory):

virt-install --name fedora --memory 2048 --vcpus 2 --disk size=16 --network bridge=virbr0 --location=/var/lib/libvirt/images/Fedora-Server-dvd-x86_64-38-1.6.iso --os-variant fedora38 --initrd-inject ./ks.cfg --extra-args "inst.ks=file:/ks.cfg" --boot uefi

FYI, you can use any file name for the Kickstart file.

Use a Preseed file with virt-install

To use a Pressed file with virt-install, two options are required.

--initrd-inject, it enables injecting a file to the initrd (the --location option must be used).
-x, --extra-args, it enables to pass additional kernel command-line arguments.

So, to deploy a virtual machine with the Debian operating system through virt-install in an automated way thanks to a Pressed file, we use for example this basic command (with the Preseed file, preseed.cfg in the current directory):

virt-install --name debian --memory 2048 --vcpus 2 --disk size=16 --network bridge=virbr0 --location=/var/lib/libvirt/images/debian-12.1.0-amd64-netinst.iso --os-variant debian12 --initrd-inject ./preseed.cfg --extra-args "inst.ks=file:preseed.cfg" --boot uefi

FYI, the Preseed must be named preseed.cfg.

Conclusion

I hope you have enjoyed this article and have learned new things! I will be happy if this article is useful for your projects.