1 |
commit: 24ad5065fa856389ee9b058f57adffbe752da157 |
2 |
Author: Christian Nilsson <nikize <AT> gmail <DOT> com> |
3 |
AuthorDate: Tue Jul 24 23:08:23 2018 +0000 |
4 |
Commit: Richard Farina <zerochaos <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Jul 25 15:10:19 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=24ad5065 |
7 |
|
8 |
linuxrc: Add detection of squashfs in initrd root |
9 |
|
10 |
Allows for the squashfs to be found in the initrd root without mounting CD |
11 |
This allows iPXE boot by adding the squashfs in a extra cpio initrd |
12 |
|
13 |
Related: https://bugs.gentoo.org/74628 |
14 |
Related: https://bugs.gentoo.org/494300 |
15 |
Closes: https://bugs.gentoo.org/396467 |
16 |
Signed-off-by: Christian Nilsson <nikize <AT> gmail.com> |
17 |
|
18 |
defaults/initrd.defaults | 5 +++++ |
19 |
defaults/linuxrc | 21 +++++++++++++++------ |
20 |
2 files changed, 20 insertions(+), 6 deletions(-) |
21 |
|
22 |
diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults |
23 |
index 924bdea..2bf14f4 100755 |
24 |
--- a/defaults/initrd.defaults |
25 |
+++ b/defaults/initrd.defaults |
26 |
@@ -70,6 +70,11 @@ CDROOT_PATH='/mnt/cdrom' |
27 |
CDROOT_MARKER='/livecd' |
28 |
VERIFY=0 |
29 |
|
30 |
+# Flag for if ok when using CDROOT |
31 |
+got_good_root='0' |
32 |
+# if LOOP found on root before mount, trigger Unpacking additional packages |
33 |
+got_loop_wo_mount='0' |
34 |
+ |
35 |
# AUFS variables |
36 |
aufs=0 |
37 |
aufs_union_file=/livecd.aufs |
38 |
|
39 |
diff --git a/defaults/linuxrc b/defaults/linuxrc |
40 |
index 81e7799..17697fc 100644 |
41 |
--- a/defaults/linuxrc |
42 |
+++ b/defaults/linuxrc |
43 |
@@ -431,6 +431,15 @@ then |
44 |
startiscsi |
45 |
fi |
46 |
|
47 |
+# Loop file already exists on fs, assume no mount needed, |
48 |
+# This allows for squashfs in initrd, which can be used for (i)PXE booting |
49 |
+if [ -e "${LOOP}" ] |
50 |
+then |
51 |
+ got_good_root=1 |
52 |
+ got_loop_wo_mount=1 |
53 |
+ CDROOT_PATH=$(dirname "${LOOP}") |
54 |
+fi |
55 |
+ |
56 |
# Apply scan delay if specified |
57 |
sdelay |
58 |
|
59 |
@@ -497,16 +506,16 @@ then |
60 |
if [ 1 = "$aufs" ]; then |
61 |
setup_aufs |
62 |
CHROOT=$aufs_union |
63 |
- elif [ 1 = "$overlayfs" ]; then |
64 |
+ elif [ 1 = "$overlayfs" ] && [ "${got_good_root}" != '1' ]; then |
65 |
bootstrapCD |
66 |
CHROOT=${NEW_ROOT} |
67 |
fi |
68 |
|
69 |
- if [ /dev/nfs != "$REAL_ROOT" ] && [ sgimips != "$LOOPTYPE" ] && [ 1 != "$aufs" ] && [ 1 != "$overlayfs" ]; then |
70 |
+ if [ "${got_good_root}" != '1' ] && [ /dev/nfs != "$REAL_ROOT" ] && [ sgimips != "$LOOPTYPE" ] && [ 1 != "$aufs" ] && [ 1 != "$overlayfs" ]; then |
71 |
bootstrapCD |
72 |
fi |
73 |
|
74 |
- if [ "${REAL_ROOT}" = '' ] |
75 |
+ if [ "${REAL_ROOT}" = '' ] && [ "${got_good_root}" != '1' ] |
76 |
then |
77 |
warn_msg "No bootable medium found. Waiting for new devices..." |
78 |
COUNTER=0 |
79 |
@@ -518,7 +527,7 @@ then |
80 |
bootstrapCD |
81 |
fi |
82 |
|
83 |
- if [ "${REAL_ROOT}" = '' ] |
84 |
+ if [ "${REAL_ROOT}" = '' ] && [ "${got_good_root}" != '1' ] |
85 |
then |
86 |
# Undo stuff |
87 |
umount "${NEW_ROOT}/dev" 2>/dev/null |
88 |
@@ -865,10 +874,10 @@ FSTAB |
89 |
fi |
90 |
fi |
91 |
|
92 |
- # Unpacking additional packages from NFS mount |
93 |
+ # Unpacking additional packages from NFS mount, or root (if squashfs was found there) |
94 |
# This is useful for adding kernel modules to /lib |
95 |
# We do this now, so that additional packages can add whereever they want. |
96 |
- if [ "${REAL_ROOT}" = '/dev/nfs' ] |
97 |
+ if [ "${REAL_ROOT}" = '/dev/nfs' ] || [ "${got_loop_wo_mount}" == '1' ] |
98 |
then |
99 |
if [ -e "${CDROOT_PATH}/add" ] |
100 |
then |