39 lines
1.4 KiB
Diff
39 lines
1.4 KiB
Diff
|
From 7275c6f6a0f6808cd939ea5bdf1244c7bd13ba44 Mon Sep 17 00:00:00 2001
|
||
|
From: Harald Hoyer <harald@redhat.com>
|
||
|
Date: Mon, 17 May 2021 14:22:10 +0200
|
||
|
Subject: [PATCH] feat(dracut.sh): detect running in a container
|
||
|
|
||
|
Don't try to `mknod` by setting DRACUT_NO_MKNOD.
|
||
|
Don't try to `cp` extended attributrs by setting DRACUT_NO_XATTR.
|
||
|
---
|
||
|
dracut.sh | 9 ++++++++-
|
||
|
1 file changed, 8 insertions(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/dracut.sh b/dracut.sh
|
||
|
index bfb7a1ac..24e1c2e7 100755
|
||
|
--- a/dracut.sh
|
||
|
+++ b/dracut.sh
|
||
|
@@ -1171,6 +1171,13 @@ if [[ -f $dracutbasedir/dracut-version.sh ]]; then
|
||
|
. "$dracutbasedir"/dracut-version.sh
|
||
|
fi
|
||
|
|
||
|
+if systemd-detect-virt -c &> /dev/null; then
|
||
|
+ export DRACUT_NO_MKNOD=1 DRACUT_NO_XATTR=1
|
||
|
+ if [[ $hostonly ]]; then
|
||
|
+ printf "%s\n" "dracut: WARNING: running in hostonly mode in a container!!"
|
||
|
+ fi
|
||
|
+fi
|
||
|
+
|
||
|
if [[ -f $dracutbasedir/dracut-init.sh ]]; then
|
||
|
# shellcheck source=./dracut-init.sh
|
||
|
. "$dracutbasedir"/dracut-init.sh
|
||
|
@@ -1888,7 +1895,7 @@ if [[ $kernel_only != yes ]]; then
|
||
|
# shellcheck disable=SC2174
|
||
|
mkdir -m 0755 -p "${initdir}/lib/dracut/hooks/$_d"
|
||
|
done
|
||
|
- if [[ $EUID == "0" ]]; then
|
||
|
+ if [[ $EUID == "0" ]] && ! [[ $DRACUT_NO_MKNOD ]]; then
|
||
|
[[ -c ${initdir}/dev/null ]] || mknod "${initdir}"/dev/null c 1 3
|
||
|
[[ -c ${initdir}/dev/kmsg ]] || mknod "${initdir}"/dev/kmsg c 1 11
|
||
|
[[ -c ${initdir}/dev/console ]] || mknod "${initdir}"/dev/console c 5 1
|