The following section describes how to prepare VM template from scratch, e.g. to be used as base vagrant box or as a base VM template. It's not needed to perform these steps when installing any products, however, might be usefull to maintain version of base OS.
As a base for most VM templates, download Centos 9 stream iso
In installation packages - select Minimal system. Create disk partition /boot and / without swap. Create swap manually
Set root password (vagrant) and create new user (vagrant:vagrant)
In Virtualbox (6.1.38 +) - Insert VBoxGuest Additions Devices -> Insert Guest Additions CD image ...
.
note that in older Virtualbox < 6.1.36 the kernel modules won't build as scripts do not support kernel 5.14 or later.
Log-in as root, and execute one of the following script:
- for non-GUI environment:
bash <(curl -L https://bit.ly/2xDpLwR)
- for GUI environment:
bash <(curl -L http://bit.ly/2GfrE7z)
Reset, check if everything works, if new kernel was installed - then manually uninstall old kernel
uname -a
# outputs which kernel is loaded
rpm -q kernel
# outputs which kernel is installed
yum remove kernel-...
# uninstalls unused kernel
bash <(curl -L ....)
#repeat post-install script 1. for non-GUI or 2. GUI
Stop virtualbox, remove unused IDE, sound card, change video memory etc.
Launch vagrant script to package box. Expecting the virtual machine name is my-sl7-virtualmachine
vagrant package --output centos9mini.box --base my-centos9-virtualmachine
Explanation:
package
instruct vagrant to get virtual machine from virtual box and package it into separate file--output centos9mini.box
writes the result to file named as centos9mini.box--base my-centos9-virtualmachine
takes VirtualBox virtual machine named my-centos9-virtualmachine