diff --git a/man/kernel-install.xml b/man/kernel-install.xml
index 88208250e8..f278c2f557 100644
--- a/man/kernel-install.xml
+++ b/man/kernel-install.xml
@@ -161,8 +161,12 @@
Environment variables
+
If is used, $KERNEL_INSTALL_VERBOSE=1 will be set for
the plugins. They may output additional logs in this case.
+
+ If MACHINE_ID= is set and not empty, it will be used as MACHINE-ID,
+ overriding any automatic detection attempts. The value must be a valid machine ID (32 hexadecimal characters).
@@ -214,9 +218,9 @@
The content of this file specifies the machine identification
- MACHINE-ID. If $BOOT/Default exists,
- or /etc/machine-id doesn't, kernel-install
- will use the literal Default as the machine ID instead.
+ MACHINE-ID. If /etc/machine-id
+ cannot be read or is temporary (backed by a file on tmpfs),
+ kernel-install will use Default instead.
diff --git a/src/kernel-install/kernel-install b/src/kernel-install/kernel-install
index c9a80b2e3d..89f0074417 100755
--- a/src/kernel-install/kernel-install
+++ b/src/kernel-install/kernel-install
@@ -85,20 +85,14 @@ fi
KERNEL_VERSION="$1"
KERNEL_IMAGE="$2"
-# Reuse directory created without a machine ID present if it exists.
-if [[ -d /efi/Default ]] || [[ -d /boot/Default ]] || [[ -d /boot/efi/Default ]]; then
- MACHINE_ID="Default"
-elif [[ -f /etc/machine-id ]]; then
- read MACHINE_ID < /etc/machine-id
-else
- MACHINE_ID="Default"
-fi
-
if [[ ! $COMMAND ]] || [[ ! $KERNEL_VERSION ]]; then
echo "Not enough arguments" >&2
exit 1
fi
+[ -z "$MACHINE_ID" ] && [ -f /etc/machine-id ] && [ "$(stat -fc %T /etc/machine-id)" != "tmpfs" ] && read -r MACHINE_ID < /etc/machine-id
+[ -z "$MACHINE_ID" ] && MACHINE_ID="Default"
+
if [[ -d /efi/loader/entries ]] || [[ -d /efi/$MACHINE_ID ]]; then
ENTRY_DIR_ABS="/efi/$MACHINE_ID/$KERNEL_VERSION"
elif [[ -d /boot/loader/entries ]] || [[ -d /boot/$MACHINE_ID ]]; then
@@ -113,7 +107,7 @@ else
ENTRY_DIR_ABS="/boot/$MACHINE_ID/$KERNEL_VERSION"
fi
-export KERNEL_INSTALL_MACHINE_ID=$MACHINE_ID
+export KERNEL_INSTALL_MACHINE_ID="$MACHINE_ID"
ret=0