How to Reset the Machine-ID of a Linux VM

PowerADM.com / Linux / How to Reset the Machine-ID of a Linux VM

When the Linux operating system is installed on a computer, a unique machine identifier is automatically generated and saved in the /etc/machine-id file. This is similar to the Computer Security Identifier (Machine SID) in Windows.

Linux host machine IDs must be unique on the network, as different software can be bound to these values. Typically, an administrator may encounter a problem with identical machine IDs when cloning a Linux virtual machine. When the cloned VM starts, it will receive the same IP address from the DHCP server as the source machine (even if the MAC address has been changed). Most DHCP servers issue IP addresses according to the dhcp clientId, which is generated by the systemd-networkd service based on the machine-id.

To find out the current Linux machine ID, run the command:

$ cat /etc/machine-id

linux - get current machne-id

Or use the command:

$ hostnamectl | grep "Machine ID"

To reset the machine-id on Linux and generate a new one, follow these steps.

Change the permissions on the /etc/machine-id file:

$ sudo chmod 644 /etc/machine-id

Remove old ID:

$ sudo rm /etc/machine-id

Generate a new ID:

$ dbus-uuidgen --ensure
$ sudo systemd-machine-id-setup

Initializing machine ID from D-Bus machine ID.

generate new machine-id on linux

Restore the original file permissions:

$ sudo chmod 444 /etc/machine-id

Check the new machine ID value:

$ hostnamectl | grep "Machine ID"
Leave a Reply

Your email address will not be published. Required fields are marked *