Accepting request 330513 from home:favogt:branches:Base:System
Change the way /sysroot is mounted in dracut with systemd. OBS-URL: https://build.opensuse.org/request/show/330513 OBS-URL: https://build.opensuse.org/package/show/Base:System/dracut?expand=0&rev=225
This commit is contained in:
parent
7682ae6f6e
commit
e2833744e0
185
0400-use_fstab_systemd.patch
Normal file
185
0400-use_fstab_systemd.patch
Normal file
@ -0,0 +1,185 @@
|
||||
From: Fabian Vogt <fvogt@suse.com>
|
||||
Subject: Use /etc/fstab for /sysroot instead of custom sysroot.mount
|
||||
|
||||
systemd-fstab-generator is capable of mounting /sysroot itself,
|
||||
looking at /proc/cmdline if root= is set.
|
||||
|
||||
Index: dracut-043/modules.d/00systemd/module-setup.sh
|
||||
===================================================================
|
||||
--- dracut-043.orig/modules.d/00systemd/module-setup.sh
|
||||
+++ dracut-043/modules.d/00systemd/module-setup.sh
|
||||
@@ -14,7 +14,7 @@ check() {
|
||||
|
||||
# called by dracut
|
||||
depends() {
|
||||
- return 0
|
||||
+ echo fs-lib
|
||||
}
|
||||
|
||||
installkernel() {
|
||||
@@ -22,6 +22,23 @@ installkernel() {
|
||||
instmods -s efivarfs
|
||||
}
|
||||
|
||||
+fstab_sysroot() {
|
||||
+ local _dev=/dev/block/$(find_root_block_device)
|
||||
+ local _fstype _flags _subvol
|
||||
+ if [ -e $_dev ]; then
|
||||
+ _dev=$(shorten_persistent_dev "$(get_persistent_dev "$_dev")")
|
||||
+ _fstype="$(find_mp_fstype /)"
|
||||
+ _flags="$(find_mp_fsopts /)"
|
||||
+
|
||||
+ if [[ $use_fstab != yes ]] && [[ $_fstype = btrfs ]]; then
|
||||
+ _subvol=$(findmnt -e -v -n -o FSROOT --target /) \
|
||||
+ && _subvol=${_subvol#/}
|
||||
+ _flags="$_flags,${_subvol:+subvol=$_subvol}"
|
||||
+ fi
|
||||
+ printf "%s /sysroot %s %s 1 1\n" "$_dev" "$_fstype" "${_flags#,}"
|
||||
+ fi
|
||||
+}
|
||||
+
|
||||
# called by dracut
|
||||
install() {
|
||||
local _mods
|
||||
@@ -216,5 +233,8 @@ install() {
|
||||
} >> "$initdir/etc/systemd/journald.conf"
|
||||
|
||||
ln_r "${systemdsystemunitdir}/multi-user.target" "${systemdsystemunitdir}/default.target"
|
||||
+
|
||||
+ # Add entry for /sysroot to /etc/fstab
|
||||
+ fstab_sysroot >> "$initdir/etc/fstab"
|
||||
}
|
||||
|
||||
Index: dracut-043/modules.d/95rootfs-block/module-setup.sh
|
||||
===================================================================
|
||||
--- dracut-043.orig/modules.d/95rootfs-block/module-setup.sh
|
||||
+++ dracut-043/modules.d/95rootfs-block/module-setup.sh
|
||||
@@ -48,22 +48,25 @@ cmdline_rootfs() {
|
||||
|
||||
# called by dracut
|
||||
cmdline() {
|
||||
- cmdline_rootfs
|
||||
- cmdline_journal
|
||||
+ # When using systemd, we're storing the root device in /etc/fstab instead.
|
||||
+ if ! dracut_module_included "systemd"; then
|
||||
+ cmdline_rootfs
|
||||
+ cmdline_journal
|
||||
+ fi
|
||||
}
|
||||
|
||||
# called by dracut
|
||||
install() {
|
||||
- if [[ $hostonly_cmdline == "yes" ]]; then
|
||||
- local _journaldev=$(cmdline_journal)
|
||||
- [[ $_journaldev ]] && printf "%s\n" "$_journaldev" >> "${initdir}/etc/cmdline.d/95root-journaldev.conf"
|
||||
- local _rootdev=$(cmdline_rootfs)
|
||||
- [[ $_rootdev ]] && printf "%s\n" "$_rootdev" >> "${initdir}/etc/cmdline.d/95root-dev.conf"
|
||||
- fi
|
||||
-
|
||||
inst_multiple umount
|
||||
inst_multiple tr
|
||||
if ! dracut_module_included "systemd"; then
|
||||
+ if [[ $hostonly_cmdline == "yes" ]]; then
|
||||
+ local _journaldev=$(cmdline_journal)
|
||||
+ [[ $_journaldev ]] && printf "%s\n" "$_journaldev" >> "${initdir}/etc/cmdline.d/95root-journaldev.conf"
|
||||
+ local _rootdev=$(cmdline_rootfs)
|
||||
+ [[ $_rootdev ]] && printf "%s\n" "$_rootdev" >> "${initdir}/etc/cmdline.d/95root-dev.conf"
|
||||
+ fi
|
||||
+
|
||||
inst_hook cmdline 95 "$moddir/parse-block.sh"
|
||||
inst_hook pre-udev 30 "$moddir/block-genrules.sh"
|
||||
inst_hook mount 99 "$moddir/mount-root.sh"
|
||||
Index: dracut-043/modules.d/98dracut-systemd/dracut-cmdline.sh
|
||||
===================================================================
|
||||
--- dracut-043.orig/modules.d/98dracut-systemd/dracut-cmdline.sh
|
||||
+++ dracut-043/modules.d/98dracut-systemd/dracut-cmdline.sh
|
||||
@@ -68,8 +68,12 @@ case "$root" in
|
||||
rootok=1 ;;
|
||||
esac
|
||||
|
||||
-[ -z "$root" ] && die "No or empty root= argument"
|
||||
-[ -z "$rootok" ] && die "Don't know how to handle 'root=$root'"
|
||||
+if [ -z "$root" ]; then
|
||||
+ root=$(findmnt --fstab -n --output source --target /sysroot)
|
||||
+ [ -z "$root" ] && die "No or empty root= argument and not in fstab"
|
||||
+elif [ -z "$rootok" ]; then
|
||||
+ die "Don't know how to handle 'root=$root'"
|
||||
+fi
|
||||
|
||||
export root rflags fstype netroot NEWROOT
|
||||
|
||||
Index: dracut-043/modules.d/98dracut-systemd/rootfs-generator.sh
|
||||
===================================================================
|
||||
--- dracut-043.orig/modules.d/98dracut-systemd/rootfs-generator.sh
|
||||
+++ dracut-043/modules.d/98dracut-systemd/rootfs-generator.sh
|
||||
@@ -36,35 +36,6 @@ generator_wait_for_dev()
|
||||
fi
|
||||
}
|
||||
|
||||
-generator_mount_rootfs()
|
||||
-{
|
||||
- local _type=$2
|
||||
- local _flags=$3
|
||||
- local _name
|
||||
-
|
||||
- [ -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]"
|
||||
- echo "Before=initrd-root-fs.target"
|
||||
- echo "RequiresOverridable=systemd-fsck@${_name}.service"
|
||||
- echo "After=systemd-fsck@${_name}.service"
|
||||
- echo "[Mount]"
|
||||
- echo "Where=/sysroot"
|
||||
- echo "What=$1"
|
||||
- echo "Options=${_flags}"
|
||||
- echo "Type=${_type}"
|
||||
- } > "$GENERATOR_DIR"/sysroot.mount
|
||||
- fi
|
||||
- if ! [ -L "$GENERATOR_DIR"/initrd-root-fs.target.requires/sysroot.mount ]; then
|
||||
- [ -d "$GENERATOR_DIR"/initrd-root-fs.target.requires ] || mkdir -p "$GENERATOR_DIR"/initrd-root-fs.target.requires
|
||||
- ln -s ../sysroot.mount "$GENERATOR_DIR"/initrd-root-fs.target.requires/sysroot.mount
|
||||
- fi
|
||||
-}
|
||||
-
|
||||
generator_fsck_after_pre_mount()
|
||||
{
|
||||
local _name
|
||||
@@ -111,9 +82,12 @@ esac
|
||||
GENERATOR_DIR="$1"
|
||||
|
||||
if [ "${root%%:*}" = "block" ]; then
|
||||
- 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=)"
|
||||
+ generator_wait_for_dev "${root#block:}" "$RDRETRY"
|
||||
+ generator_fsck_after_pre_mount "${root#block:}"
|
||||
+ if ! [ -L "$GENERATOR_DIR"/initrd-root-fs.target.requires/sysroot.mount ]; then
|
||||
+ [ -d "$GENERATOR_DIR"/initrd-root-fs.target.requires ] || mkdir -p "$GENERATOR_DIR"/initrd-root-fs.target.requires
|
||||
+ ln -s ../sysroot.mount "$GENERATOR_DIR"/initrd-root-fs.target.requires/sysroot.mount
|
||||
+ fi
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Index: dracut-043/modules.d/99base/init.sh
|
||||
===================================================================
|
||||
--- dracut-043.orig/modules.d/99base/init.sh
|
||||
+++ dracut-043/modules.d/99base/init.sh
|
||||
@@ -128,8 +128,12 @@ make_trace_mem "hook cmdline" '1+:mem' '
|
||||
getarg 'rd.break=cmdline' -d 'rdbreak=cmdline' && emergency_shell -n cmdline "Break before cmdline"
|
||||
source_hook cmdline
|
||||
|
||||
-[ -z "$root" ] && die "No or empty root= argument"
|
||||
-[ -z "$rootok" ] && die "Don't know how to handle 'root=$root'"
|
||||
+if [ -z "$root" ]; then
|
||||
+ root=$(findmnt --fstab -n --output source --target /sysroot)
|
||||
+ [ -z "$root" ] && die "No or empty root= argument and not in fstab"
|
||||
+elif [ -z "$rootok" ]; then
|
||||
+ die "Don't know how to handle 'root=$root'"
|
||||
+fi
|
||||
|
||||
export root rflags fstype netroot NEWROOT
|
||||
|
57
0401-mount_option_mountpoint.patch
Normal file
57
0401-mount_option_mountpoint.patch
Normal file
@ -0,0 +1,57 @@
|
||||
From: Fabian Vogt <fvogt@suse.com>
|
||||
Subject: dracut.sh: Support --mount with just mountpoint as parameter
|
||||
|
||||
Right now the --mount parameter of dracut expects a rather long fstab-like
|
||||
line. This makes it possible to invoke dracut with e.g. --mount /boot.
|
||||
|
||||
Index: dracut-043/dracut.8.asc
|
||||
===================================================================
|
||||
--- dracut-043.orig/dracut.8.asc
|
||||
+++ dracut-043/dracut.8.asc
|
||||
@@ -338,6 +338,10 @@ provide a valid _/etc/fstab_.
|
||||
The default _<dump frequency>_ is "0".
|
||||
the default _<fsck order>_ is "2".
|
||||
|
||||
+**--mount** "_<mountpoint>_"::
|
||||
+ Like above, but _<device>_, _<filesystem type>_ and _<filesystem options>_
|
||||
+ are determined by looking at the current mounts.
|
||||
+
|
||||
**--add-device** _<device>_ ::
|
||||
Bring up _<device>_ in initramfs, _<device>_ should be the device name.
|
||||
This can be useful in hostonly mode for resume support when your swap is on
|
||||
Index: dracut-043/dracut.sh
|
||||
===================================================================
|
||||
--- dracut-043.orig/dracut.sh
|
||||
+++ dracut-043/dracut.sh
|
||||
@@ -152,6 +152,8 @@ Creates initial ramdisk images for prelo
|
||||
--mount "[DEV] [MP] [FSTYPE] [FSOPTS]"
|
||||
Mount device [DEV] on mountpoint [MP] with filesystem
|
||||
[FSTYPE] and options [FSOPTS] in the initramfs
|
||||
+ --mount "[MP]" Same as above, but [DEV], [FSTYPE] and [FSOPTS] are
|
||||
+ determined by looking at the current mounts.
|
||||
--add-device "[DEV]" Bring up [DEV] in initramfs
|
||||
-i, --include [SOURCE] [TARGET]
|
||||
Include the files in the SOURCE directory into the
|
||||
@@ -1536,9 +1538,21 @@ if [[ $kernel_only != yes ]]; then
|
||||
|
||||
while pop fstab_lines line; do
|
||||
line=($line)
|
||||
- [ -z "${line[3]}" ] && line[3]="defaults"
|
||||
+
|
||||
+ if [ -z "${line[1]}" ]; then
|
||||
+ # Determine device and mount options from current system
|
||||
+ mountpoint -q "${line[0]}" || derror "${line[0]} is not a mount point!"
|
||||
+ line=($(findmnt --raw -n --target "${line[0]}" --output=source,target,fstype,options))
|
||||
+ dinfo "Line for ${line[1]}: ${line[@]}"
|
||||
+ else
|
||||
+ # Use default options
|
||||
+ [ -z "${line[3]}" ] && line[3]="defaults"
|
||||
+ fi
|
||||
+
|
||||
+ # Default options for freq and passno
|
||||
[ -z "${line[4]}" ] && line[4]="0"
|
||||
[ -z "${line[5]}" ] && line[5]="2"
|
||||
+
|
||||
strstr "${line[2]}" "nfs" && line[5]="0"
|
||||
echo "${line[@]}" >> "${initdir}/etc/fstab"
|
||||
done
|
@ -1,3 +1,16 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Sep 11 11:06:46 UTC 2015 - fvogt@suse.com
|
||||
|
||||
- Add 0401-mount_option_mountpoint.patch:
|
||||
Make it possible to use a mountpoint as --mount parameter
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Sep 11 10:56:42 UTC 2015 - fvogt@suse.com
|
||||
|
||||
- Add experimental 0400-use_fstab_systemd.patch:
|
||||
Add entry for /sysroot in /etc/fstab instead of relying
|
||||
on root= and rootflags=
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sun Aug 23 19:14:15 UTC 2015 - seife+obs@b1-systems.com
|
||||
|
||||
|
@ -116,6 +116,9 @@ Patch202: dracut_dmraid_use_udev.patch
|
||||
## fix for SUSE systems which have dpkg installed anyway
|
||||
Patch300: dracut_dont_use_dpkg_defaults_on_SUSE.patch
|
||||
|
||||
Patch400: 0400-use_fstab_systemd.patch
|
||||
Patch401: 0401-mount_option_mountpoint.patch
|
||||
|
||||
BuildRequires: asciidoc
|
||||
BuildRequires: bash
|
||||
BuildRequires: docbook-xsl-stylesheets
|
||||
@ -245,6 +248,9 @@ and its cryptography during startup.
|
||||
|
||||
%patch300 -p1
|
||||
|
||||
%patch400 -p1
|
||||
%patch401 -p1
|
||||
|
||||
%build
|
||||
%configure\
|
||||
--systemdsystemunitdir=%{_unitdir}\
|
||||
|
Loading…
x
Reference in New Issue
Block a user