FS#40131 - [systemd] Duplicate machine-id

Attached to Project: Arch Linux
Opened by Ruben Kerkhof (ruben) - Monday, 28 April 2014, 18:10 GMT
Last edited by Dave Reisner (falconindy) - Wednesday, 20 August 2014, 22:35 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Dave Reisner (falconindy)
Tom Gundersen (tomegun)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:

When creating a container with pacstrap, as described in https://wiki.archlinux.org/index.php/Arch_systemd_container, the container contains /etc/machine-id which is the same as /etc/machine-id on the host on which pacstrap is run. This prevents me from using the journal merging feature.

This only happens on a KVM virtual machine.

A workaround is to remove /etc/machine-id in the container and let systemd generate a new one.
This doesn't currently work and just got fixed by upstream commit 984233ceb6dfeecd8b43864795a660a200e4ac78

Digging into this further, when pacstrap installs systemd, the systemd install script calls systemd-machine-id-setup (https://projects.archlinux.org/svntogit/packages.git/tree/trunk/systemd.install?h=packages/systemd&id=0768de1fb8007f267c567123ffa43ecfd86f1e05#n21)

IMHO this call should be dropped, so that systemd can do the right thing and create /etc/machine-id on first boot, be it in a container or in a vm.

Steps to reproduce:

Run pacman on a kvm virtual machine to create a container:
mkdir ~MyContainer
sudo pacstrap -i -c -d ~/MyContainer base
diff /etc/machine-id ~/MyContainer/etc/machine-id

Observe that both files are the same.

Kind regards,

Ruben
This task depends upon

Closed by  Dave Reisner (falconindy)
Wednesday, 20 August 2014, 22:35 GMT
Reason for closing:  Fixed
Additional comments about closing:  Now using systemd-firstboot instead of s-m-i-s in systemd-216-1
Comment by Dave Reisner (falconindy) - Monday, 28 April 2014, 18:23 GMT
> IMHO this call should be dropped, so that systemd can do the right thing and create /etc/machine-id on first boot, be it in a container or in a vm.
But systemd *won't* create this on first boot, so I don't understand why you're proposing this.
Comment by Ruben Kerkhof (ruben) - Monday, 28 April 2014, 18:44 GMT
Hi Dave,

Thanks for your fast response.

If I remove /etc/machine-id from my system, systemd certainly creates a new one.
Looking at the code, systemd calls machine_id_setup from main.c
See also this thread on systemd-devel: http://lists.freedesktop.org/archives/systemd-devel/2014-April/018934.html
Comment by Dave Reisner (falconindy) - Monday, 28 April 2014, 19:41 GMT
I read the thread before you filed the bug. I'm still not interested in this change. On bare metal or a VM, there's only a *chance* that this works properly because machine-id-setup runs when root might be read-only. In a setup where this is true, you'll get a varying machine-id on every boot -- not good. Another point of reference -- I'm not yet sure why, but I can boot a VM without an /etc/machine-id and it isn't generated. Lots of services fail as a result.

Seems to me like there's a number of bugs in this code that upstream needs to deal with before we should be getting involved on the distro level.
Comment by Ruben Kerkhof (ruben) - Tuesday, 29 April 2014, 16:56 GMT
You're right, I didn't consider the readonly case, and there are certainly a number of bugs in the upstream code.
So forget about my proposed solution, but the bug's still there.
What do you propose for case in which people use pacstrap to create a container? Document that they need to create /etc/machine-id themselves?

As for /etc/machine-id nog being regenerated, I can't reproduce what you're seeing (yet).
I just created a KVM virtual machine based on Arch 2014.04.1 (systemd-211), removed /etc/machine-id and after a reboot /etc/machine-id is there, with the uuid based on the KVM uuid.
Comment by Dave Reisner (falconindy) - Tuesday, 29 April 2014, 17:06 GMT
> What do you propose for case in which people use pacstrap to create a container?
I don't understand why this is a problem. systemd-machine-id-setup should be using the random generator to create the machine ID (as per the documentation). If this isn't the case, then talk to upstream.
Comment by Ruben Kerkhof (ruben) - Tuesday, 29 April 2014, 17:54 GMT
http://www.freedesktop.org/software/systemd/man/systemd-machine-id-setup.html describes that a random id is only generated
when not on kvm or in a container.

Comment by Dave Reisner (falconindy) - Tuesday, 29 April 2014, 17:57 GMT
The key sentence in the manpage seems to be this:

"If run inside a KVM virtual machine and a UUID is passed via the -uuid option, this UUID is used to initialize the machine ID instead of a randomly generated one. The caller must ensure that the UUID passed is sufficiently unique and is different for every booted instanced of the VM."

Emphasis on "and a UUID is passed via the --uuid option". You also seem to have pointed out to upstream that this particular feature isn't working.
Comment by Ruben Kerkhof (ruben) - Tuesday, 29 April 2014, 18:26 GMT
There's a difference between -uuid (one minus) and --uuid, you made a typo in the part you emphasized.
The -uuid option passed to qemu-kvm works just fine, it's the --uuid option passed to systemd-nspawn that doesn't work.
Comment by Dave Reisner (falconindy) - Saturday, 21 June 2014, 16:02 GMT
Is this still an issue with systemd 214?
Comment by Ruben Kerkhof (ruben) - Friday, 27 June 2014, 19:55 GMT
Just tested this with systemd 214-2, and unfortunately this is still an issue.

Loading...