[vbox-dev] [PATCH] add redhat8_ks.cfg kickstart

Timothy Tacker timothytacker+virtualbox at gmail.com
Tue Jul 21 12:49:04 GMT 2020

Due to changes in RHEL 8, the redhat67_ks.cfg Kickstart script included in
the UnattendedTemplates directory does not work with CentOS 8. The patch
below adds a Kickstart script for RHEL 8 and CentOS 8, and makes other
changes to integrate the new script into VirtualBox. Following the pattern
for redhat67_ks.cfg, the new script is named redhat8_ks.cfg. All comments
in the new script are worded to mirror language and terms used in the RHEL
8 documentation; and all sections, commands, and options appear in the same
order in both the new script and the documentation.

The install command has been deprecated in RHEL 8. In regard to the install
command, the documentation states, "Use its methods as separate commands."
The cdrom command was retained and now serves to specify that installation
should occur from the first optical drive. The install command was removed
from the new script.

The auth command has been deprecated in RHEL 8. Passwords are shadowed by
default with sha512. The following auth command was removed from the new
auth  --useshadow  --passalgo=sha512

The default SELinux policy is enforcing. The following selinux command was
removed from the new script:
selinux --enforcing

The documentation states, "Either the --vckeymap= or the --xlayouts= option
must be used" for the required keyboard command, suggesting an OR rather
than an AND. Nonetheless, both --vckeymap=us and --xlayouts='us' are used
in the new script. Many examples of this usage can be found, and it does
not appear to cause issues. The value "us" was specified to maintain
consistency with the value that was specified in the redhat67_ks.cfg script.

In order to comply with the order demonstrated in the syntax shown in the
documentation, the timezone command was changed as follows:

For the --plaintext option to the user command, the documentation states,
"If this option is present, the password argument is assumed to be in plain
text"; but it does not explicitly indicate plaintext is the default. The
--plaintext option was added to the user command as follows:
--password=@@VBOX_INSERT_USER_PASSWORD_SH@@ --plaintext

For the network command, DHCP is the bootproto method used by default. In
addition, due to a change in how network devices are named in RHEL 8, eth0
is not a valid device name by default; but the link keyword can be used to
specify the first interface with its link in the up state. The network
command was changed as follows:
network  --bootproto=dhcp --device=eth0 --onboot=on
network --device=link --onboot=on --hostname=@@VBOX_INSERT_HOSTNAME_FQDN_SH@

For the bootloader command, mbr is the default value for the location
option. The bootloader command was changed as follows:
bootloader --location=mbr --append="nomodeset crashkernel=auto rhgb quiet"
bootloader --append="nomodeset crashkernel=auto rhgb quiet"

The autopart command automatically creates partitions in accordance with
Red Hat recommendations. The value plain for the type option specifies
"Regular partitions with no LVM." The following two part commands were
changed to the single autopart command on the third line immediately below:
part / --fstype ext4 --size 6000 --grow --asprimary
part swap --size 1024
autopart --type=plain

Without the elfutils-libelf-devel package installed, post install scripting
failed to compile kernel modules for VirtualBox Guest Additions, resulting
in their failure to install. The elfutils-libelf-devel package was added to
the %packages section in order to resolve this issue.

Only the new Kickstart script has been tested, and it has only been tested
with CentOS 8. OS and Guest Additions both install. Full testing with RHEL
8 should be completed prior to integration.

I'm licensing this patch under the MIT license. Please review. Feedback is
welcome. Thanks!

Timothy Tacker

 src/VBox/Installer/Config.kmk                 |   1 +
 .../Main/UnattendedTemplates/Makefile.kmk     |   1 +
 .../Main/UnattendedTemplates/redhat8_ks.cfg   | 116 ++++++++++++++++++
 src/VBox/Main/include/UnattendedInstaller.h   |  11 ++
 4 files changed, 129 insertions(+)
 create mode 100644 src/VBox/Main/UnattendedTemplates/redhat8_ks.cfg

diff --git a/src/VBox/Installer/Config.kmk b/src/VBox/Installer/Config.kmk
index 077d6af6..0cbcfe8d 100644
--- a/src/VBox/Installer/Config.kmk
+++ b/src/VBox/Installer/Config.kmk
@@ -66,6 +66,7 @@ ifdef VBOX_WITH_UNATTENDED
  rhel4_ks.cfg \
  rhel5_ks.cfg \
  redhat67_ks.cfg \
+ redhat8_ks.cfg \
  win_nt5_unattended.sif \
  win_nt6_unattended.xml \
diff --git a/src/VBox/Main/UnattendedTemplates/Makefile.kmk
index c8baeaf5..cd15ffb4 100644
--- a/src/VBox/Main/UnattendedTemplates/Makefile.kmk
+++ b/src/VBox/Main/UnattendedTemplates/Makefile.kmk
@@ -32,6 +32,7 @@ ifdef VBOX_WITH_UNATTENDED
  rhel4_ks.cfg \
  rhel5_ks.cfg \
  redhat67_ks.cfg \
+ redhat8_ks.cfg \
  ol_ks.cfg \
  fedora_ks.cfg \
  suse_autoinstall.xml \
diff --git a/src/VBox/Main/UnattendedTemplates/redhat8_ks.cfg
new file mode 100644
index 00000000..d37f8baa
--- /dev/null
+++ b/src/VBox/Main/UnattendedTemplates/redhat8_ks.cfg
@@ -0,0 +1,116 @@
+#platform=x86, AMD64, or Intel EM64T
+## Installation program configuration and flow control commands:
+# Install from first optical drive.
+# Specify info as minimum log level on tty3 in Anaconda during
+logging --level=info
+# Attempt to eject bootable media and reboot after installation.
+reboot --eject
+# Perform installation in text mode.
+## System configuration commands:
+# Do not configure iptables rules.
+firewall --disabled
+# Set available keyboard layouts for system.
+keyboard --vckeymap=us --xlayouts='us'
+# Set language to use during installation and default to use on installed
+# Set system root password using supplied plaintext.
+rootpw --plaintext @@VBOX_INSERT_ROOT_PASSWORD_SH@@
+# Set system time zone and indicate if hardware clock is UTC (Greenwich
Mean) time.
+# Create new user on system and set password using supplied plaintext.
+user --name=@@VBOX_INSERT_USER_LOGIN_SH@@
--password=@@VBOX_INSERT_USER_PASSWORD_SH@@ --plaintext
+## Network configuration commands:
+# Configure network device and activate in Anaconda installation
+#  Device specified in first network command activated automatically.
+#  DHCP method used by default.
+#  Device: Link keyword specifies first interface with link in up state.
+#  Onboot: Enable device at boot time.
+#  Hostname: Specify host name for installed system.
+network --device=link --onboot=on
+## Storage handling commands:
+# Specifify how boot loader installed.
+#  Location boot record written dependent on drive usage of MBR or GPT
+#  Append: Specifies additional kernel parameters.
+bootloader --append="nomodeset crashkernel=auto rhgb quiet"
+# Remove partitions from system prior to creation of new partitions.
+#  All: Erase all partitions on disks reachable by installation program,
including attached network storage.
+#  Initlabel: Initialize disk(s) by creating default labels in respective
architectures designated for formatting.
+clearpart --all --initlabel
+# Automatically create partitions.
+#  Type: Plain keyword specifies regular partitioning scheme with no LVM.
+#  Default file system is xfs.
+autopart --type=plain
+# Initialize invalid partition tables and destroy contents of disks with
invalid partition tables.
+# Packages.  We currently ignore missing packages/groups here to keep
things simpler.
+%packages --ignoremissing
+ at base
+ at core
+ at development
+ at basic-desktop
+ at desktop-debugging
+ at desktop-platform
+ at fonts
+ at general-desktop
+ at graphical-admin-tools
+ at remote-desktop-clients
+ at x11
+# Prepare building the additions kernel module, try get what we can from
the cdrom as it may be impossible
+# to install anything from the post script:
+# Post install happens in a different script.
+# Note! We mount the CDROM explictily here since the location differs
between fedora 26 to rhel5
+#       and apparently there isn't any way to be certain that anaconda
didn't unmount it already.
+%post --nochroot --log=/mnt/sysimage/root/ks-post.log
+df -h
+mkdir -p /tmp/vboxcdrom
+mount /dev/cdrom /tmp/vboxcdrom
+cp /tmp/vboxcdrom/vboxpostinstall.sh /mnt/sysimage/root/vboxpostinstall.sh
+chmod a+x /mnt/sysimage/root/vboxpostinstall.sh
+/bin/bash /mnt/sysimage/root/vboxpostinstall.sh --rhel
+umount /tmp/vboxcdrom
diff --git a/src/VBox/Main/include/UnattendedInstaller.h
index 5003613d..09988815 100644
--- a/src/VBox/Main/include/UnattendedInstaller.h
+++ b/src/VBox/Main/include/UnattendedInstaller.h
@@ -518,6 +518,17 @@ protected:

+ * RHEL 8 installer (same as RHEL 6 & 7, except for the kickstart
+ */
+class UnattendedRhel5Installer : public UnattendedRhel6And7Installer
+    UnattendedRhel5Installer(Unattended *pParent) :
UnattendedRhel6And7Installer(pParent, "redhat8_ks.cfg") {}
+    ~UnattendedRhel5Installer() {}
  * RHEL 5 installer (same as RHEL 6 & 7, except for the kickstart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.virtualbox.org/pipermail/vbox-dev/attachments/20200721/edab2985/attachment.html>

More information about the vbox-dev mailing list