2023-03-22 22:59:52 +00:00
|
|
|
# fedora-server-vm-full.ks (rel. 1.02)
|
2022-08-10 14:30:04 +00:00
|
|
|
# Kickstart file to build a Fedora Server Edition VM disk image.
|
|
|
|
# The image aims to resemble as close as technically possible the
|
|
|
|
# full features of a Fedora Server Edition in a virtual machine.
|
|
|
|
#
|
2022-09-14 22:31:30 +00:00
|
|
|
# The image uses GPT partition type as of default in Fedora 37.
|
2022-08-22 15:05:47 +00:00
|
|
|
#
|
2022-09-14 22:31:30 +00:00
|
|
|
# At first boot it opens a text mode basic configuration screen.
|
2022-08-10 14:30:04 +00:00
|
|
|
#
|
|
|
|
# This kickstart file is designed to be used with ImageFactory (in Koji).
|
|
|
|
#
|
|
|
|
# To build the image locally, you need to install ImageFactory and
|
|
|
|
# various additional helpers and configuration files.
|
|
|
|
# See Fedora Server Edition user documentation tutorial.
|
|
|
|
|
2022-08-22 15:05:47 +00:00
|
|
|
# Use text mode install
|
|
|
|
text
|
|
|
|
|
2022-08-10 14:30:04 +00:00
|
|
|
# Keyboard layouts
|
|
|
|
keyboard 'us'
|
|
|
|
|
2022-08-22 15:05:47 +00:00
|
|
|
# System language
|
|
|
|
lang en_US.UTF-8
|
|
|
|
|
|
|
|
# System timezone
|
|
|
|
# set time zone to GMT (Etcetera/UTC)
|
|
|
|
timezone Etc/UTC --utc
|
|
|
|
|
|
|
|
|
2022-08-10 14:30:04 +00:00
|
|
|
# Root password
|
|
|
|
rootpw --iscrypted --lock locked
|
|
|
|
|
2022-08-22 15:05:47 +00:00
|
|
|
# SELinux configuration
|
|
|
|
selinux --enforcing
|
2022-08-10 14:30:04 +00:00
|
|
|
|
|
|
|
|
2022-08-22 15:05:47 +00:00
|
|
|
# System bootloader configuration
|
|
|
|
bootloader --location=mbr --timeout=1 --append="console=tty1 console=ttyS0,115200n8"
|
2022-08-10 14:30:04 +00:00
|
|
|
|
|
|
|
# Network information
|
|
|
|
network --bootproto=dhcp --device=link --activate --onboot=on
|
|
|
|
|
|
|
|
# Firewall configuration
|
|
|
|
firewall --enabled --service=mdns
|
|
|
|
|
2022-08-22 15:05:47 +00:00
|
|
|
|
|
|
|
# System services
|
|
|
|
services --enabled="sshd,NetworkManager,chronyd,initial-setup"
|
2022-08-10 14:30:04 +00:00
|
|
|
|
|
|
|
# Run the Setup Agent on first boot
|
|
|
|
firstboot --reconfig
|
|
|
|
|
2022-08-22 15:05:47 +00:00
|
|
|
# Partition Information. Use GPT by default (since Fedora 37)
|
|
|
|
# Resemble the Partitioning used for Fedora Server Install media
|
|
|
|
clearpart --all --initlabel --disklabel=gpt
|
2022-09-08 12:18:19 +00:00
|
|
|
reqpart --add-boot
|
2022-08-22 15:05:47 +00:00
|
|
|
part pv.007 --size=4000 --grow
|
|
|
|
volgroup sysvg pv.007
|
|
|
|
logvol / --vgname=sysvg --size=4000 --grow --maxsize=16000 --fstype=xfs --name=root --label=sysroot
|
2022-08-10 14:30:04 +00:00
|
|
|
|
|
|
|
|
2022-09-14 22:31:30 +00:00
|
|
|
# Include URLs for network installation dynamically, dependent on Fedora release
|
2022-08-22 15:05:47 +00:00
|
|
|
# and imagefactory runtime environment
|
|
|
|
%include fedora-repo.ks
|
|
|
|
|
|
|
|
# Shutdown after installation
|
|
|
|
shutdown
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##### begin package list #############################################
|
|
|
|
%packages --inst-langs=en
|
|
|
|
|
|
|
|
@server-product
|
|
|
|
@core
|
|
|
|
@headless-management
|
|
|
|
@standard
|
|
|
|
@networkmanager-submodules
|
2022-09-14 22:31:30 +00:00
|
|
|
# container management is an optional install item on disk media.
|
|
|
|
# Install options not available with VMs. So we don't include it
|
|
|
|
# despite trying to resemble a DVD installation as close as possible.
|
2022-08-22 15:05:47 +00:00
|
|
|
##@container-management
|
|
|
|
@domain-client
|
|
|
|
@guest-agents
|
|
|
|
|
|
|
|
# All arm-tools packages install on aarch64/armhfp only
|
|
|
|
# TODO: on a x86_64 devel environment are @arm-tools not available
|
|
|
|
# and cause a build error.
|
|
|
|
# @arm-tools
|
|
|
|
|
|
|
|
# Standard Fedora Package Groups
|
|
|
|
## dracut-config-generic ## included in =core=
|
|
|
|
glibc-all-langpacks
|
|
|
|
initial-setup
|
|
|
|
kernel-core
|
|
|
|
-dracut-config-rescue
|
|
|
|
-generic-release*
|
|
|
|
-initial-setup-gui
|
|
|
|
-kernel
|
|
|
|
-linux-firmware
|
|
|
|
-plymouth
|
|
|
|
# pulled in by @standard
|
|
|
|
-smartmontools
|
|
|
|
-smartmontools-selinux
|
|
|
|
|
|
|
|
%end
|
|
|
|
##### end package list ###############################################
|
2022-08-10 14:30:04 +00:00
|
|
|
|
|
|
|
|
2022-08-22 15:05:47 +00:00
|
|
|
##### begin kickstart post script ####################################
|
|
|
|
%post --erroronfail --log=/root/anaconda-post-1.log
|
2022-08-10 14:30:04 +00:00
|
|
|
|
|
|
|
# Find the architecture we are on
|
|
|
|
arch=$(uname -m)
|
|
|
|
|
|
|
|
# Import RPM GPG key, during installation saved in /etc/pki
|
|
|
|
echo "Import RPM GPG key"
|
|
|
|
releasever=$(rpm --eval '%{fedora}')
|
|
|
|
basearch=$(uname -i)
|
|
|
|
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
|
|
|
|
|
|
|
|
# See the systemd-random-seed.service man page that says:
|
|
|
|
# " It is recommended to remove the random seed from OS images intended
|
|
|
|
# for replication on multiple systems"
|
|
|
|
# The newly installed instance should make it's own
|
|
|
|
echo "Removing random-seed so it's not the same in every image."
|
|
|
|
rm -f /var/lib/systemd/random-seed
|
|
|
|
|
|
|
|
# When we build the image a networking config file gets left behind.
|
|
|
|
# Let's clean it up.
|
|
|
|
echo "Cleanup leftover networking configuration"
|
|
|
|
rm -f /etc/NetworkManager/system-connections/*.nmconnection
|
|
|
|
|
|
|
|
# Truncate the /etc/resolv.conf left over from NetworkManager during the
|
2022-08-22 15:05:47 +00:00
|
|
|
# kickstart because the DNS server is environment specific.
|
2022-08-10 14:30:04 +00:00
|
|
|
truncate -s 0 /etc/resolv.conf
|
|
|
|
|
2022-08-22 15:05:47 +00:00
|
|
|
echo "Cleaning repodata to save space."
|
|
|
|
dnf clean all
|
|
|
|
|
2022-08-10 14:30:04 +00:00
|
|
|
# linux-firmware is installed by default and is quite large. As of mid 2020:
|
|
|
|
# Total download size: 97 M
|
|
|
|
# Installed size: 268 M
|
2022-08-22 15:05:47 +00:00
|
|
|
# Not needed in virtual environment.
|
2022-08-10 14:30:04 +00:00
|
|
|
echo "Removing linux-firmware package."
|
|
|
|
rpm -e linux-firmware
|
|
|
|
|
2022-08-23 17:04:39 +00:00
|
|
|
# Will ever anybody see this?
|
2022-08-10 14:30:04 +00:00
|
|
|
echo "Packages within this disk image"
|
|
|
|
rpm -qa --qf '%{size}\t%{name}-%{version}-%{release}.%{arch}\n' |sort -rn
|
|
|
|
|
|
|
|
# Note that running rpm recreates the rpm db files which aren't needed or wanted
|
|
|
|
rm -f /var/lib/rpm/__db*
|
|
|
|
|
|
|
|
|
2022-08-23 17:04:39 +00:00
|
|
|
# Do we need a serial terminal with a VM?
|
2022-08-10 14:30:04 +00:00
|
|
|
if [[ $arch == "aarch64" ]] || [[ $arch == "armv7l" ]]; then
|
2022-08-22 15:05:47 +00:00
|
|
|
# Anaconda adds console=tty0 to the grub boot line on all images. this is problematic
|
|
|
|
# when you are using fedora via serial console as you do not get any output post grub
|
|
|
|
# linux does a good job of knowing what consoles need to be enabled.
|
|
|
|
# https://bugzilla.redhat.com/show_bug.cgi?id=2022757
|
|
|
|
sed -i -e 's|console=tty0||g' /boot/loader/entries/*conf
|
|
|
|
fi
|
2022-08-10 14:30:04 +00:00
|
|
|
|
2024-08-14 17:12:52 +00:00
|
|
|
# Trigger lvm-devices-import.path and .service to create
|
|
|
|
# a new /etc/lvm/devices/system.devices for the root VG.
|
|
|
|
rm -f /etc/lvm/devices/system.devices
|
|
|
|
touch /etc/lvm/devices/auto-import-rootvg
|
2022-08-10 14:30:04 +00:00
|
|
|
|
2022-08-22 15:05:47 +00:00
|
|
|
# Remove machine-id on pre generated images
|
|
|
|
rm -f /etc/machine-id
|
|
|
|
touch /etc/machine-id
|
2022-08-10 14:30:04 +00:00
|
|
|
|
2022-08-22 15:05:47 +00:00
|
|
|
%end
|
|
|
|
##### end kickstart post script #####################################
|
2022-08-10 14:30:04 +00:00
|
|
|
|
2022-08-22 15:05:47 +00:00
|
|
|
|
|
|
|
##### begin custom post script (after base) #########################
|
|
|
|
%post
|
2022-08-10 14:30:04 +00:00
|
|
|
|
2023-03-22 22:59:52 +00:00
|
|
|
# When we build the image /var/log gets populated.
|
|
|
|
# Let's clean it up.
|
|
|
|
echo "Cleanup leftover in /var/log"
|
|
|
|
cd /var/log && find . -name \* -type f -delete
|
|
|
|
|
2022-08-10 14:30:04 +00:00
|
|
|
echo "Zeroing out empty space."
|
|
|
|
# Create zeros file with nodatacow and no compression
|
|
|
|
touch /var/tmp/zeros
|
|
|
|
chattr +C /var/tmp/zeros
|
|
|
|
# This forces the filesystem to reclaim space from deleted files
|
|
|
|
dd bs=1M if=/dev/zero of=/var/tmp/zeros || :
|
|
|
|
echo "(Don't worry -- that out-of-space error was expected.)"
|
|
|
|
# Force sync to disk
|
|
|
|
sync /
|
|
|
|
rm -f /var/tmp/zeros
|
|
|
|
sync /
|
|
|
|
|
|
|
|
# setup systemd to boot to the right runlevel
|
|
|
|
echo -n "Setting default runlevel to multiuser text mode"
|
2023-11-20 03:26:23 +00:00
|
|
|
systemctl set-default multi-user.target
|
2022-08-10 14:30:04 +00:00
|
|
|
echo .
|
|
|
|
|
|
|
|
%end
|
2022-08-22 15:05:47 +00:00
|
|
|
##### end custom post script ########################################
|