1 Star 0 Fork 9

jiaxinyyang/dracut

forked from OpenCloudOS Stream/dracut 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
fix-rootfs-generator.patch 4.49 KB
一键复制 编辑 原始数据 按行查看 历史
cunshunxia 提交于 2023-11-17 07:59 . fix rootfs generator issue
diff -uprN dracut-059/modules.d/98dracut-systemd/module-setup.sh dracut-059.patch/modules.d/98dracut-systemd/module-setup.sh
--- dracut-059/modules.d/98dracut-systemd/module-setup.sh 2022-12-24 16:49:27.000000000 +0000
+++ dracut-059.patch/modules.d/98dracut-systemd/module-setup.sh 2023-11-17 07:31:15.645791475 +0000
@@ -37,6 +37,8 @@ install() {
inst_script "$moddir/rootfs-generator.sh" "$systemdutildir"/system-generators/dracut-rootfs-generator
+ inst_hook cmdline 00 "$moddir/parse-root.sh"
+
for i in \
dracut-cmdline.service \
dracut-cmdline-ask.service \
diff -uprN dracut-059/modules.d/98dracut-systemd/parse-root.sh dracut-059.patch/modules.d/98dracut-systemd/parse-root.sh
--- dracut-059/modules.d/98dracut-systemd/parse-root.sh 1970-01-01 00:00:00.000000000 +0000
+++ dracut-059.patch/modules.d/98dracut-systemd/parse-root.sh 2023-11-17 07:29:54.551079730 +0000
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
+
+root=$(getarg root=)
+case "${root#block:}" in
+ LABEL=* | UUID=* | PARTUUID=* | PARTLABEL=*)
+ root="block:$(label_uuid_to_dev "$root")"
+ rootok=1
+ ;;
+ /dev/nfs | /dev/root) # ignore legacy
+ ;;
+ /dev/*)
+ root="block:${root}"
+ rootok=1
+ ;;
+esac
+
+if [ "$rootok" = "1" ]; then
+ root_dev="${root#block:}"
+ root_name="$(str_replace "$root_dev" '/' '\x2f')"
+ if ! [ -e "$hookdir/initqueue/finished/devexists-${root_name}.sh" ]; then
+
+ # If a LUKS device needs unlocking via systemd in the initrd, assume
+ # it's for the root device. In that case, don't block on it if it's
+ # after remote-fs-pre.target since the initqueue is ordered before it so
+ # it will never actually show up (think Tang-pinned rootfs).
+ cat > "$hookdir/initqueue/finished/devexists-${root_name}.sh" << EOF
+if ! grep -q After=remote-fs-pre.target /run/systemd/generator/systemd-cryptsetup@*.service 2>/dev/null; then
+ [ -e "$root_dev" ]
+fi
+EOF
+ {
+ printf '[ -e "%s" ] || ' "$root_dev"
+ printf 'warn "\"%s\" does not exist"\n' "$root_dev"
+ } >> "$hookdir/emergency/80-${root_name}.sh"
+ fi
+fi
diff -uprN dracut-059/modules.d/98dracut-systemd/rootfs-generator.sh dracut-059.patch/modules.d/98dracut-systemd/rootfs-generator.sh
--- dracut-059/modules.d/98dracut-systemd/rootfs-generator.sh 2022-12-24 16:49:27.000000000 +0000
+++ dracut-059.patch/modules.d/98dracut-systemd/rootfs-generator.sh 2023-11-17 07:31:15.645791475 +0000
@@ -6,28 +6,10 @@ generator_wait_for_dev() {
local _name
local _timeout
- _name="$(str_replace "$1" '/' '\x2f')"
+ _name=$(dev_unit_name "$1")
_timeout=$(getarg rd.timeout)
_timeout=${_timeout:-0}
- if ! [ -e "$hookdir/initqueue/finished/devexists-${_name}.sh" ]; then
-
- # If a LUKS device needs unlocking via systemd in the initrd, assume
- # it's for the root device. In that case, don't block on it if it's
- # after remote-fs-pre.target since the initqueue is ordered before it so
- # it will never actually show up (think Tang-pinned rootfs).
- cat > "$hookdir/initqueue/finished/devexists-${_name}.sh" << EOF
-if ! grep -q After=remote-fs-pre.target /run/systemd/generator/systemd-cryptsetup@*.service 2>/dev/null; then
- [ -e "$1" ]
-fi
-EOF
- {
- printf '[ -e "%s" ] || ' "$1"
- printf 'warn "\"%s\" does not exist"\n' "$1"
- } >> "$hookdir/emergency/80-${_name}.sh"
- fi
-
- _name=$(dev_unit_name "$1")
if ! [ -L "$GENERATOR_DIR"/initrd.target.wants/"${_name}".device ]; then
[ -d "$GENERATOR_DIR"/initrd.target.wants ] || mkdir -p "$GENERATOR_DIR"/initrd.target.wants
ln -s ../"${_name}".device "$GENERATOR_DIR"/initrd.target.wants/"${_name}".device
@@ -51,7 +33,6 @@ generator_mount_rootfs() {
[ -z "$1" ] && return 0
_name=$(dev_unit_name "$1")
- [ -d "$GENERATOR_DIR" ] || mkdir -p "$GENERATOR_DIR"
if ! [ -f "$GENERATOR_DIR"/sysroot.mount ]; then
{
echo "[Unit]"
@@ -101,9 +82,10 @@ case "${root#block:}" in
;;
esac
-GENERATOR_DIR="$1"
-
if [ "$rootok" = "1" ]; then
+ GENERATOR_DIR="$1"
+ [ -z "$GENERATOR_DIR" ] && exit 1
+ [ -d "$GENERATOR_DIR" ] || mkdir -p "$GENERATOR_DIR"
generator_wait_for_dev "${root#block:}" "$RDRETRY"
generator_fsck_after_pre_mount "${root#block:}"
strstr "$(cat /proc/cmdline)" 'root=' || generator_mount_rootfs "${root#block:}" "$(getarg rootfstype=)" "$(getarg rootflags=)"
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/XIN_Y/dracut.git
git@gitee.com:XIN_Y/dracut.git
XIN_Y
dracut
dracut
master

搜索帮助