dash: systemd-detect-virt fails to detect virtualized environment when run under dash

Jonathan Nieder jrnieder at gmail.com
Thu Oct 11 02:53:15 BST 2018


Hi,

spuggy930 at gmail.com wrote:

> When run under dash, systemd-detect-virt returns "none" in a systemd-nspawn
> chroot'd environment when it should not; same command under bash works
> as expected.

Do you have more details?  What test does systemd-detect-virt use, and
why is it failing on dash?  What version of systemd are you using?

Thanks,
Jonathan

> Because /bin/sh is linked to /bin/dash, this causes the MAKEDEV post-inst
> script not to realize it's in a virtual environment (despite tests added
> in 2.3.1-93 and 2.3.1-94 versions of makedev package to detect precisely
> this situation).
>
> it will, therefore, attempt to inappropriately create devices in the
> chroot. Which fails horribly, resulting in an uninstalled/unconfigured
> package. (actually many, in a debootstrap run)
>
> Which makes it more awkward than it should be to build an OS image via
> debootstrap in a systemd-nspawn container without hackery or workarounds.
>
> $ systemd-nspawn -D jessie-18-10-10/ /bin/bash -c "systemd-detect-virt"
> Spawning container jessie-18-10-10 on /data/PXE/squashbuilder/jessie-18-10-10.
> Press ^] three times within 1s to kill container.
> systemd-nspawn
> Container jessie-18-10-10 exited successfully.
>
> $ systemd-nspawn -D jessie-18-10-10/ /bin/dash -c "systemd-detect-virt"
> Spawning container jessie-18-10-10 on /data/PXE/squashbuilder/jessie-18-10-10.
> Press ^] three times within 1s to kill container.
> none
> Container jessie-18-10-10 failed with error code 1.



More information about the Pkg-systemd-maintainers mailing list