-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0005.patch
More file actions
143 lines (128 loc) · 5.03 KB
/
0005.patch
File metadata and controls
143 lines (128 loc) · 5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
From b39b8452d23d098aa4f6898a2bdb8391aa45836e Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Wed, 28 Feb 2018 09:39:12 +0100
Subject: [PATCH] 5?-dracut*.install: Allow scripts to install the initramfs in
/boot dir
The GRUB 2 bootloaders expect the initrd to be installed in /boot instead
of /boot/$MACHINE_ID/$KERNEL_VERSION/{linux,initrd}, so if that directory
doesn't exists, install the initramfs images on the /boot directory.
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
50-dracut.install | 17 ++++++++++-----
51-dracut-rescue.install | 55 ++++++++++++++++++++++++++++++++++--------------
2 files changed, 51 insertions(+), 21 deletions(-)
diff --git a/50-dracut.install b/50-dracut.install
index f1314d02..64e3549f 100755
--- a/50-dracut.install
+++ b/50-dracut.install
@@ -11,6 +11,13 @@ if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then
exit 0
fi
+if [[ -d "$BOOT_DIR_ABS" ]]; then
+ INITRD="initrd"
+else
+ BOOT_DIR_ABS="/boot"
+ INITRD="initramfs-${KERNEL_VERSION}.img"
+fi
+
ret=0
case "$COMMAND" in
add)
@@ -18,9 +25,9 @@ case "$COMMAND" in
if [[ -f ${INITRD_IMAGE_PREGENERATED} ]]; then
# we found an initrd at the same place as the kernel
# use this and don't generate a new one
- cp --reflink=auto "$INITRD_IMAGE_PREGENERATED" "$BOOT_DIR_ABS/initrd" \
- && chown root:root "$BOOT_DIR_ABS/initrd" \
- && chmod 0600 "$BOOT_DIR_ABS/initrd" \
+ cp --reflink=auto "$INITRD_IMAGE_PREGENERATED" "$BOOT_DIR_ABS/$INITRD" \
+ && chown root:root "$BOOT_DIR_ABS/$INITRD" \
+ && chmod 0600 "$BOOT_DIR_ABS/$INITRD" \
&& exit 0
fi
@@ -42,11 +49,11 @@ case "$COMMAND" in
break
fi
done
- dracut ${noimageifnotneeded:+--noimageifnotneeded} "$BOOT_DIR_ABS"/initrd "$KERNEL_VERSION"
+ dracut ${noimageifnotneeded:+--noimageifnotneeded} "$BOOT_DIR_ABS/$INITRD" "$KERNEL_VERSION"
ret=$?
;;
remove)
- rm -f -- "$BOOT_DIR_ABS"/initrd
+ rm -f -- "$BOOT_DIR_ABS/$INITRD"
ret=$?
;;
esac
diff --git a/51-dracut-rescue.install b/51-dracut-rescue.install
index 7fbeac1d..3f07a698 100755
--- a/51-dracut-rescue.install
+++ b/51-dracut-rescue.install
@@ -63,15 +63,30 @@ if ! [[ ${BOOT_OPTIONS[*]} ]]; then
exit 1
fi
-BOOT_DIR="/${MACHINE_ID}/0-rescue"
-BOOT_ROOT=${BOOT_DIR_ABS%$BOOT_DIR}
-LOADER_ENTRY="$BOOT_ROOT/loader/entries/${MACHINE_ID}-0-rescue.conf"
+if [[ -d "$BOOT_DIR_ABS" ]]; then
+ BOOT_DIR="/${MACHINE_ID}/0-rescue"
+ BOOT_ROOT=${BOOT_DIR_ABS%$BOOT_DIR}
+ LOADER_ENTRY="$BOOT_ROOT/loader/entries/${MACHINE_ID}-0-rescue.conf"
+ KERNEL="linux"
+ INITRD="initrd"
+else
+ BLS_DIR="/boot/loader/entries"
+ if [ -d /sys/firmware/efi ]; then
+ BLS_DIR="/boot/efi/EFI/${ID}/loader/entries"
+ fi
+
+ BOOT_DIR_ABS="/boot"
+ LOADER_ENTRY="$BLS_DIR/${MACHINE_ID}-0-rescue.conf"
+ KERNEL="vmlinuz-0-rescue-${MACHINE_ID}"
+ INITRD="initramfs-0-rescue-${MACHINE_ID}.img"
+fi
ret=0
case "$COMMAND" in
add)
- [[ -f "$LOADER_ENTRY" ]] && exit 0
+ [[ -f "$LOADER_ENTRY" ]] && [[ -f "$BOOT_DIR_ABS/$KERNEL" ]] \
+ && [[ -f "$BOOT_DIR_ABS/$INITRD" ]] && exit 0
# source our config dir
for f in $(dropindirs_sort ".conf" "/etc/dracut.conf.d" "/usr/lib/dracut/dracut.conf.d"); do
@@ -82,21 +97,29 @@ case "$COMMAND" in
[[ -d "$BOOT_DIR_ABS" ]] || mkdir -p "$BOOT_DIR_ABS"
- if ! cp --reflink=auto "$KERNEL_IMAGE" "$BOOT_DIR_ABS"/linux; then
- echo "Can't copy '$KERNEL_IMAGE to '$BOOT_DIR_ABS/linux'!" >&2
+ if ! cp --reflink=auto "$KERNEL_IMAGE" "$BOOT_DIR_ABS/$KERNEL"; then
+ echo "Can't copy '$KERNEL_IMAGE to '$BOOT_DIR_ABS/$KERNEL'!" >&2
fi
- dracut --no-hostonly -a "rescue" "$BOOT_DIR_ABS"/initrd "$KERNEL_VERSION"
- ((ret+=$?))
+ if [[ ! -f "$BOOT_DIR_ABS/$INITRD" ]]; then
+ dracut --no-hostonly -a "rescue" "$BOOT_DIR_ABS/$INITRD" "$KERNEL_VERSION"
+ ((ret+=$?))
+ fi
+
+ if [[ -d "$BOOT_DIR" ]]; then
+ {
+ echo "title $PRETTY_NAME - Rescue Image"
+ echo "version $KERNEL_VERSION"
+ echo "machine-id $MACHINE_ID"
+ echo "options ${BOOT_OPTIONS[@]} rd.auto=1"
+ echo "linux $BOOT_DIR/linux"
+ echo "initrd $BOOT_DIR/initrd"
+ } > $LOADER_ENTRY
+ else
+ cp -aT "${KERNEL_IMAGE%/*}/bls.conf" $LOADER_ENTRY
+ sed -i 's/'$KERNEL_VERSION'/0-rescue-'${MACHINE_ID}'/' $LOADER_ENTRY
+ fi
- {
- echo "title $PRETTY_NAME - Rescue Image"
- echo "version $KERNEL_VERSION"
- echo "machine-id $MACHINE_ID"
- echo "options ${BOOT_OPTIONS[@]} rd.auto=1"
- echo "linux $BOOT_DIR/linux"
- echo "initrd $BOOT_DIR/initrd"
- } > $LOADER_ENTRY
((ret+=$?))
;;