Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFE: nspawn: allow to disable os-release safety check via env var or so #29185

Closed
rfc1036 opened this issue Sep 15, 2023 · 3 comments · Fixed by #29844
Closed

RFE: nspawn: allow to disable os-release safety check via env var or so #29185

rfc1036 opened this issue Sep 15, 2023 · 3 comments · Fixed by #29844
Labels
nspawn RFE 🎁 Request for Enhancement, i.e. a feature request

Comments

@rfc1036
Copy link
Contributor

rfc1036 commented Sep 15, 2023

systemd version the issue has been seen with

254.1-3

Used distribution

Debian

Linux kernel version used

6.4.0-2-amd64

CPU architectures issue was seen on

x86_64

Component

systemd-nspawn

Expected behaviour you didn't see

I think that systemd-nspawn should be able to start containers which have an empty and bind-mounted /usr directory.

Unexpected behaviour you saw

systemd-nspawn fails to start containers with a bind-mounted /usr if /etc is empty or if /etc/os-release is the usual symlink to the file in /usr.

Steps to reproduce the problem

Initialization:

mkdir /var/lib/machines/empty/
ln -s usr/bin usr/sbin usr/lib usr/lib64 /var/lib/machines/empty/

The container fails to start:

systemd-nspawn --private-network -b -D /var/lib/machines/empty/ --bind-ro=/usr

Unless I create a bogus os-release file:

mkdir /var/lib/machines/empty/etc/
echo ID=hack > /var/lib/machines/empty/etc/os-release
systemd-nspawn --private-network -b -D /var/lib/machines/empty/ --bind-ro=/usr

Additional program output to the terminal or log subsystem illustrating the issue

root@bongo:~# systemd-nspawn --private-network --network-veth -b -D /var/lib/machines/empty/ --bind-ro=/usr
Directory /var/lib/machines/empty doesn't look like an OS root directory (os-release file is missing). Refusing.
[Exit 1]
root@bongo:~#
@rfc1036 rfc1036 added the bug 🐛 Programming errors, that need preferential fixing label Sep 15, 2023
@bluca bluca changed the title os-release is not found in containers with a bind-mounted /usr nspawn fails to boot container with empty root and a bind-mounted (populated) /usr Sep 16, 2023
@poettering
Copy link
Member

I am not sure I follow? Why not just populate /usr/lib/os-release with a valid file?

@poettering poettering added needs-reporter-feedback ❓ There's an unanswered question, the reporter needs to answer and removed bug 🐛 Programming errors, that need preferential fixing labels Oct 30, 2023
@rfc1036
Copy link
Contributor Author

rfc1036 commented Oct 30, 2023

There is a valid file there after the container is started, but while it is being started /var/lib/machines/$NAME/usr/ is empty because /usr/ will be bind-mounted from somewhere else.

@poettering
Copy link
Member

This setup is kinda weird, but I guess we should support it, at least via some env var you can set that relaxes the os-release check.

Happy to take a patch for that!

@poettering poettering changed the title nspawn fails to boot container with empty root and a bind-mounted (populated) /usr RFE: nspawn: allow to disable os-release safety check via env var or so Oct 31, 2023
@poettering poettering added RFE 🎁 Request for Enhancement, i.e. a feature request and removed needs-reporter-feedback ❓ There's an unanswered question, the reporter needs to answer labels Oct 31, 2023
mrc0mmand added a commit to mrc0mmand/systemd that referenced this issue Nov 3, 2023
Introduce a new env variable $SYSTEMD_NSPAWN_CHECK_OS_RELEASE, that can
be used to disable the os-release check for bootable OS trees. Useful
when trying to boot a container with empty /etc and bind-mounted /usr.

Resolves: systemd#29185
mrc0mmand added a commit to mrc0mmand/systemd that referenced this issue Nov 3, 2023
Introduce a new env variable $SYSTEMD_NSPAWN_CHECK_OS_RELEASE, that can
be used to disable the os-release check for bootable OS trees. Useful
when trying to boot a container with empty /etc and bind-mounted /usr.

Resolves: systemd#29185
mrc0mmand added a commit to mrc0mmand/systemd that referenced this issue Nov 3, 2023
Introduce a new env variable $SYSTEMD_NSPAWN_CHECK_OS_RELEASE, that can
be used to disable the os-release check for bootable OS trees. Useful
when trying to boot a container with empty /etc/ and bind-mounted /usr/.

Resolves: systemd#29185
mrc0mmand added a commit to mrc0mmand/systemd that referenced this issue Nov 3, 2023
Introduce a new env variable $SYSTEMD_NSPAWN_CHECK_OS_RELEASE, that can
be used to disable the os-release check for bootable OS trees. Useful
when trying to boot a container with empty /etc/ and bind-mounted /usr/.

Resolves: systemd#29185
mrc0mmand added a commit to mrc0mmand/systemd that referenced this issue Nov 3, 2023
Introduce a new env variable $SYSTEMD_NSPAWN_CHECK_OS_RELEASE, that can
be used to disable the os-release check for bootable OS trees. Useful
when trying to boot a container with empty /etc/ and bind-mounted /usr/.

Resolves: systemd#29185
bluca pushed a commit that referenced this issue Nov 3, 2023
Introduce a new env variable $SYSTEMD_NSPAWN_CHECK_OS_RELEASE, that can
be used to disable the os-release check for bootable OS trees. Useful
when trying to boot a container with empty /etc/ and bind-mounted /usr/.

Resolves: #29185
ssahani pushed a commit to ssahani/systemd that referenced this issue Nov 23, 2023
Introduce a new env variable $SYSTEMD_NSPAWN_CHECK_OS_RELEASE, that can
be used to disable the os-release check for bootable OS trees. Useful
when trying to boot a container with empty /etc/ and bind-mounted /usr/.

Resolves: systemd#29185
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nspawn RFE 🎁 Request for Enhancement, i.e. a feature request
Development

Successfully merging a pull request may close this issue.

2 participants