From 97fe09769d6a86492c39e0368f088f54f7c0fa6e Mon Sep 17 00:00:00 2001 From: Antonio Alvarez Feijoo Date: Tue, 7 Mar 2023 16:17:16 +0100 Subject: [PATCH] fix(dracut.sh): handle /etc/machine-id empty or uninitialized Handle the case where the user tries to generate the initrd after explicitly resetting the /etc/machine-id file. Fixes issue #2267 --- dracut.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dracut.sh b/dracut.sh index 1f6f0aee80..7178ac5e39 100755 --- a/dracut.sh +++ b/dracut.sh @@ -1087,8 +1087,9 @@ if ! [[ $outfile ]]; then || [[ -d "$dracutsysrootdir"/boot/Default ]] \ || [[ -d "$dracutsysrootdir"/boot/efi/Default ]]; then MACHINE_ID="Default" - elif [[ -f "$dracutsysrootdir"/etc/machine-id ]]; then + elif [[ -s "$dracutsysrootdir"/etc/machine-id ]]; then read -r MACHINE_ID < "$dracutsysrootdir"/etc/machine-id + [[ $MACHINE_ID == "uninitialized" ]] && MACHINE_ID="Default" else MACHINE_ID="Default" fi