This is an old revision of the document!


Unique machine ID for nfs root systems

When multiple hosts running systemd share the same NFS root, they will also share the same machine-id. This can cause issues, especially with journald. Journald logging can be disabled by deleting /var/log/journal which solves most of the problems, but a better solution is to use unique machine-id values on all of the hosts. Modern motherboards provide a unique UUID accessible via DMI, so a reasonable option is to write this out to /run during boot and point systemd at that as the machine-id. Here is a simple way to set that up.

Create the file /etc/initramfs-tools/scripts/init-top/machineid:

machineid
#!/bin/sh -e
 
PREREQS=""
 
prereqs() { echo "$PREREQS"; }
 
case "$1" in
    prereqs)
    prereqs
    exit 0
    ;;
esac
 
# write sanitized motherboard UUID to /run/machine-id
sed 's/-//g' /sys/class/dmi/id/product_uuid > /run/machine-id
 
# requires the following symbolic links:
# ln -sf /run/machine-id /etc/machine-id
# ln -sf /run/machine-id /var/lib/dbus/machine-id

Rebuild the initramfs (for example update-initramfs -c -k 4.15.0-99-generic) and replace /etc/machine-id and /var/lib/dbus/machine-id with symlinks to /run/machine-id.