Unattended Installation of RedHat Enterprise Linux 9.7 on VirtualBox

The following steps describe an unattended installation of RedHat Enterprise Linux 9.7 on VirtualBox. The host system in my case is Windows 10.

General Preparations for new VM Installations

These steps have to be done once and can be used to install also other guest Operating Systems (e.g. Windows):
Add the path of vboxmanage to the Windows Path environment variable. For example with Win+r and then enter:

rundll32 sysdm.cpl,EditEnvironmentVariables

Add C:\Program Files\Oracle\VirtualBox to the User variable Path.
A directory c:\vms for the virtual machines on the host system should exist:

mkdir c:\vms

Preparation of the Linux guest installation

Download the RedHat Enterprise Linux 9.7 iso file from RedHat and place it in the folder c:\sw. The original RedHat iso file will be modified to include the Kickstart file. These steps need to be done only once on another RHEL 9 machine or another Oracle Linux 9.5 VM:

# install the lorax tool
dnf -y install lorax

# create the Kickstart file
cat >~/ks.cfg <<'EOF'
lang en_US
keyboard --xlayouts='de'
timezone Europe/Berlin
# root password: changeme
# the password hashes can be created with: openssl passwd -6
rootpw --iscrypted $2b$10$MvOC8eg0rIsuQQnXYrkslOXsvDOe8XLPd8YIgYoMvtGHySbP1nQCG
user --name=user1 --iscrypted --password=$2b$10$MvOC8eg0rIsuQQnXYrkslOXsvDOe8XLPd8YIgYoMvtGHySbP1nQCG
reboot
text
cdrom
bootloader --append="quiet crashkernel=1G-4G:192M,4G-64G:256M,64G:512M"
zerombr
clearpart --all --initlabel
autopart --type=plain --nohome
network --bootproto=dhcp --device=link --onboot=on
firstboot --disable
selinux --disabled
firewall --disabled
%packages
@^graphical-server-environment
kernel-headers
kernel-devel
glibc-devel
glibc-headers
gcc
elfutils-libelf-devel
make
bzip2
perl
%end
%post --interpreter=/usr/bin/bash --log=/root/ks-post.log
# permit root login
sed -i 's/^#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
# install VirtualBox Guest Additions
df -h
mkdir -p /tmp/vboxcdrom
mount /dev/sr1 /tmp/vboxcdrom
/usr/bin/bash /tmp/vboxcdrom/VBoxLinuxAdditions.run
umount /tmp/vboxcdrom
rmdir /tmp/vboxcdrom
%end
EOF

# remove a previous custom iso image and create the new one
rm -f /sw/rhel_9.7_uefi_custom.iso
mkksiso --ks ~/ks.cfg -R "set default=\"1\"" "set default=\"0\"" -R "set timeout=60" "set timeout=5" /sw/rhel-9.7-x86_64-dvd.iso /sw/rhel_9.7_uefi_custom.iso
Sample Output (click to expand):
[root@lin1 ~]# # install the lorax tool
[root@lin1 ~]# dnf -y install lorax
Extra Packages for Enterprise Linux 9 - x86_64                                                                       82 kB/s |  34 kB     00:00
Extra Packages for Enterprise Linux 9 - x86_64                                                                      3.3 MB/s |  21 MB     00:06
Oracle Linux 9 BaseOS Latest (x86_64)                                                                                40 kB/s | 4.3 kB     00:00
Oracle Linux 9 BaseOS Latest (x86_64)                                                                                10 MB/s | 119 MB     00:11
Oracle Linux 9 Application Stream Packages (x86_64)                                                                  38 kB/s | 4.5 kB     00:00
Oracle Linux 9 Application Stream Packages (x86_64)                                                                 9.6 MB/s |  88 MB     00:09
Oracle Linux 9 UEK Release 7 (x86_64)                                                                                43 kB/s | 3.5 kB     00:00
Oracle Linux 9 UEK Release 7 (x86_64)                                                                                11 MB/s | 100 MB     00:09
Last metadata expiration check: 0:00:17 ago on Tue 21 Apr 2026 09:00:00 PM CEST.
Dependencies resolved.
====================================================================================================================================================
 Package                                   Architecture             Version                               Repository                           Size
====================================================================================================================================================
Installing:
 lorax                                     x86_64                   34.9.29-1.0.1.el9                     ol9_appstream                       255 k
Installing dependencies:
 isomd5sum                                 x86_64                   1:1.2.3-14.el9                        ol9_appstream                        35 k
 libburn                                   x86_64                   1.5.4-5.el9                           ol9_appstream                       176 k
 libisoburn                                x86_64                   1.5.4-5.el9_5                         ol9_appstream                       419 k
 libisofs                                  x86_64                   1.5.4-4.el9                           ol9_appstream                       227 k
 lorax-templates-generic                   x86_64                   34.9.29-1.0.1.el9                     ol9_appstream                        98 k
 lorax-templates-rhel                      noarch                   9.7-3.0.1.el9                         ol9_appstream                        97 k
 mtools                                    x86_64                   4.0.26-5.el9_7                        ol9_baseos_latest                   249 k
 pbzip2                                    x86_64                   1.1.13-6.el9                          ol9_appstream                        59 k
 python3-kickstart                         noarch                   3.32.15-1.0.2.el9                     ol9_appstream                       874 k
 python3-mako                              noarch                   1.1.4-6.el9                           ol9_appstream                       263 k
 python3-pycdlib                           noarch                   1.11.0-5.el9                          ol9_appstream                       297 k
 syslinux                                  x86_64                   6.04-0.20.el9                         ol9_baseos_latest                   607 k
 syslinux-nonlinux                         noarch                   6.04-0.20.el9                         ol9_baseos_latest                   642 k
 xorriso                                   x86_64                   1.5.4-5.el9_5                         ol9_appstream                       325 k
 xz-lzma-compat                            x86_64                   5.2.5-8.el9_0                         ol9_appstream                        21 k

Transaction Summary
====================================================================================================================================================
Install  16 Packages

Total size: 4.5 M
Installed size: 11 M
Downloading Packages:
[SKIPPED] mtools-4.0.26-5.el9_7.x86_64.rpm: Already downloaded
[SKIPPED] syslinux-6.04-0.20.el9.x86_64.rpm: Already downloaded
[SKIPPED] syslinux-nonlinux-6.04-0.20.el9.noarch.rpm: Already downloaded
[SKIPPED] isomd5sum-1.2.3-14.el9.x86_64.rpm: Already downloaded
[SKIPPED] libburn-1.5.4-5.el9.x86_64.rpm: Already downloaded
[SKIPPED] libisoburn-1.5.4-5.el9_5.x86_64.rpm: Already downloaded
[SKIPPED] libisofs-1.5.4-4.el9.x86_64.rpm: Already downloaded
[SKIPPED] lorax-34.9.29-1.0.1.el9.x86_64.rpm: Already downloaded
[SKIPPED] lorax-templates-generic-34.9.29-1.0.1.el9.x86_64.rpm: Already downloaded
[SKIPPED] lorax-templates-rhel-9.7-3.0.1.el9.noarch.rpm: Already downloaded
[SKIPPED] pbzip2-1.1.13-6.el9.x86_64.rpm: Already downloaded
[SKIPPED] python3-kickstart-3.32.15-1.0.2.el9.noarch.rpm: Already downloaded
[SKIPPED] python3-mako-1.1.4-6.el9.noarch.rpm: Already downloaded
[SKIPPED] python3-pycdlib-1.11.0-5.el9.noarch.rpm: Already downloaded
[SKIPPED] xorriso-1.5.4-5.el9_5.x86_64.rpm: Already downloaded
[SKIPPED] xz-lzma-compat-5.2.5-8.el9_0.x86_64.rpm: Already downloaded
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                            1/1
  Installing       : xz-lzma-compat-5.2.5-8.el9_0.x86_64                                                                                       1/16
  Installing       : python3-pycdlib-1.11.0-5.el9.noarch                                                                                       2/16
  Installing       : python3-mako-1.1.4-6.el9.noarch                                                                                           3/16
  Installing       : python3-kickstart-3.32.15-1.0.2.el9.noarch                                                                                4/16
  Installing       : pbzip2-1.1.13-6.el9.x86_64                                                                                                5/16
  Installing       : libisofs-1.5.4-4.el9.x86_64                                                                                               6/16
  Installing       : libburn-1.5.4-5.el9.x86_64                                                                                                7/16
  Installing       : libisoburn-1.5.4-5.el9_5.x86_64                                                                                           8/16
  Running scriptlet: xorriso-1.5.4-5.el9_5.x86_64                                                                                              9/16
  Installing       : xorriso-1.5.4-5.el9_5.x86_64                                                                                              9/16
  Running scriptlet: xorriso-1.5.4-5.el9_5.x86_64                                                                                              9/16
  Installing       : isomd5sum-1:1.2.3-14.el9.x86_64                                                                                          10/16
  Installing       : mtools-4.0.26-5.el9_7.x86_64                                                                                             11/16
  Installing       : syslinux-nonlinux-6.04-0.20.el9.noarch                                                                                   12/16
  Installing       : syslinux-6.04-0.20.el9.x86_64                                                                                            13/16
  Installing       : lorax-templates-generic-34.9.29-1.0.1.el9.x86_64                                                                         14/16
  Installing       : lorax-templates-rhel-9.7-3.0.1.el9.noarch                                                                                15/16
  Installing       : lorax-34.9.29-1.0.1.el9.x86_64                                                                                           16/16
  Running scriptlet: lorax-34.9.29-1.0.1.el9.x86_64                                                                                           16/16
  Verifying        : mtools-4.0.26-5.el9_7.x86_64                                                                                              1/16
  Verifying        : syslinux-6.04-0.20.el9.x86_64                                                                                             2/16
  Verifying        : syslinux-nonlinux-6.04-0.20.el9.noarch                                                                                    3/16
  Verifying        : isomd5sum-1:1.2.3-14.el9.x86_64                                                                                           4/16
  Verifying        : libburn-1.5.4-5.el9.x86_64                                                                                                5/16
  Verifying        : libisoburn-1.5.4-5.el9_5.x86_64                                                                                           6/16
  Verifying        : libisofs-1.5.4-4.el9.x86_64                                                                                               7/16
  Verifying        : lorax-34.9.29-1.0.1.el9.x86_64                                                                                            8/16
  Verifying        : lorax-templates-generic-34.9.29-1.0.1.el9.x86_64                                                                          9/16
  Verifying        : lorax-templates-rhel-9.7-3.0.1.el9.noarch                                                                                10/16
  Verifying        : pbzip2-1.1.13-6.el9.x86_64                                                                                               11/16
  Verifying        : python3-kickstart-3.32.15-1.0.2.el9.noarch                                                                               12/16
  Verifying        : python3-mako-1.1.4-6.el9.noarch                                                                                          13/16
  Verifying        : python3-pycdlib-1.11.0-5.el9.noarch                                                                                      14/16
  Verifying        : xorriso-1.5.4-5.el9_5.x86_64                                                                                             15/16
  Verifying        : xz-lzma-compat-5.2.5-8.el9_0.x86_64                                                                                      16/16

Installed:
  isomd5sum-1:1.2.3-14.el9.x86_64                 libburn-1.5.4-5.el9.x86_64                  libisoburn-1.5.4-5.el9_5.x86_64
  libisofs-1.5.4-4.el9.x86_64                     lorax-34.9.29-1.0.1.el9.x86_64              lorax-templates-generic-34.9.29-1.0.1.el9.x86_64
  lorax-templates-rhel-9.7-3.0.1.el9.noarch       mtools-4.0.26-5.el9_7.x86_64                pbzip2-1.1.13-6.el9.x86_64
  python3-kickstart-3.32.15-1.0.2.el9.noarch      python3-mako-1.1.4-6.el9.noarch             python3-pycdlib-1.11.0-5.el9.noarch
  syslinux-6.04-0.20.el9.x86_64                   syslinux-nonlinux-6.04-0.20.el9.noarch      xorriso-1.5.4-5.el9_5.x86_64
  xz-lzma-compat-5.2.5-8.el9_0.x86_64

Complete!
[root@lin1 ~]#
[root@lin1 ~]# # create the Kickstart file
[root@lin1 ~]# cat >~/ks.cfg <<'EOF'
> lang en_US
> keyboard --xlayouts='de'
> timezone Europe/Berlin
> # root password: changeme
> # the password hashes can be created with: openssl passwd -6
> rootpw --iscrypted $2b$10$MvOC8eg0rIsuQQnXYrkslOXsvDOe8XLPd8YIgYoMvtGHySbP1nQCG
> user --name=user1 --iscrypted --password=$2b$10$MvOC8eg0rIsuQQnXYrkslOXsvDOe8XLPd8YIgYoMvtGHySbP1nQCG
> reboot
> text
> cdrom
> bootloader --append="quiet crashkernel=1G-4G:192M,4G-64G:256M,64G:512M"
> zerombr
> clearpart --all --initlabel
> autopart --type=plain --nohome
> network --bootproto=dhcp
> firstboot --disable
> selinux --disabled
> firewall --disabled
> %packages
> @^graphical-server-environment
> kernel-headers
> kernel-devel
> glibc-devel
> glibc-headers
> gcc
> elfutils-libelf-devel
> make
> bzip2
> perl
> %end
> %post --interpreter=/usr/bin/bash --log=/root/ks-post.log
> # permit root login
> sed -i 's/^#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
> # install VirtualBox Guest Additions
> df -h
> mkdir -p /tmp/vboxcdrom
> mount /dev/sr1 /tmp/vboxcdrom
> /usr/bin/bash /tmp/vboxcdrom/VBoxLinuxAdditions.run
> umount /tmp/vboxcdrom
> rmdir /tmp/vboxcdrom
> %end
> EOF
[root@lin1 ~]#
[root@lin1 ~]# # remove a previous custom iso image and create the new one
[root@lin1 ~]# rm -f /sw/rhel_9.7_uefi_custom.iso
[root@lin1 ~]# mkksiso --ks ~/ks.cfg -R "set default=\"1\"" "set default=\"0\"" -R "set timeout=60" "set timeout=5" /sw/rhel-9.7-x86_64-dvd.iso /sw/rhel_9.7_uefi_custom.iso
xorriso 1.5.4 : RockRidge filesystem manipulator, libburnia project.

xorriso : NOTE : Loading ISO image tree from LBA 0
xorriso : UPDATE :    7596 nodes read in 1 seconds
xorriso : NOTE : Detected El-Torito boot information which currently is set to be discarded
Drive current: -indev '/sw/rhel-9.7-x86_64-dvd.iso'
Drive access : shared:readonly
Media current: stdio file, overwriteable
Media status : is written , is appendable
Boot record  : El Torito , MBR isohybrid cyl-align-off GPT
Media summary: 1 session, 6641880 data blocks, 12.7g data,  637g free
Volume id    : 'RHEL-9-7-0-BaseOS-x86_64'
xorriso : UPDATE :       1 files restored (    60b) in 1 seconds = 0.0xD
Extracted from ISO image: file '/.discinfo'='/tmp/mkksiso-piojt35f/.discinfo'
xorriso : UPDATE :       1 files restored (  3326b) in 1 seconds = 0.0xD
Extracted from ISO image: file '/isolinux/isolinux.cfg'='/tmp/mkksiso-piojt35f/isolinux/isolinux.cfg'
xorriso : UPDATE :       1 files restored (  1654b) in 1 seconds = 0.0xD
Extracted from ISO image: file '/EFI/BOOT/grub.cfg'='/tmp/mkksiso-piojt35f/EFI/BOOT/grub.cfg'
INFO:iso arch = x86_64
INFO:Volume Id = RHEL-9-7-0-BaseOS-x86_64
WARNING:No s390 config files found
xorriso 1.5.4 : RockRidge filesystem manipulator, libburnia project.

xorriso : NOTE : Loading ISO image tree from LBA 0
xorriso : UPDATE :    7596 nodes read in 1 seconds
xorriso : NOTE : Detected El-Torito boot information which currently is set to be discarded
Drive current: -indev '/sw/rhel-9.7-x86_64-dvd.iso'
Drive access : shared:readonly
Media current: stdio file, overwriteable
Media status : is written , is appendable
Boot record  : El Torito , MBR isohybrid cyl-align-off GPT
Media summary: 1 session, 6641880 data blocks, 12.7g data,  637g free
Volume id    : 'RHEL-9-7-0-BaseOS-x86_64'
xorriso : UPDATE :       7 files restored (6715.7k) in 1 seconds = 5.0xD
Extracted from ISO image: file '/EFI'='/tmp/mkksiso-r7l0_pgk/EFI'
xorriso 1.5.4 : RockRidge filesystem manipulator, libburnia project.

xorriso : NOTE : Loading ISO image tree from LBA 0
xorriso : UPDATE :    7596 nodes read in 1 seconds
xorriso : NOTE : Detected El-Torito boot information which currently is set to be discarded
Drive current: -indev '/sw/rhel-9.7-x86_64-dvd.iso'
Media current: stdio file, overwriteable
Media status : is written , is appendable
Boot record  : El Torito , MBR isohybrid cyl-align-off GPT
Media summary: 1 session, 6641880 data blocks, 12.7g data,  637g free
Volume id    : 'RHEL-9-7-0-BaseOS-x86_64'
Drive current: -outdev '/sw/rhel_9.7_uefi_custom.iso'
Media current: stdio file, overwriteable
Media status : is blank
Media summary: 0 sessions, 0 data blocks, 0 data,  637g free
xorriso : WARNING : -volid text does not comply to ISO 9660 / ECMA 119 rules
xorriso : NOTE : Replayed 19 boot related commands
Updating '/tmp/mkksiso-piojt35f/EFI/BOOT/grub.cfg' to '/EFI/BOOT/grub.cfg'
xorriso : UPDATE : Added/overwrote '/EFI/BOOT/grub.cfg'  (1903)
Differences detected and updated. (runtime 0.0 s)
Updating '/tmp/mkksiso-piojt35f/isolinux/isolinux.cfg' to '/isolinux/isolinux.cfg'
xorriso : UPDATE : Added/overwrote '/isolinux/isolinux.cfg'  (3576)
Differences detected and updated. (runtime 0.0 s)
Updating '/tmp/mkksiso-piojt35f/.discinfo' to '/.discinfo'
xorriso : UPDATE : Adjusted attributes of '/.discinfo'
Differences detected and updated. (runtime 0.0 s)
xorriso : UPDATE :       1 files added in 1 seconds
Added to ISO image: file '/ks.cfg'='/root/ks.cfg'
xorriso : NOTE : Copying to System Area: 32768 bytes from file '--interval:imported_iso:0s-15s:zero_mbrpt,zero_gpt:/sw/rhel-9.7-x86_64-dvd.iso'
libisofs: NOTE : Automatically adjusted MBR geometry to 1654/255/63
xorriso : UPDATE : Writing:       5968s    0.1%   fifo  99%  buf  50%
xorriso : UPDATE : Writing:      66000s    1.0%   fifo  98%  buf  50%  110.5xD
xorriso : UPDATE : Writing:     127424s    1.9%   fifo 100%  buf  50%   90.4xD
xorriso : UPDATE : Writing:     189808s    2.9%   fifo  99%  buf  50%   91.9xD
xorriso : UPDATE : Writing:     246720s    3.7%   fifo  98%  buf  50%   83.7xD
xorriso : UPDATE : Writing:     312304s    4.7%   fifo  99%  buf  50%   96.5xD
xorriso : UPDATE : Writing:     388000s    5.8%   fifo  98%  buf  50%  111.4xD
xorriso : UPDATE : Writing:     468912s    7.1%   fifo  99%  buf  50%  119.1xD
xorriso : UPDATE : Writing:     550480s    8.3%   fifo  99%  buf  50%  120.4xD
xorriso : UPDATE : Writing:     626752s    9.4%   fifo  97%  buf  50%  112.5xD
xorriso : UPDATE : Writing:     705568s   10.6%   fifo  99%  buf  50%  116.2xD
xorriso : UPDATE : Writing:     795472s   12.0%   fifo  99%  buf  50%  132.7xD
xorriso : UPDATE : Writing:     861872s   13.0%   fifo 100%  buf  50%   97.8xD
xorriso : UPDATE : Writing:     929488s   14.0%   fifo  99%  buf  50%   99.7xD
xorriso : UPDATE : Writing:    1010832s   15.2%   fifo  99%  buf  50%  120.1xD
xorriso : UPDATE : Writing:    1086624s   16.4%   fifo 100%  buf  50%  111.9xD
xorriso : UPDATE : Writing:    1153104s   17.4%   fifo 100%  buf  50%   98.0xD
xorriso : UPDATE : Writing:    1221936s   18.4%   fifo 100%  buf  50%  101.2xD
xorriso : UPDATE : Writing:    1317584s   19.8%   fifo  99%  buf  50%  141.0xD
xorriso : UPDATE : Writing:    1384096s   20.8%   fifo 100%  buf  50%   97.8xD
xorriso : UPDATE : Writing:    1448480s   21.8%   fifo 100%  buf  50%   94.5xD
xorriso : UPDATE : Writing:    1514208s   22.8%   fifo 100%  buf  50%   96.8xD
xorriso : UPDATE : Writing:    1599632s   24.1%   fifo 100%  buf  50%  125.7xD
xorriso : UPDATE : Writing:    1656912s   24.9%   fifo  99%  buf  50%   84.3xD
xorriso : UPDATE : Writing:    1708736s   25.7%   fifo 100%  buf  50%   84.7xD
xorriso : UPDATE : Writing:    1780400s   26.8%   fifo  99%  buf  50%  105.4xD
xorriso : UPDATE : Writing:    1866240s   28.1%   fifo 100%  buf  50%  126.7xD
xorriso : UPDATE : Writing:    1934304s   29.1%   fifo 100%  buf  50%  100.2xD
xorriso : UPDATE : Writing:    2002048s   30.1%   fifo 100%  buf  50%   99.9xD
xorriso : UPDATE : Writing:    2088880s   31.4%   fifo  99%  buf  50%  128.2xD
xorriso : UPDATE : Writing:    2149072s   32.3%   fifo 100%  buf  50%   88.4xD
xorriso : UPDATE : Writing:    2199952s   33.1%   fifo 100%  buf  50%   75.0xD
xorriso : UPDATE : Writing:    2260336s   34.0%   fifo  99%  buf  50%   89.0xD
xorriso : UPDATE : Writing:    2335344s   35.1%   fifo  99%  buf  50%  110.6xD
xorriso : UPDATE : Writing:    2378112s   35.8%   fifo  99%  buf  50%   62.8xD
xorriso : UPDATE : Writing:    2417776s   36.4%   fifo  99%  buf  50%   58.4xD
xorriso : UPDATE : Writing:    2482160s   37.4%   fifo  99%  buf  50%   95.0xD
xorriso : UPDATE : Writing:    2555040s   38.4%   fifo 100%  buf  50%  107.6xD
xorriso : UPDATE : Writing:    2603565s   39.2%   fifo  99%  buf  50%   71.6xD
xorriso : UPDATE : Writing:    2653968s   39.9%   fifo 100%  buf  50%   74.2xD
xorriso : UPDATE : Writing:    2724144s   41.0%   fifo 100%  buf  50%  103.5xD
xorriso : UPDATE : Writing:    2797696s   42.1%   fifo 100%  buf  50%  108.5xD
xorriso : UPDATE : Writing:    2857056s   43.0%   fifo 100%  buf  50%   87.5xD
xorriso : UPDATE : Writing:    2911536s   43.8%   fifo  99%  buf  50%   80.3xD
xorriso : UPDATE : Writing:    2986768s   44.9%   fifo  99%  buf  50%  111.0xD
xorriso : UPDATE : Writing:    3055936s   46.0%   fifo 100%  buf  50%  102.1xD
xorriso : UPDATE : Writing:    3112496s   46.8%   fifo  99%  buf  50%   83.4xD
xorriso : UPDATE : Writing:    3168784s   47.7%   fifo  99%  buf  50%   83.0xD
xorriso : UPDATE : Writing:    3248608s   48.9%   fifo 100%  buf  50%  117.9xD
xorriso : UPDATE : Writing:    3309200s   49.8%   fifo  99%  buf  50%   89.4xD
xorriso : UPDATE : Writing:    3370432s   50.7%   fifo  99%  buf  50%   90.3xD
xorriso : UPDATE : Writing:    3439088s   51.8%   fifo  99%  buf  50%  101.4xD
xorriso : UPDATE : Writing:    3527568s   53.1%   fifo 100%  buf  50%  129.6xD
xorriso : UPDATE : Writing:    3590416s   54.0%   fifo 100%  buf  50%   92.5xD
xorriso : UPDATE : Writing:    3651536s   54.9%   fifo 100%  buf  50%   90.1xD
xorriso : UPDATE : Writing:    3727376s   56.1%   fifo  99%  buf  50%  124.2xD
xorriso : UPDATE : Writing:    3812224s   57.4%   fifo 100%  buf  50%  125.3xD
xorriso : UPDATE : Writing:    3881024s   58.4%   fifo 100%  buf  50%  101.4xD
xorriso : UPDATE : Writing:    3949680s   59.4%   fifo 100%  buf  50%  101.3xD
xorriso : UPDATE : Writing:    4042000s   60.8%   fifo 100%  buf  50%  136.2xD
xorriso : UPDATE : Writing:    4116112s   61.9%   fifo  99%  buf  50%  109.2xD
xorriso : UPDATE : Writing:    4181552s   62.9%   fifo 100%  buf  50%   96.4xD
xorriso : UPDATE : Writing:    4250064s   64.0%   fifo  99%  buf  50%  100.6xD
xorriso : UPDATE : Writing:    4348048s   65.4%   fifo 100%  buf  50%  144.6xD
xorriso : UPDATE : Writing:    4411760s   66.4%   fifo 100%  buf  50%   93.7xD
xorriso : UPDATE : Writing:    4465712s   67.2%   fifo  99%  buf  50%   79.3xD
xorriso : UPDATE : Writing:    4531920s   68.2%   fifo  99%  buf  50%   97.4xD
xorriso : UPDATE : Writing:    4612704s   69.4%   fifo  99%  buf  50%  118.9xD
xorriso : UPDATE : Writing:    4679088s   70.4%   fifo  99%  buf  50%   97.9xD
xorriso : UPDATE : Writing:    4740432s   71.3%   fifo 100%  buf  50%   90.4xD
xorriso : UPDATE : Writing:    4817952s   72.5%   fifo 100%  buf  50%  114.3xD
xorriso : UPDATE : Writing:    4899920s   73.7%   fifo  99%  buf  50%  120.9xD
xorriso : UPDATE : Writing:    4957424s   74.6%   fifo 100%  buf  50%   84.6xD
xorriso : UPDATE : Writing:    5014352s   75.5%   fifo 100%  buf  50%   83.9xD
xorriso : UPDATE : Writing:    5092560s   76.6%   fifo  99%  buf  50%  115.1xD
xorriso : UPDATE : Writing:    5163280s   77.7%   fifo 100%  buf  50%  104.2xD
xorriso : UPDATE : Writing:    5221392s   78.6%   fifo  99%  buf  50%   85.8xD
xorriso : UPDATE : Writing:    5278096s   79.4%   fifo  99%  buf  50%   83.6xD
xorriso : UPDATE : Writing:    5362000s   80.7%   fifo  99%  buf  50%  123.3xD
xorriso : UPDATE : Writing:    5421664s   81.6%   fifo 100%  buf  50%   87.9xD
xorriso : UPDATE : Writing:    5478608s   82.4%   fifo 100%  buf  50%   83.7xD
xorriso : UPDATE : Writing:    5539600s   83.4%   fifo  99%  buf  50%   99.6xD
xorriso : UPDATE : Writing:    5615808s   84.5%   fifo 100%  buf  50%  112.1xD
xorriso : UPDATE : Writing:    5673088s   85.4%   fifo 100%  buf  50%   84.3xD
xorriso : UPDATE : Writing:    5729856s   86.2%   fifo 100%  buf  50%   83.6xD
xorriso : UPDATE : Writing:    5804144s   87.3%   fifo  99%  buf  50%  109.2xD
xorriso : UPDATE : Writing:    5881360s   88.5%   fifo 100%  buf  50%  113.1xD
xorriso : UPDATE : Writing:    5945312s   89.5%   fifo 100%  buf  50%   94.1xD
xorriso : UPDATE : Writing:    6012788s   90.5%   fifo  99%  buf  50%   99.2xD
xorriso : UPDATE : Writing:    6090352s   91.7%   fifo  99%  buf  50%  114.4xD
xorriso : UPDATE : Writing:    6170176s   92.9%   fifo  99%  buf  50%  117.7xD
xorriso : UPDATE : Writing:    6229296s   93.7%   fifo  99%  buf  50%   86.7xD
xorriso : UPDATE : Writing:    6293808s   94.7%   fifo  99%  buf  50%   95.0xD
xorriso : UPDATE : Writing:    6383216s   96.1%   fifo 100%  buf  50%  132.0xD
xorriso : UPDATE : Writing:    6452240s   97.1%   fifo  99%  buf  50%  101.8xD
xorriso : UPDATE : Writing:    6510896s   98.0%   fifo  99%  buf  50%   86.4xD
xorriso : UPDATE : Writing:    6579648s   99.0%   fifo 100%  buf  50%  101.4xD
ISO image produced: 6645054 sectors
Written to medium : 6645216 sectors at LBA 32
Writing to '/sw/rhel_9.7_uefi_custom.iso' completed successfully.

[root@lin1 ~]#

This step created a custom iso file (rhel_9.7_uefi_custom.iso) that can be used to perform the unattended installation. Remember this file needs to be created only once.

Unattended Installation of RHEL 9.7 on VirtualBox

Create the Virtual Machine and start the installation

Run these steps in a Windows command prompt to create the new VM and start the installation from the custom iso. You probably need to adjust the parameter –bridgeadapter1 to the name of your primary interface of the Windows host system (see the Output of this command: ipconfig /all|findstr /C:Description /C:IPv|findstr /V Virtual)

set "VHOST=" && set "MAC="
(set /p VHOST=Enter VM name ^(e.g. lin1^):
set /p MAC=Enter the MAC address of the VM if you would like to use a dedicated MAC address. Press Enter to let VirtualBox assign a random MAC: 
call vboxmanage createvm --name %VHOST% --ostype RedHat9_64 --register
call vboxmanage modifyvm %VHOST% --clipboard-mode=bidirectional --drag-and-drop=bidirectional --audio-controller=hda --audio-out=on
call vboxmanage modifyvm %VHOST% --memory=8192 --cpus=4 --vram=128 --graphicscontroller=vmsvga --usb-ehci=on --firmware efi
call vboxmanage setextradata %VHOST% GUI/ScaleFactor 2
call vboxmanage storagectl %VHOST% --name "IDE" --add ide
call vboxmanage storagectl %VHOST% --name "SATA" --add sata --bootable on
call vboxmanage createmedium disk --filename c:\vms\%VHOST%\%VHOST%_1.vdi --size 512000 --variant Standard
call vboxmanage storageattach %VHOST% --storagectl "SATA" --port 0 --device 0 --type hdd --medium c:\vms\%VHOST%\%VHOST%_1.vdi
call vboxmanage storageattach %VHOST% --storagectl "IDE" --port 0 --device 0 --type dvddrive --medium c:\sw\rhel_9.7_uefi_custom.iso
call vboxmanage storageattach %VHOST% --storagectl "IDE" --port 0 --device 1 --type dvddrive --medium "C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso"
call vboxmanage modifyvm %VHOST% --nic1 bridged --bridgeadapter1 "Intel(R) Ethernet Connection (2) I219-LM"
if defined MAC call vboxmanage modifyvm %VHOST% --mac-address1=%MAC% 
call vboxmanage sharedfolder add %VHOST% --name=sw --hostpath=c:\sw --automount --auto-mount-point=/sw
call vboxmanage showvminfo %VHOST%|findstr /C:"NIC 1"
call vboxmanage startvm %VHOST% --type=gui)

The second to last command shows the mac address that the VM will use. Add the IP/mac address to your local dns so that the new machine can retrieve the IP address you want to use for the VM.

Perform tasks after the unattended OS installation

The installation takes about 10 minutes. Now you are able to login to the system with the IP or hostname you specified in the DNS server (username: root password: changeme). If you would like to take advantage of the poor man’s RPM cache you could enable it now 🙂 Afterwards perform these steps:

# fix rcvboxadd
sed -i "/#test \! -f \"\$1\"/s/    #/    /" /sbin/rcvboxadd
bash -c "
# register the system with RedHat:
subscription-manager register
# install and update packages:
dnf -y update && dnf -y groupinstall 'Server with GUI' && dnf -y install libnsl bc binutils compat-openssl11 elfutils-libelf glibc glibc-devel ksh libaio libXrender libX11 libXau libXi libXtst  libgcc libnsl libstdc++ libxcb libibverbs make smartmontools sysstat libnsl2 net-tools nfs-utils libstdc++-devel libaio-devel iotop kernel-devel-$(uname -r) sshpass expect telnet
# setup VirtualBox Guest Additions (this is needed to make the clipboard work)
/sbin/rcvboxadd setup
# Recompile VirtualBox Guest Additions kernel modules:
/sbin/rcvboxadd quicksetup all
# add user1 to the vboxsf group
usermod -G vboxsf -a user1
# disable screen lock for user root
gsettings set org.gnome.desktop.session idle-delay 0
# enable boot in GUI mode
systemctl set-default graphical.target
# set the /etc/hosts entry to: <ip> <fqdn> <hostname>
echo \"$(host `hostname`|awk {'print $4"  "$1'})\" \"$(hostname|awk -F. {'print $1'})\" >> /etc/hosts
# adjust /etc/hostname
hostname > /etc/hostname
# disable the Gnome Welcome screen for all users
echo 'X-GNOME-Autostart-enabled=false' >> /etc/xdg/autostart/gnome-initial-setup-first-login.desktop
# disable the screen idle delay (disables the lock screen) for all gnome users
cat << EOF > /etc/dconf/db/local.d/01-session
# dconf path
[org/gnome/desktop/session]

# settings
idle-delay=uint32 0
EOF
dconf update
# disable the boot splash screen (plymouth)
grubby --update-kernel=ALL --remove-args=rhgb
# lower the grub timeout from 5 seconds to 2
sed -i s/GRUB_TIMEOUT=5/GRUB_TIMEOUT=2/g /etc/default/grub
# set the resolution to 1024x768x32
grubby --update-kernel=ALL --args vga=836
# generate a grub config file
grub2-mkconfig -o /boot/grub2/grub.cfg
init 6"

Your new RedHat Enterprise Linux 9.7 VM is now ready to use! Have fun.

Further info

Some useful Links:

Delete a Virtual Machine

To delete a VM follow these steps.

Updating VirtualBox Guest Additions

Follow these steps to update the Oracle VirtualBox Guest Additions

0