Richard W.M. Jones
2016-Mar-29 11:14 UTC
[Libguestfs] [PATCH] appliance: Copy /etc/machine-id from host system into the appliance.
Currently when the appliance is booted we see warning messages like these ones: [/usr/lib/tmpfiles.d/systemd.conf:26] Failed to replace specifiers: /run/log/journal/%m [/usr/lib/tmpfiles.d/systemd.conf:28] Failed to replace specifiers: /run/log/journal/%m [/usr/lib/tmpfiles.d/systemd.conf:29] Failed to replace specifiers: /run/log/journal/%m They are apparently harmless, but are caused because /etc/machine-id does not exist inside the appliance, and so %m cannot be substituted by systemd-tmpfiles. The solution to this is to provide /etc/machine-id. However this is not so simple: either we could get supermin to generate this, requiring an ugly systemd-specific hack to supermin, or we could generate it in the /init script, which just slows the init script down for no real reason. Since the content of /etc/machine-id doesn't really matter for a throwaway appliance so long as it has the right format, this commit copies the host file into the appliance. --- appliance/hostfiles.in | 1 + 1 file changed, 1 insertion(+) diff --git a/appliance/hostfiles.in b/appliance/hostfiles.in index 8ff53b5..6c581bd 100644 --- a/appliance/hostfiles.in +++ b/appliance/hostfiles.in @@ -13,5 +13,6 @@ dnl SUSE=1 For OpenSUSE. dnl FRUGALWARE=1 For Frugalware. dnl MAGEIA=1 For Mageia. +/etc/machine-id /lib/lsb/* /usr/share/augeas/lenses/*.aug -- 2.7.4
Fabian Deutsch
2016-Mar-29 11:16 UTC
Re: [Libguestfs] [PATCH] appliance: Copy /etc/machine-id from host system into the appliance.
systemd will generate a new machine-id if /etc/machine-id is empty, that's how anaconda does it, maybe it's also an option for guestfish. - fabian On Tue, Mar 29, 2016 at 1:14 PM, Richard W.M. Jones <rjones@redhat.com> wrote:> Currently when the appliance is booted we see warning messages like > these ones: > > [/usr/lib/tmpfiles.d/systemd.conf:26] Failed to replace specifiers: /run/log/journal/%m > [/usr/lib/tmpfiles.d/systemd.conf:28] Failed to replace specifiers: /run/log/journal/%m > [/usr/lib/tmpfiles.d/systemd.conf:29] Failed to replace specifiers: /run/log/journal/%m > > They are apparently harmless, but are caused because /etc/machine-id > does not exist inside the appliance, and so %m cannot be substituted > by systemd-tmpfiles. > > The solution to this is to provide /etc/machine-id. However this is > not so simple: either we could get supermin to generate this, > requiring an ugly systemd-specific hack to supermin, or we could > generate it in the /init script, which just slows the init script down > for no real reason. > > Since the content of /etc/machine-id doesn't really matter for a > throwaway appliance so long as it has the right format, this commit > copies the host file into the appliance. > --- > appliance/hostfiles.in | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/appliance/hostfiles.in b/appliance/hostfiles.in > index 8ff53b5..6c581bd 100644 > --- a/appliance/hostfiles.in > +++ b/appliance/hostfiles.in > @@ -13,5 +13,6 @@ dnl SUSE=1 For OpenSUSE. > dnl FRUGALWARE=1 For Frugalware. > dnl MAGEIA=1 For Mageia. > > +/etc/machine-id > /lib/lsb/* > /usr/share/augeas/lenses/*.aug > -- > 2.7.4 > > _______________________________________________ > Libguestfs mailing list > Libguestfs@redhat.com > https://www.redhat.com/mailman/listinfo/libguestfs-- Fabian Deutsch <fdeutsch@redhat.com> RHEV Hypervisor Red Hat
Richard W.M. Jones
2016-Mar-29 11:49 UTC
Re: [Libguestfs] [PATCH] appliance: Copy /etc/machine-id from host system into the appliance.
On Tue, Mar 29, 2016 at 01:16:34PM +0200, Fabian Deutsch wrote:> systemd will generate a new machine-id if /etc/machine-id is empty, > that's how anaconda does it, maybe it's also an option for guestfish.If we were running systemd, then I'm sure it would :-) I'm not opposed in some way to running systemd in the appliance, but it would have to have only benefits. We're only running one daemon. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html
Pino Toscano
2016-Mar-29 13:14 UTC
Re: [Libguestfs] [PATCH] appliance: Copy /etc/machine-id from host system into the appliance.
On Tuesday 29 March 2016 12:14:21 Richard W.M. Jones wrote:> Currently when the appliance is booted we see warning messages like > these ones: > > [/usr/lib/tmpfiles.d/systemd.conf:26] Failed to replace specifiers: /run/log/journal/%m > [/usr/lib/tmpfiles.d/systemd.conf:28] Failed to replace specifiers: /run/log/journal/%m > [/usr/lib/tmpfiles.d/systemd.conf:29] Failed to replace specifiers: /run/log/journal/%m > > They are apparently harmless, but are caused because /etc/machine-id > does not exist inside the appliance, and so %m cannot be substituted > by systemd-tmpfiles. > > The solution to this is to provide /etc/machine-id. However this is > not so simple: either we could get supermin to generate this, > requiring an ugly systemd-specific hack to supermin, or we could > generate it in the /init script, which just slows the init script down > for no real reason. > > Since the content of /etc/machine-id doesn't really matter for a > throwaway appliance so long as it has the right format, this commit > copies the host file into the appliance. > ---I had a prototype since some months of the solution about generating it in /init: diff --git a/appliance/init b/appliance/init index 28054ab..20c8d24 100755 --- a/appliance/init +++ b/appliance/init @@ -85,6 +85,9 @@ fi mkdir -p /run/tmpfiles.d kmod static-nodes --format=tmpfiles --output=/run/tmpfiles.d/kmod.conf +# Create a machine-id with a random UUID +dd if=/dev/urandom bs=1 count=16 status=none | od -x -A n | sed -e 's, ,,g' > /etc/machine-id + # Set up tmpfiles (must run after kmod.conf is created above). systemd-tmpfiles --prefix=/dev --create --boot Considering that, since a week or so, virtio-rng is used for the /dev/urandom of the appliance, reading 16 bytes should not cause to wait for randomness. -- Pino Toscano
Richard W.M. Jones
2016-Mar-29 15:50 UTC
Re: [Libguestfs] [PATCH] appliance: Copy /etc/machine-id from host system into the appliance.
On Tue, Mar 29, 2016 at 03:14:15PM +0200, Pino Toscano wrote:> +# Create a machine-id with a random UUID > +dd if=/dev/urandom bs=1 count=16 status=none | od -x -A n | sed -e 's, ,,g' > /etc/machine-idOut of interest, why read single bytes, and not the whole 16 bytes in one go? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
Apparently Analagous Threads
- [PATCH] appliance: Copy /etc/machine-id from host system into the appliance.
- Re: [PATCH] appliance: Copy /etc/machine-id from host system into the appliance.
- [PATCH] appliance: run systemd-tmpfiles also for /var/run
- [PATCH 5/5] appliance: run systemd-tmpfiles also for /run
- [PATCH 4/4] appliance: run systemd-tmpfiles also for /run