|
Harald Hoyer |
0840a3 |
From 1cadc26fd44a602ffbcfb59786b400990541dc86 Mon Sep 17 00:00:00 2001
|
|
Harald Hoyer |
0840a3 |
From: Harald Hoyer <harald@redhat.com>
|
|
Harald Hoyer |
0840a3 |
Date: Thu, 9 Jul 2015 13:18:13 +0200
|
|
Harald Hoyer |
0840a3 |
Subject: [PATCH] Add all btrfs devices
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
We have to find them with "btrfs usage", which is cumbersome.
|
|
Harald Hoyer |
0840a3 |
---
|
|
Harald Hoyer |
0840a3 |
dracut-functions.sh | 13 +++++++++++++
|
|
Harald Hoyer |
0840a3 |
dracut.sh | 22 ++++++++++++++++++++--
|
|
Harald Hoyer |
0840a3 |
modules.d/99base/module-setup.sh | 4 +++-
|
|
Harald Hoyer |
0840a3 |
3 files changed, 36 insertions(+), 3 deletions(-)
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
diff --git a/dracut-functions.sh b/dracut-functions.sh
|
|
Harald Hoyer |
0840a3 |
index f415f0d..639c5ae 100755
|
|
Harald Hoyer |
0840a3 |
--- a/dracut-functions.sh
|
|
Harald Hoyer |
0840a3 |
+++ b/dracut-functions.sh
|
|
Harald Hoyer |
0840a3 |
@@ -31,6 +31,10 @@ strstr() { [[ $1 = *"$2"* ]]; }
|
|
Harald Hoyer |
0840a3 |
strglobin() { [[ $1 = *$2* ]]; }
|
|
Harald Hoyer |
0840a3 |
# Generic glob matching function. If glob pattern $2 matches all of $1, OK
|
|
Harald Hoyer |
0840a3 |
strglob() { [[ $1 = $2 ]]; }
|
|
Harald Hoyer |
0840a3 |
+# returns OK if $1 contains literal string $2 at the beginning, and isn't empty
|
|
Harald Hoyer |
0840a3 |
+str_starts() { [ "${1#"$2"*}" != "$1" ]; }
|
|
Harald Hoyer |
0840a3 |
+# returns OK if $1 contains literal string $2 at the end, and isn't empty
|
|
Harald Hoyer |
0840a3 |
+str_ends() { [ "${1%*"$2"}" != "$1" ]; }
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
# helper function for check() in module-setup.sh
|
|
Harald Hoyer |
0840a3 |
# to check for required installed binaries
|
|
Harald Hoyer |
0840a3 |
@@ -1815,3 +1819,12 @@ lvm_internal_dev() {
|
|
Harald Hoyer |
0840a3 |
[[ ${DM_LV_LAYER} ]] || [[ ! -L /dev/${DM_VG_NAME}/${DM_LV_NAME} ]]
|
|
Harald Hoyer |
0840a3 |
}
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
+btrfs_devs() {
|
|
Harald Hoyer |
0840a3 |
+ local _mp="$1"
|
|
Harald Hoyer |
0840a3 |
+ btrfs device usage "$_mp" \
|
|
Harald Hoyer |
0840a3 |
+ | while read _dev _rest; do
|
|
Harald Hoyer |
0840a3 |
+ str_starts "$_dev" "/" || continue
|
|
Harald Hoyer |
0840a3 |
+ _dev=${_dev%,}
|
|
Harald Hoyer |
0840a3 |
+ printf -- "%s\n" "$_dev"
|
|
Harald Hoyer |
0840a3 |
+ done
|
|
Harald Hoyer |
0840a3 |
+}
|
|
Harald Hoyer |
0840a3 |
diff --git a/dracut.sh b/dracut.sh
|
|
Harald Hoyer |
0840a3 |
index 8394cee..bf1886f 100755
|
|
Harald Hoyer |
0840a3 |
--- a/dracut.sh
|
|
Harald Hoyer |
0840a3 |
+++ b/dracut.sh
|
|
Harald Hoyer |
0840a3 |
@@ -1146,6 +1146,11 @@ for line in "${fstab_lines[@]}"; do
|
|
Harald Hoyer |
0840a3 |
;;
|
|
Harald Hoyer |
0840a3 |
esac
|
|
Harald Hoyer |
0840a3 |
[ -z "$dev" ] && dwarn "Bad fstab entry $@" && continue
|
|
Harald Hoyer |
0840a3 |
+ if [[ "$3" == btrfs ]]; then
|
|
Harald Hoyer |
0840a3 |
+ for i in $(btrfs_devs "$2"); do
|
|
Harald Hoyer |
0840a3 |
+ push_host_devs "$i"
|
|
Harald Hoyer |
0840a3 |
+ done
|
|
Harald Hoyer |
0840a3 |
+ fi
|
|
Harald Hoyer |
0840a3 |
push_host_devs "$dev"
|
|
Harald Hoyer |
0840a3 |
host_fs_types["$dev"]="$3"
|
|
Harald Hoyer |
0840a3 |
done
|
|
Harald Hoyer |
0840a3 |
@@ -1194,8 +1199,14 @@ if [[ $hostonly ]]; then
|
|
Harald Hoyer |
0840a3 |
_bdev=$(readlink -f "/dev/block/$_dev")
|
|
Harald Hoyer |
0840a3 |
[[ -b $_bdev ]] && _dev=$_bdev
|
|
Harald Hoyer |
0840a3 |
push_host_devs $_dev
|
|
Harald Hoyer |
0840a3 |
- [[ "$mp" == "/" ]] && root_dev="$_dev"
|
|
Harald Hoyer |
0840a3 |
+ [[ "$mp" == "/" ]] && push root_devs "$_dev"
|
|
Harald Hoyer |
0840a3 |
push_host_devs "$_dev"
|
|
Harald Hoyer |
0840a3 |
+ if [[ $(find_mp_fstype "$mp") == btrfs ]]; then
|
|
Harald Hoyer |
0840a3 |
+ for i in $(btrfs_devs "$mp"); do
|
|
Harald Hoyer |
0840a3 |
+ [[ "$mp" == "/" ]] && push root_devs "$i"
|
|
Harald Hoyer |
0840a3 |
+ push_host_devs "$i"
|
|
Harald Hoyer |
0840a3 |
+ done
|
|
Harald Hoyer |
0840a3 |
+ fi
|
|
Harald Hoyer |
0840a3 |
done
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
if [[ -f /proc/swaps ]] && [[ -f /etc/fstab ]]; then
|
|
Harald Hoyer |
0840a3 |
@@ -1240,7 +1251,14 @@ if [[ $hostonly ]]; then
|
|
Harald Hoyer |
0840a3 |
[[ "$_o" != *x-initrd.mount* ]] && continue
|
|
Harald Hoyer |
0840a3 |
_dev=$(expand_persistent_dev "$_d")
|
|
Harald Hoyer |
0840a3 |
_dev="$(readlink -f "$_dev")"
|
|
Harald Hoyer |
0840a3 |
- [[ -b $_dev ]] && push_host_devs "$_dev"
|
|
Harald Hoyer |
0840a3 |
+ [[ -b $_dev ]] || continue
|
|
Harald Hoyer |
0840a3 |
+
|
|
Harald Hoyer |
0840a3 |
+ push_host_devs "$_dev"
|
|
Harald Hoyer |
0840a3 |
+ if [[ "$_t" == btrfs ]]; then
|
|
Harald Hoyer |
0840a3 |
+ for i in $(find_btrfs_devs "$_m"); do
|
|
Harald Hoyer |
0840a3 |
+ push_host_devs "$i"
|
|
Harald Hoyer |
0840a3 |
+ done
|
|
Harald Hoyer |
0840a3 |
+ fi
|
|
Harald Hoyer |
0840a3 |
done < /etc/fstab
|
|
Harald Hoyer |
0840a3 |
fi
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
diff --git a/modules.d/99base/module-setup.sh b/modules.d/99base/module-setup.sh
|
|
Harald Hoyer |
0840a3 |
index bbc68ba..3fbdc41 100755
|
|
Harald Hoyer |
0840a3 |
--- a/modules.d/99base/module-setup.sh
|
|
Harald Hoyer |
0840a3 |
+++ b/modules.d/99base/module-setup.sh
|
|
Harald Hoyer |
0840a3 |
@@ -102,7 +102,9 @@ install() {
|
|
Harald Hoyer |
0840a3 |
. "$moddir/dracut-lib.sh"
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
for _dev in ${host_devs[@]}; do
|
|
Harald Hoyer |
0840a3 |
- [[ "$_dev" == "$root_dev" ]] && continue
|
|
Harald Hoyer |
0840a3 |
+ for _dev2 in ${root_devs[@]}; do
|
|
Harald Hoyer |
0840a3 |
+ [[ "$_dev" == "$_dev2" ]] && continue 2
|
|
Harald Hoyer |
0840a3 |
+ done
|
|
Harald Hoyer |
0840a3 |
|
|
Harald Hoyer |
0840a3 |
# We only actually wait for real devs - swap is only needed
|
|
Harald Hoyer |
0840a3 |
# for resume and udev rules generated when parsing resume=
|