mkosi icon indicating copy to clipboard operation
mkosi copied to clipboard

relative paths as --workspaces-dir are not made absolute, causing nspawn invalid argument errors

Open mcassaniti opened this issue 3 years ago • 4 comments

I'm using version 13 on Ubuntu 20.04 LTS with the below command line options:

/usr/local/bin/mkosi --format gpt_xfs --output mkosi.img --workspace-dir target-mkosi --root-size 8G build

I'm unfortunately getting this error near the end of the build phase:

I: Base system installed successfully.
Failed to parse --bind(-ro)= argument target-mkosi/pgax33su/var-tmp:/var/tmp: Invalid argument
‣ Error: Workspace command /bin/rm -rf /usr/share/locale /usr/share/doc /usr/share/man /usr/share/groff /usr/share/info /usr/share/lintian /usr/share/linda returned non-zero exit code 1.
‣  (Unmounting Package Cache)
‣  (Unmounting image)
‣  (Detaching /dev/loop3)

For completeness, my build machine /etc/os-release is:

NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

Perhaps I misunderstand when I should use the workspace-dir option. I used this option so that files didn't end up in /var/tmp during the second stage build. When I change the format to tar then things work fine.

mcassaniti avatar Jun 29 '22 04:06 mcassaniti

The problem seems to be nspawn being unhappy about the argument to --bind= (target-mkosi/pgax33su/var-tmp:/var/tmp:). Judging from your output snippet this happens in install_debian_or_ubuntu in the block where docs are deleted. A workaround could be to skip that section by building --with-docs, but I assume in that case you will see a failure further down, when kernel-install will be called via the same means backend.py:run_workspace_command.

Could the problem be, that the path is not absolute? Looking into the nspawn code I see that's the reason for it to throw an invalid argument error. Could you try to pass an absolut path as argument there?

Just out of curiosity: Why don't you want files to be in /var/temp? The file directory will be removed at the end of the build.

behrmann avatar Jun 29 '22 08:06 behrmann

For the test build I'm doing I probably have sufficient space in /var/tmp but I suspect later on as I do more I won't be so fortunate.

In any case, using an absolute path has resolved the issue :smile:. If you feel that this should be kept open as a bug then please do so, otherwise you're more than welcome to close this issue.

mcassaniti avatar Jun 29 '22 23:06 mcassaniti

Thanks for checking! Changed the title accordingly, because that's something we should fix.

behrmann avatar Jun 30 '22 07:06 behrmann

We can probably patch this in mkosi as well, but https://github.com/systemd/systemd/pull/23979 will fix this in nspawn itself

DaanDeMeyer avatar Jul 11 '22 20:07 DaanDeMeyer

This should be fixed, so let's close

DaanDeMeyer avatar Feb 14 '23 14:02 DaanDeMeyer