Careful when cloning: Editing machine IDs for fun and profit

{{< figure align=alignright width=225 src=”/wp-content/uploads/2022/12/jzb%5Frobot%5Fshowing%5FID%5Fhumanoid%5Frobot%5Fdisplaying%5Fan%5FID%5Fcard%5F964de368-bb5f-4aa8-aabe-2dfeebc06061-150x150.png?crop=1” alt=”” >}}

Today I was setting up some VMs on Fedora in Cockpit and decided to clone an Ubuntu 20.04 LTS image, which immediately pulled the same IP as the original. I hadn’t had that issue with CentOS or Debian, not quite sure why, but the culprit is a duplicate machine ID. Here’s how to fix that.

You’ll want to delete two files, /etc/machine-id and /var/lib/dbus/machine-id. (You’ll need to use sudo or be root, of course.) Then run systemd-machine-id-setup. Hat tip to this StackExchange answer for tipping me to the D-Bus copy of the ID…

For good measure I just rebooted the virtual machine after that and made a note that I want to zap the machine ID anytime I clone a VM in the future.

The nice thing was that Cockpit’s console feature let me hop into the machines via the web interface. I didn’t lose access just because I couldn’t shell into the VM that lost the contest for the same IP address.

Related post