From 585fd33d40de9e359ffd3ab8e7b7777e832c2699 Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Fri, 6 Jun 2025 10:56:47 +0800 Subject: [PATCH] kdumpctl: check and generate /etc/vconsole.conf Resolves: https://issues.redhat.com/browse/RHEL-79413 Upstream: kdump-utils Conflict: Yes, upstream use has_command to check if a command is avaiable but that function is not backported to RHEL-9. commit f758448cc7f29a24d8f5ddd7418dc9dd2fc3fd35 Author: Lichen Liu Date: Thu May 8 17:22:17 2025 +0800 kdumpctl: check and generate /etc/vconsole.conf For VMs created from KVM Guest images, /etc/vconsole.conf is missing so that dracut module 10i18n will install all kbd files. ``` # du -sh initramfs/squash/usr/lib/kbd/* 438K initramfs/squash/usr/lib/kbd/consolefonts 340K initramfs/squash/usr/lib/kbd/consoletrans 2.1M initramfs/squash/usr/lib/kbd/keymaps 232K initramfs/squash/usr/lib/kbd/unimaps ``` From man 5 vconsole.conf, KEYMAP= defaults to "us" if not set. We can safely generate a /etc/vconsole.conf with KEYMAP=us by localectl to reduce the initramfs size. ``` # du -sh initramfs/squash/usr/lib/kbd/* 11K initramfs/squash/usr/lib/kbd/consolefonts 121K initramfs/squash/usr/lib/kbd/keymaps ``` Signed-off-by: Lichen Liu Signed-off-by: Lichen Liu --- kdumpctl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/kdumpctl b/kdumpctl index b52dea5..1bdbb07 100755 --- a/kdumpctl +++ b/kdumpctl @@ -143,6 +143,18 @@ rebuild_kdump_initrd() return 0 } +check_and_generate_vconsole_conf() +{ + if [[ ! -e /etc/vconsole.conf ]]; then + dwarn "/etc/vconsole.conf does not exist, trying to set keymap to us to reduce the initramfs size." + if [[ -x "$(command -v localectl)" ]] ; then + if localectl list-keymaps | grep -q "^us$"; then + localectl set-keymap us 2>/dev/null + fi + fi + fi +} + rebuild_initrd() { local _ret @@ -152,6 +164,8 @@ rebuild_initrd() return 1 fi + check_and_generate_vconsole_conf + if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then rebuild_fadump_initrd else