]>
Commit | Line | Data |
---|---|---|
bb529f94 JK |
1 | #!/bin/sh |
2 | ||
3 | # geninitrd | |
4 | # | |
45d4d8cb | 5 | # by PLD Linux Team |
bb529f94 | 6 | # |
9e1ceabe | 7 | # based on mkinitrd from RedHat Linux |
e4b07ddc | 8 | # |
9 | # TODO: | |
c3667d07 | 10 | # - make udev start before insmods |
e4b07ddc | 11 | # - make proper use of USE_UDEV - don't copy fules if USE_UDEV is off no! |
12 | # - sanitize - one mounting of /proc and /sys at the begining and one umount at the end! | |
aebe301c | 13 | # |
c31050f3 | 14 | |
28eec2b1 | 15 | RCSID='$Id$' |
ca2c2012 ER |
16 | R=${RCSID#* * }; VERSION=${R%% *} |
17 | PROGRAM=${0##*/} | |
bb529f94 JK |
18 | |
19 | . /etc/rc.d/init.d/functions | |
1cea325b | 20 | . /etc/geninitrd/functions |
bb529f94 | 21 | |
c3667d07 ER |
22 | COMPRESS=yes |
23 | USERAIDSTART=yes | |
24 | USEMDADMSTATIC=no | |
25 | USEINSMODSTATIC=no | |
26 | USE_SUSPEND=yes | |
27 | USE_TUXONICE=yes | |
10c3df06 MM |
28 | # it should be safe to remove scsi_mod from here, but I'm not sure... |
29 | PRESCSIMODS="-scsi_mod unknown -sd_mod" | |
64497ebb AM |
30 | PREIDEMODS="-ide-core unknown -ide-detect -ide-disk" |
31 | PREIDEMODSOLD="-ide-probe -ide-probe-mod -ide-disk" | |
bb529f94 JK |
32 | target="" |
33 | kernel="" | |
34 | force="" | |
35 | verbose="" | |
36 | MODULES="" | |
37 | img_vers="" | |
c3667d07 ER |
38 | fstab=/etc/fstab |
39 | insmod=insmod | |
40 | modext=.o | |
4e9eb79c | 41 | rootdev_nr=0 |
738c05d8 ER |
42 | # device node for rootfs from fstab |
43 | rootdev="" | |
5b71959c AM |
44 | # default bootsplash is off, if it have to be on, install bootsplash package |
45 | BOOT_SPLASH=no | |
e4b07ddc | 46 | # default same as bootsplash, if on install splashutils and some splashutils theme |
47 | FB_SPLASH=no | |
48 | # defualt we don't use udev to make nodes for static modules, as per default | |
49 | # PLD loads the modules needed to mount and boot | |
50 | PROBESTATICMODULES=no | |
bb529f94 | 51 | |
8bd582f1 ER |
52 | # internal variables |
53 | # is /dev on tmpfs | |
54 | tmpfs_dev=no | |
55 | # is /proc/devices entries already created | |
56 | proc_partitions=no | |
6b013929 ER |
57 | |
58 | # LVM devices that should not be included in vgscan on initrd | |
f8a1a92c | 59 | lvm_ignore_devices='' |
c083ae23 | 60 | |
69b1e935 ER |
61 | # if we should init NFS at boot |
62 | have_nfs=no | |
63 | # if we should init LVM at boot | |
df738638 ER |
64 | have_lvm=no |
65 | # if we should init md (softraid) at boot | |
66 | have_md=no | |
c083ae23 ER |
67 | # if we should init dmraid at boot |
68 | have_dmraid=no | |
9baf4f3f | 69 | # if we should init dm-multipath at boot |
69b1e935 | 70 | have_multipath=no |
b4d9d384 | 71 | |
447ff04b | 72 | if [ -f /etc/udev/udev.conf -a -x /sbin/initrd-udevd ]; then |
c3667d07 | 73 | USE_UDEV=yes |
1606e343 AM |
74 | . /etc/udev/udev.conf |
75 | fi | |
882472ae ER |
76 | |
77 | if [ -x /sbin/dmraid-initrd ]; then | |
c3667d07 | 78 | USE_DMRAID=yes |
882472ae | 79 | fi |
ac085800 | 80 | |
2cc3ae8b | 81 | if [ -x /sbin/multipath ]; then |
c3667d07 | 82 | USE_MULTIPATH=yes |
2cc3ae8b ER |
83 | fi |
84 | ||
bb529f94 | 85 | usage () { |
553786c4 | 86 | uname_r=$(uname -r) |
00eaa938 | 87 | echo "usage: $PROGRAM [--version] [-v] [-f] [--ifneeded] [--preload <module>]" |
ac085800 | 88 | echo " [--with=<module>] [--image-version] [--fstab=<fstab>] [--nocompress]" |
92ed99b6 | 89 | echo " [--initrdfs=rom|initramfs|ext2|cram] [--modules-conf=<modules.conf>]" |
ac085800 | 90 | echo " [--with-raidstart] [--without-raidstart] [--with-insmod-static]" |
ba5d09f0 | 91 | echo " [--with-bootsplash] [--without-bootsplash]" |
92 | echo " [ --with-fbsplash] [--without-fbsplash]" | |
e4b07ddc | 93 | echo " [--lvmtoolsversion=1|2] [--with-udev] [--without-udev]" |
ba5d09f0 | 94 | echo " [--with-suspend] [--without-suspend]" |
1cd2aabd | 95 | echo " [--with-tuxonice] [--without-tuxonice]" |
2cc3ae8b | 96 | echo " [--without-dmraid] [--without-multipath]" |
ac085800 | 97 | echo " <initrd-image> <kernel-version>" |
553786c4 ER |
98 | echo "" |
99 | echo "example:" | |
00eaa938 | 100 | echo " $PROGRAM -f --initrdfs=rom /boot/initrd-$uname_r.gz $uname_r" |
7d2fc5eb | 101 | exit 1 |
bb529f94 JK |
102 | } |
103 | ||
94769f11 | 104 | debug() { |
f155a80b | 105 | [ -n "$verbose" ] && echo >&2 "$*" |
94769f11 | 106 | } |
aa69da6e | 107 | |
bf6c3fcb ER |
108 | # aborts program abnormally |
109 | die() { | |
b5f5c089 | 110 | local rc=${2:-1} |
bf6c3fcb ER |
111 | echo >&2 "$PROGRAM: ERROR: $1" |
112 | exit $rc | |
113 | } | |
114 | ||
9299682f ER |
115 | # Checks if busybox has support for APPLET(s) |
116 | # Exits from geninitrd if the support is not present. | |
117 | # | |
118 | # NB! XXX do not output to STDOUT, it will appear in initrd images in some cases! | |
119 | busybox_applet() { | |
120 | local err=0 | |
121 | ||
122 | if [ -z "$busybox_functions" ]; then | |
9b1373fb ER |
123 | local tmp=$(/bin/initrd-busybox 2>&1) |
124 | ||
125 | # BusyBox v1.1.3 says applet not found if it's not called 'busybox'. | |
126 | if [[ "$tmp" = *applet\ not\ found* ]]; then | |
127 | local t=$(mktemp -d) | |
128 | ln -s /bin/initrd-busybox $t/busybox | |
129 | local tmp=$($t/busybox 2>&1) | |
130 | rm -rf $t | |
131 | fi | |
132 | ||
133 | busybox_functions=$(echo "$tmp" | \ | |
9299682f ER |
134 | sed -ne '/Currently defined functions:/,$p' | \ |
135 | xargs | sed -e 's,.*Currently defined functions: ,,' | |
136 | ) | |
137 | fi | |
138 | for applet in $*; do | |
139 | local have | |
140 | # try cache | |
141 | eval have='$'busybox_have_$applet | |
142 | if [ -z "$have" ]; then | |
143 | have=$(echo "$busybox_functions" | egrep -c "( |^)$applet(,|$)") | |
144 | if [ "$have" = 0 ]; then | |
145 | echo >&2 "This setup requires busybox-initrd compiled with applet '$applet' support" | |
146 | err=1 | |
147 | fi | |
148 | eval busybox_have_$applet=$have | |
149 | fi | |
150 | done | |
151 | if [ $err = 1 ]; then | |
00eaa938 | 152 | die "Aborted" |
9299682f ER |
153 | fi |
154 | } | |
155 | ||
10c3df06 MM |
156 | find_depmod () { |
157 | typeset mods module f level depfile first | |
158 | ||
159 | depfile=/lib/modules/$kernel/modules.dep | |
ac085800 | 160 | |
00eaa938 | 161 | if [ ! -f $depfile ]; then |
9e1ceabe | 162 | die "No $depfile! Run depmod and rerun $PROGRAM." |
f6de9380 | 163 | fi |
ac085800 | 164 | |
0868f49f | 165 | # prepend / if no path given, append $modext.gz if not given, |
10c3df06 | 166 | # quote / |
3b00e899 | 167 | origmodule="$2" |
10c3df06 | 168 | module=$(echo "$2" | \ |
ac085800 ER |
169 | awk '/\// {print;next} {print "/" $0}' | \ |
170 | awk '/\./ {print;next} {print $0 "'$modext'.gz"}' | | |
171 | awk '{gsub("/","\\/");print}') | |
10c3df06 MM |
172 | mods=$(awk ' |
173 | BEGIN { here = 0 } | |
174 | /'"$module"':(.*)/ { gsub(/:/," "); gsub(/\\/," "); print; here = 1; next } | |
175 | /:/ { here = 0 } | |
176 | /(.*)/ { gsub(/\\/," "); if (here) print } | |
4fd11db9 AF |
177 | ' $depfile | xargs) |
178 | ||
0868f49f | 179 | # fallback to $modext |
07b09cf9 | 180 | if [ "$mods" = "" ]; then |
00eaa938 | 181 | module=$(echo "$module" | awk '{gsub("\'$modext'\.gz$","\'$modext'",$0);print}') |
740d6215 | 182 | # ") - vim |
ac085800 | 183 | fi |
00eaa938 | 184 | |
4fd11db9 AF |
185 | mods=$(awk ' |
186 | BEGIN { here = 0 } | |
187 | /'"$module"':(.*)/ { gsub(/:/," "); gsub(/\\/," "); print; here = 1; next } | |
188 | /:/ { here = 0 } | |
189 | /(.*)/ { gsub(/\\/," "); if (here) print } | |
10c3df06 MM |
190 | ' $depfile | xargs) |
191 | ||
07b09cf9 ER |
192 | if [ "$mods" = "" ]; then |
193 | if [ "$1" != silent ]; then | |
94769f11 | 194 | echo >&2 "$origmodule: module not found in $depfile" |
10c3df06 | 195 | fi |
00eaa938 | 196 | if ! is_no "$EXIT_IF_MISSING"; then |
fd2dc249 AF |
197 | exit 1 |
198 | else | |
94769f11 | 199 | echo >&2 "If $origmodule isn't compiled in kernel then this initrd may not start your system." |
fd2dc249 | 200 | fi |
10c3df06 | 201 | fi |
ac085800 | 202 | |
10c3df06 | 203 | level=$3 |
07b09cf9 | 204 | if [ "$level" = "" ]; then |
10c3df06 MM |
205 | level=0 |
206 | fi | |
94769f11 | 207 | level=$((level + 1)) |
07b09cf9 | 208 | if [ $level -gt 20 ]; then |
00eaa938 | 209 | die "$origmodule: cycle in $depfile" |
10c3df06 | 210 | fi |
ac085800 | 211 | |
10c3df06 MM |
212 | first= |
213 | for f in $mods ; do | |
07b09cf9 | 214 | if [ "$first" = "" ]; then |
10c3df06 | 215 | first=$f |
413878f8 | 216 | else |
10c3df06 | 217 | find_depmod $1 $f $level |
9c9f7cdb | 218 | fi |
aa69da6e | 219 | done |
ac085800 | 220 | |
10c3df06 | 221 | echo $first |
aa69da6e | 222 | } |
223 | ||
10c3df06 | 224 | addmodule() { |
c3667d07 ER |
225 | local fmPath=$1 |
226 | local skiperrors=$2 | |
10c3df06 MM |
227 | |
228 | if [ ! -f "/lib/modules/$kernel/$fmPath" ]; then | |
229 | if [ -n "$skiperrors" ]; then | |
230 | return | |
231 | fi | |
232 | ||
00eaa938 | 233 | die "module $fmPath present in modules.dep, but not in filesystem (kernel = $kernel)" |
10c3df06 MM |
234 | fi |
235 | ||
236 | # only need to add each module once | |
237 | # quote / | |
c3667d07 | 238 | local tmpFmPath=$(echo $fmPath | awk '{gsub(/\//,"\\/");print}') |
10c3df06 MM |
239 | if echo "$MODULES" | awk '/'"$tmpFmPath"'/ {exit 1}' ; then |
240 | MODULES="$MODULES $fmPath" | |
241 | fi | |
81de8443 AF |
242 | } |
243 | ||
bb529f94 | 244 | findmodule() { |
c3667d07 ER |
245 | local skiperrors="" |
246 | local modName=$1 | |
10c3df06 | 247 | |
94769f11 | 248 | if [ ${modName#-} != ${modName} ]; then |
413878f8 | 249 | skiperrors=1 |
94769f11 | 250 | modName=${modName#-} |
413878f8 | 251 | fi |
bb529f94 | 252 | |
10c3df06 | 253 | # what's that? |
413878f8 | 254 | if [ "$modName" = "pluto" ]; then |
255 | findmodule fc4 | |
256 | findmodule soc | |
257 | fi | |
258 | if [ "$modName" = "fcal" ]; then | |
259 | findmodule fc4 | |
260 | findmodule socal | |
261 | fi | |
bb529f94 | 262 | |
c3667d07 | 263 | local mod allModulesToFind |
10c3df06 | 264 | if [ -n "$skiperrors" ]; then |
94769f11 | 265 | allModulesToFind=$(find_depmod silent $modName) |
10c3df06 | 266 | else |
94769f11 ER |
267 | allModulesToFind=$(find_depmod normal $modName) |
268 | if [ $? != 0 ]; then | |
10c3df06 | 269 | exit 1 |
413878f8 | 270 | fi |
413878f8 | 271 | fi |
ac085800 | 272 | |
94769f11 ER |
273 | for mod in $allModulesToFind; do |
274 | mod=$(echo $mod | awk '{sub(/^\/lib\/modules\/[^\/]*\//, ""); print}') | |
10c3df06 MM |
275 | addmodule $mod "$skiperrors" |
276 | done | |
bb529f94 JK |
277 | } |
278 | ||
034fdd5d ER |
279 | # install a file to temporary mount image. |
280 | # it will operate recursively (copying directories) | |
281 | # and will symlink destinations if source is symlink. | |
bb529f94 | 282 | inst() { |
dab92b1d | 283 | if [ "$#" -lt "2" ];then |
1775ba37 | 284 | die 'Usage: inst <file> $MNTIMAGE<destination>' |
c31050f3 | 285 | fi |
1775ba37 | 286 | cp -HR "$1" "$MNTIMAGE$2" |
bb529f94 JK |
287 | } |
288 | ||
dab92b1d | 289 | inst_d() { |
034fdd5d | 290 | if [ "$#" = "0" ];then |
dab92b1d | 291 | die 'Usage: inst_d $MNTIMAGE<destination> $MNTIMAGE<destination>' |
034fdd5d ER |
292 | fi |
293 | for dir in "$@"; do | |
034fdd5d ER |
294 | install -d "$MNTIMAGE$dir" |
295 | done | |
296 | } | |
297 | ||
df738638 ER |
298 | find_modules_md() { |
299 | local found raidlevel | |
300 | ||
ac085800 | 301 | if [ -f /etc/mdadm.conf ]; then |
94769f11 | 302 | debug "Finding RAID details using mdadm for rootdev=$1" |
ac085800 ER |
303 | eval `/sbin/mdadm -v --examine --scan --config=/etc/mdadm.conf | awk -v rootdev="$1" ' |
304 | BEGIN { | |
305 | found = "no"; | |
306 | dev_list = ""; | |
307 | raidlevel = "" | |
308 | rootdev_devfs = rootdev; | |
309 | if (rootdev ~ /\/dev\/md\/[0-9]/) { | |
310 | gsub(/\/dev\/md\//,"/dev/md",rootdev_devfs); | |
311 | } | |
514a668a | 312 | } |
ac085800 ER |
313 | |
314 | /^ARRAY/ { | |
315 | if (($2 == rootdev) || ($2 == rootdev_devfs)) { | |
316 | raidlevel=$3; | |
317 | gsub(/level=/,NUL,raidlevel); | |
318 | if (raidlevel ~ /^raid([0-6]|10)/) { | |
319 | gsub(/raid/,NUL,raidlevel); | |
320 | }; | |
321 | found="yes"; | |
322 | getline x; | |
323 | if (x ~ /devices=/) { | |
324 | dev_list = x; | |
325 | gsub(".*devices=", NUL, dev_list); | |
326 | gsub(",", " ", dev_list); | |
327 | } | |
328 | } | |
56946560 | 329 | } |
ac085800 ER |
330 | |
331 | END { | |
df738638 | 332 | print "have_md=" found; |
ac085800 ER |
333 | print "raidlevel=" raidlevel; |
334 | print "dev_list=\"" dev_list "\""; | |
335 | }'` | |
336 | fi | |
7c38b114 | 337 | |
df738638 | 338 | if [ "$have_md" != "yes" -a -f /etc/raidtab ]; then |
00eaa938 | 339 | die "raidtools are not longer supported. Please migrate to mdadm setup!" |
809cc4cc | 340 | fi |
ac085800 | 341 | |
df738638 | 342 | if is_yes "$have_md" ; then |
7c38b114 | 343 | case "$raidlevel" in |
bf17c86c | 344 | [01]|10) |
7c38b114 AF |
345 | findmodule "raid$raidlevel" |
346 | ;; | |
bf17c86c AM |
347 | [456]) |
348 | findmodule "-raid$raidlevel" | |
349 | findmodule "-raid456" | |
350 | ;; | |
7c38b114 AF |
351 | linear) |
352 | findmodule "linear" | |
353 | ;; | |
354 | *) | |
94769f11 | 355 | echo >&2 "raid level $number (in mdadm config) not recognized" |
7c38b114 AF |
356 | ;; |
357 | esac | |
88614cd1 | 358 | else |
00eaa938 | 359 | die "RAID devices not found for \"$1\", check your configuration!" |
7c38b114 | 360 | fi |
4e9eb79c AM |
361 | |
362 | rootdev_nr=$(( $rootdev_nr + 1 )) | |
363 | eval "rootdev${rootdev_nr}=\"$1\"" | |
364 | eval "dev_list${rootdev_nr}=\"${dev_list}\"" | |
ac085800 | 365 | |
7c38b114 | 366 | for device in $dev_list; do |
a8007847 | 367 | find_modules_for_device $device |
7c38b114 AF |
368 | done |
369 | } | |
370 | ||
371 | find_modules_scsi() { | |
c3667d07 | 372 | local n |
7c38b114 | 373 | for n in $PRESCSIMODS; do |
07b09cf9 | 374 | if [ "X$n" = "Xunknown" ]; then |
7c38b114 | 375 | if [ -f "$modulefile" ]; then |
d4a15d5f | 376 | scsimodules="`awk '/scsi_hostadapter/ && ! /^[\t ]*#/ { print $3; }' $modulefile`" |
7c38b114 AF |
377 | for n in $scsimodules; do |
378 | # for now allow scsi modules to come from anywhere. There are some | |
379 | # RAID controllers with drivers in block | |
380 | findmodule "$n" | |
381 | done | |
382 | fi | |
383 | else | |
384 | findmodule "$n" | |
385 | fi | |
386 | done | |
84df18b8 | 387 | findmodule "-scsi_wait_scan" |
7c38b114 AF |
388 | } |
389 | ||
390 | find_modules_ide() { | |
c3667d07 ER |
391 | local devpath=$1 |
392 | # remove partition, if any | |
393 | local disk=${devpath%[0-9]*} | |
f0615744 | 394 | # set blockdev for rootfs (hda, sdc, ...) |
c3667d07 | 395 | local rootblkdev=${disk#/dev/} |
ac085800 | 396 | |
c3667d07 | 397 | local n |
ac085800 | 398 | if [ "$pack_version_long" -lt "002004021" ]; then |
94769f11 | 399 | debug "Finding IDE modules for kernels <= 2.4.20" |
ac085800 ER |
400 | for n in $PREIDEMODSOLD; do |
401 | findmodule "$n" | |
402 | done | |
64497ebb | 403 | else |
c3667d07 | 404 | local tryauto=1 |
ac085800 | 405 | for n in $PREIDEMODS; do |
07b09cf9 | 406 | if [ "X$n" = "Xunknown" ]; then |
ac085800 | 407 | if [ -f "$modulefile" ]; then |
94769f11 | 408 | debug "Finding IDE modules using ide_hostadapter" |
ac085800 ER |
409 | idemodules="`awk '/ide_hostadapter/ && ! /^[\t ]*#/ { print $3; }' $modulefile`" |
410 | for na in $idemodules; do | |
411 | tryauto=0; | |
412 | findmodule "$na" | |
413 | done | |
414 | fi | |
64497ebb | 415 | |
ac085800 ER |
416 | if [ "$tryauto" -eq 1 ]; then |
417 | # If tryauto {{{ | |
418 | if [ -r /usr/share/pci-database/ide.pci -a -r /proc/bus/pci/devices ]; then | |
94769f11 | 419 | debug "Finding IDE modules using PCI ID database" |
ac085800 ER |
420 | # Finding IDE modules using PCI ID database {{{ |
421 | if is_yes "${ide_only_root}"; then | |
f0615744 ER |
422 | if [ -f /sys/block/${rootblkdev}/device/../../vendor -a -f /sys/block/${rootblkdev}/device/../../device ]; then |
423 | vendorid="$(awk ' { gsub(/0x/,NUL); print $0 } ' /sys/block/${rootblkdev}/device/../../vendor)" | |
424 | deviceid="$(awk ' { gsub(/0x/,NUL); print $0 } ' /sys/block/${rootblkdev}/device/../../device)" | |
ac085800 | 425 | searchpciid="${vendorid}${deviceid}" |
f0615744 ER |
426 | elif [ -f /proc/ide/${rootblkdev}/../config ]; then |
427 | searchpciid="$(awk ' /pci bus/ { print $7$9 } ' /proc/ide/${rootblkdev}/../config)" | |
ac085800 ER |
428 | fi |
429 | fi | |
430 | ||
431 | if [ -z "${searchpciid}" ]; then | |
432 | searchpciid="$(awk ' { print $2 } ' /proc/bus/pci/devices)" | |
433 | fi | |
434 | ||
435 | idemodules="" | |
436 | ||
437 | for nb in $searchpciid; do | |
438 | eval `awk -v pciid="$nb" '{ | |
439 | gsub("\t"," "); | |
440 | gsub(" +", " "); | |
441 | gsub("^ ",""); | |
442 | if (/^[\t ]*#/) | |
443 | next; | |
444 | compmod = $1 ""; # make sure comparison type will be string | |
445 | # cause pci IDs are hexadecimal numeric | |
446 | if (compmod == pciid) { | |
447 | module=$2; | |
448 | # min_kernel=$3; # now in ide.pci $3,$4 = vendor and device name | |
449 | # max_kernel=$4; # | |
450 | exit 0; | |
451 | } | |
452 | } | |
453 | ||
454 | END { | |
455 | print "module=" module "\nmin_kernel=" min_kernel "\nmax_kernel=\"" max_kernel "\"\n"; | |
456 | }' /usr/share/pci-database/ide.pci` | |
457 | [ -n "$module" ] && idemodules="$idemodules $module" | |
458 | done | |
459 | if is_yes "$(awk ' /ide=reverse/ { print "yes" } ' /proc/cmdline)"; then | |
460 | new_idemodules="" | |
461 | for nc in idemodules; do | |
462 | new_idemodules="$nc $new_idemodules" | |
463 | done | |
464 | idemodules="${new_idemodules}" | |
465 | fi | |
466 | ||
467 | if [ -z "$idemodules" ]; then | |
468 | echo "WARNING: rootfs on IDE device but no related modules found, loading ide-generic." | |
469 | idemodules="ide-generic" | |
470 | fi | |
471 | ||
472 | # }}} | |
473 | for nd in $idemodules; do | |
474 | findmodule "-$nd" | |
475 | done | |
476 | # }}} | |
477 | # else tryauto {{{ | |
478 | else | |
479 | [ -r /usr/share/pci-database/ide.pci ] || echo "WARNING: /usr/share/pci-database/ide.pci missing." | |
480 | [ -r /proc/bus/pci/devices ] || echo "WARNING: /proc/bus/pci/devices missing." | |
481 | echo "Automatic IDE modules finding not available." | |
482 | fi | |
483 | # }}} | |
484 | fi | |
485 | else | |
486 | findmodule "$n" | |
5de40f1f | 487 | fi |
ac085800 | 488 | done |
64497ebb | 489 | fi |
7c38b114 AF |
490 | } |
491 | ||
a7fce633 ER |
492 | # return true if node is lvm node |
493 | _check_lvm() { | |
494 | local node="$1" | |
495 | if [ ! -e "$node" ]; then | |
94769f11 | 496 | echo >&2 "WARNING: check_lvm(): node $node doesn't exist!" |
a7fce633 ER |
497 | return 1 |
498 | fi | |
499 | ||
500 | # block-major-58 is lvm1 | |
501 | ls -lL "$node" 2> /dev/null | awk '{if (/^b/) { if ($5 == "58,") { exit 0; } else { exit 1; } } else { exit 1; }}' | |
502 | rc=$? | |
503 | ||
504 | if [ $rc = 0 ]; then | |
94769f11 | 505 | debug "$node is LVM1 node" |
a7fce633 ER |
506 | # is lvm1 |
507 | return 0 | |
508 | fi | |
509 | ||
510 | /sbin/lvm lvdisplay "$node" > /dev/null 2>&1 | |
511 | rc=$? | |
512 | if [ $rc -gt 127 ]; then | |
513 | # lvdisplay terminated by signal! most likely it segfaulted. | |
00eaa938 | 514 | die "Unexpected exit from 'lvdisplay $node': $rc - are your lvm tools broken?" |
a7fce633 ER |
515 | fi |
516 | ||
517 | if [ $rc = 0 ]; then | |
94769f11 | 518 | debug "$node is lvm2 node" |
a7fce633 | 519 | else |
94769f11 | 520 | debug "$node is not any lvm node" |
a7fce633 ER |
521 | fi |
522 | return $rc | |
523 | } | |
524 | ||
07137fe3 ER |
525 | # find dm-multipath modules for $devpath |
526 | # returns false if $devpath is not dm-multipath | |
527 | find_modules_multipath() { | |
528 | local devpath="$1" | |
529 | ||
530 | # remove partition, if any | |
531 | local disk=${devpath%p[0-9]*} | |
532 | # need only dm name | |
533 | local id=${disk#/dev/mapper/} | |
534 | ||
535 | local info=$(multipath -l $id) | |
536 | if [ -z "$info" ]; then | |
537 | return 1 | |
538 | fi | |
539 | ||
540 | debug "have multipath" | |
541 | have_multipath=yes | |
542 | local dev phydevs=$(echo "$info" | awk '$2 ~ /^[0-9]+:[0-9]+:[0-9]+:[0-9]+$/{printf("/dev/%s\n", $3)}') | |
543 | for dev in $phydevs; do | |
544 | find_modules_for_device $dev | |
6b013929 | 545 | lvm_ignore_devices="$lvm_ignore_devices $dev" |
07137fe3 ER |
546 | done |
547 | ||
548 | local hw hwhandlers=$(echo "$info" | awk '/hwhandler=1/{sub(/.*hwhandler=1 /, ""); sub(/\]$/, ""); print}') | |
549 | for hw in $hwhandlers; do | |
550 | findmodule "dm-$hw" | |
551 | done | |
552 | ||
553 | local target targets=$(echo "$info" | awk '/prio=/{print $2}' | sort -u) | |
554 | for target in $targets; do | |
555 | findmodule "dm-$target" | |
556 | done | |
557 | ||
558 | findmodule "dm-mod" | |
559 | return 0 | |
560 | } | |
561 | ||
c083ae23 ER |
562 | # find dmraid modules for $devpath |
563 | # returns false if $devpath is not on dmraid | |
564 | find_modules_dmraid() { | |
565 | local devpath="$1" | |
566 | ||
567 | # get blockdev itself (without partition) | |
568 | # /dev/mapper/sil_ahbgadcbchfc3 -> /dev/mapper/sil_ahbgadcbchfc | |
569 | local blockdev=${devpath%%[0-9]*} | |
570 | local raidname=${blockdev#/dev/mapper/} | |
571 | local found=0 | |
572 | ||
573 | local dev phydevs=$(dmraid -r -cdevpath,raidname | awk -F, -vv="$raidname" '{if ($2 == v) print $1}') | |
574 | for dev in $phydevs; do | |
575 | find_modules_for_device $dev | |
6b013929 | 576 | lvm_ignore_devices="$lvm_ignore_devices $dev" |
c083ae23 ER |
577 | found=1 |
578 | done | |
579 | ||
580 | if [ $found = 0 ]; then | |
581 | return 1 | |
582 | fi | |
583 | ||
584 | # XXX probably should detect | |
585 | findmodule "dm-mirror" | |
586 | have_dmraid=yes | |
587 | return 0 | |
588 | } | |
589 | ||
bc0d6f2d | 590 | # find modules for $devpath |
a8007847 | 591 | find_modules_for_device() { |
bc0d6f2d ER |
592 | local devpath="$1" |
593 | if [ -z "$devpath" ]; then | |
a8007847 | 594 | die "No argument passed to find_modules_for_device() - is your /etc/fstab correct?" |
f6536797 | 595 | fi |
ac085800 | 596 | |
bc0d6f2d ER |
597 | # /dev/dm-3 -> /dev/mapper/sil_ahbgadcbchfc3 |
598 | case "$devpath" in | |
599 | /dev/dm-*) | |
600 | devpath=$(dm_longname "$devpath") | |
601 | ;; | |
602 | esac | |
9baf4f3f | 603 | debug "find_modules_for_device($devpath)" |
bc0d6f2d | 604 | |
bc0d6f2d | 605 | if is_yes "`echo "$devpath" | awk '/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:|\/dev\/nfs)/ { print "yes"; }'`"; then |
07b09cf9 | 606 | if [ ! -x /usr/bin/pcidev -a -z "$NFS_ETH_MODULES" ]; then |
00eaa938 | 607 | die "root on NFS but /usr/bin/pcidev not found. Please install correct pci-database package and rerun $PROGRAM." |
6fe19d5b | 608 | fi |
07137fe3 | 609 | local m |
5c4cec75 AM |
610 | [ -z "$NFS_ETH_MODULES" ] && NFS_ETH_MODULES=$(/usr/bin/pcidev /m net | xargs) |
611 | for m in $NFS_ETH_MODULES; do | |
ac085800 | 612 | findmodule "$m" |
6fe19d5b AM |
613 | done |
614 | findmodule "-ipv4" | |
ac085800 | 615 | findmodule "nfs" |
69b1e935 | 616 | have_nfs=yes |
9baf4f3f ER |
617 | echo >&2 "Remember to use \`root=/dev/ram0 init=/linuxrc' when starting kernel" |
618 | echo >&2 "or you will have problems like init(xx) being child process of swapper(1)." | |
d9179777 ER |
619 | return |
620 | fi | |
621 | ||
9baf4f3f | 622 | if [[ "$devpath" == /dev/md/* ]]; then |
df738638 | 623 | find_modules_md "$devpath" |
d9179777 ER |
624 | return |
625 | fi | |
626 | ||
1a63b128 | 627 | if is_yes "$USE_MULTIPATH" && [[ "$devpath" == /dev/mapper/* ]]; then |
07137fe3 | 628 | if find_modules_multipath "$devpath"; then |
9baf4f3f | 629 | return |
9baf4f3f | 630 | fi |
9baf4f3f ER |
631 | # fallback |
632 | fi | |
633 | ||
c083ae23 ER |
634 | if is_yes "$USE_DMRAID" && is_yes "$(echo "$devpath" | awk '/^\/dev\/mapper\/(sil|hpt37x|hpt45x|isw|lsi|nvidia|pdc|sil|via|dos)_/ { print "yes"; }')"; then |
635 | if find_modules_dmraid "$devpath"; then | |
636 | return | |
637 | fi | |
638 | # fallback | |
639 | fi | |
640 | ||
d9179777 | 641 | if is_yes "$(echo "$devpath" | awk '/^\/dev\/(sd|scsi)/ { print "yes"; }')" ; then |
7c38b114 | 642 | find_modules_scsi |
d9179777 ER |
643 | return |
644 | fi | |
645 | ||
c3667d07 | 646 | if is_yes "$(echo "$devpath" | awk '/^\/dev\/(hd|ide)/ { print "yes"; }')" ; then |
bc0d6f2d | 647 | find_modules_ide "$devpath" |
d9179777 ER |
648 | return |
649 | fi | |
650 | ||
07b09cf9 | 651 | if [[ "$devpath" == /dev/rd/* ]]; then |
7c38b114 | 652 | findmodule "DAC960" |
d9179777 ER |
653 | return |
654 | fi | |
655 | ||
07b09cf9 | 656 | if [[ "$devpath" == /dev/ida/* ]]; then |
7c38b114 | 657 | findmodule "cpqarray" |
d9179777 ER |
658 | return |
659 | fi | |
660 | ||
07b09cf9 | 661 | if [[ "$devpath" == /dev/ccis/* ]]; then |
7c38b114 | 662 | findmodule "cciss" |
d9179777 ER |
663 | return |
664 | fi | |
665 | ||
07b09cf9 | 666 | if [[ "$devpath" == /dev/ataraid/* ]]; then |
ac085800 | 667 | find_modules_ide |
7c38b114 | 668 | findmodule "ataraid" |
d4a15d5f | 669 | ataraidmodules="`awk '/ataraid_hostadapter/ && ! /^[\t ]*#/ { print $3; }' $modulefile`" |
9ae446b9 | 670 | if [ -n "$ataraidmodules" ]; then |
7c38b114 | 671 | # FIXME: think about modules compiled in kernel |
00eaa938 | 672 | die "ataraid_hostadapter alias not defined in $modulefile! Please set it and run $PROGRAM again." |
7c38b114 AF |
673 | fi |
674 | for n in $ataraidmodules; do | |
675 | findmodule "$n" | |
676 | done | |
d9179777 ER |
677 | return |
678 | fi | |
679 | ||
7c38b114 | 680 | # check to see if we need to set up a loopback filesystem |
07b09cf9 | 681 | if [[ "$devpath" == /dev/loop* ]]; then |
00eaa938 | 682 | die "Sorry, root on loop device isn't supported." |
7c38b114 AF |
683 | # TODO: rewrite for bsp and make nfs ready |
684 | if [ ! -x /sbin/losetup ]; then | |
00eaa938 | 685 | die "losetup is missing" |
7c38b114 | 686 | fi |
bc0d6f2d | 687 | key="^# $(echo $devpath | awk -F/ '{print($3);}' | tr '[a-z]' '[A-Z]'):" |
7c38b114 | 688 | if ! is_yes "`awk '/'$key'/ { print( "yes"); }' $fstab`" ; then |
bc0d6f2d | 689 | die "The root filesystem is on a $devpath, but there is no magic entry in $fstab for this device. Consult the geninitrd man page for more information" |
7c38b114 AF |
690 | fi |
691 | ||
692 | line="`awk '/'$key'/ { print $0; }' $fstab`" | |
693 | loopDev="$(echo $line | awk '{print $3}')" | |
694 | loopFs="$(echo $line | awk '{print $4}')" | |
695 | loopFile="$(echo $line | awk '{print $5}')" | |
696 | ||
697 | BASICMODULES="$BASICMODULES -loop" | |
698 | findmodule "-$loopFs" | |
699 | BASICMODULES="$BASICMODULES -${loopFs}" | |
d9179777 ER |
700 | return |
701 | fi | |
702 | ||
703 | if _check_lvm "$devpath"; then | |
bc0d6f2d | 704 | node="$devpath" |
f6536797 | 705 | |
07b09cf9 | 706 | if [ ! -f /sbin/initrd-lvm -o ! -x /sbin/lvdisplay -o ! -x /sbin/pvdisplay ]; then |
00eaa938 | 707 | die "root on LVM but /sbin/initrd-lvm, /sbin/lvdisplay and /sbin/pvdisplay not found. Please install lvm(2) and lvm(2)-initrd package and rerun $PROGRAM." |
7c38b114 | 708 | fi |
07b09cf9 | 709 | if [ -z "$LVMTOOLSVERSION" ]; then |
ac085800 | 710 | LVMTOOLSVERSION=$(/sbin/initrd-lvm vgchange --version 2>/dev/null|head -n 1|awk '{gsub("vgchange: Logical Volume Manager ",NIL); gsub("LVM version: ",NIL); gsub(/\..*/,NIL); print $1}') |
07b09cf9 | 711 | if [ -z "$LVMTOOLSVERSION" ]; then |
00eaa938 | 712 | die "Can't determine LVM tools version. Please set LVMTOOLSVERSION and rerun $PROGRAM." |
ac085800 | 713 | fi |
77bcfc68 | 714 | fi |
07b09cf9 | 715 | if [ -z "$PVDEVICES" ]; then |
f6536797 | 716 | VGVOLUME=$(/sbin/lvdisplay -c "$node" 2> /dev/null | awk -F":" ' { print $2 } ') |
d2dc16e9 | 717 | PVDEVICES=$(/sbin/pvdisplay -c 2>/dev/null | awk -F":" -v vg="$VGVOLUME" ' BEGIN { devices="" } { if ($2 == vg) { devices = devices " " $1 } } END { print devices } ') |
decd277c | 718 | fi |
07b09cf9 | 719 | if [ -n "$PVDEVICES" ]; then |
7c38b114 | 720 | for device in $PVDEVICES; do |
a8007847 | 721 | find_modules_for_device $device |
7c38b114 AF |
722 | done |
723 | else | |
00eaa938 | 724 | die "I wasn't able to find PV (via lvdisplay and pvdisplay). You can try to set PVDEVICES in /etc/sysconfig/geninitrd." |
7c38b114 | 725 | fi |
e0c502bb | 726 | if [ "$LVMTOOLSVERSION" = "2" ]; then |
ac085800 | 727 | findmodule "-dm-mod" |
e0c502bb | 728 | elif [ "$LVMTOOLSVERSION" = "1" ]; then |
ac085800 ER |
729 | findmodule "-lvm" |
730 | findmodule "-lvm-mod" | |
93d781d1 | 731 | else |
00eaa938 | 732 | die "LVM version $LVMTOOLSVERSION is not supported yet." |
93d781d1 | 733 | fi |
94769f11 | 734 | debug "LVM $LVMTOOLSVERSION enabled" |
69b1e935 | 735 | have_lvm=yes |
d9179777 | 736 | return |
7c38b114 AF |
737 | fi |
738 | } | |
739 | ||
9ed6e1db | 740 | firmware_install_module_pre() { |
c3667d07 ER |
741 | local module="$1" |
742 | local linuxrc="$2" | |
743 | local firmware_files="$3" | |
9ed6e1db | 744 | |
94769f11 | 745 | debug "Adding Firmwares ($firmware_files) to initrd for module $module" |
034fdd5d ER |
746 | inst_d /proc |
747 | inst_d /sys | |
9ed6e1db AM |
748 | # firmware not yet installed |
749 | if [ ! -f "$MNTIMAGE/lib/firmware/firmware.sh" ]; then | |
034fdd5d | 750 | inst_d /lib/firmware |
9ed6e1db AM |
751 | cat << 'EOF' >> "$MNTIMAGE/lib/firmware/firmware.sh" |
752 | #!/bin/sh -e | |
8639f99a AM |
753 | echo 1 > /sys$DEVPATH/loading |
754 | cat "/lib/firmware/$FIRMWARE" > /sys$DEVPATH/data | |
755 | echo 0 > /sys$DEVPATH/loading | |
756 | exit 0 | |
9ed6e1db | 757 | EOF |
94769f11 | 758 | chmod 755 "$MNTIMAGE/lib/firmware/firmware.sh" |
9ed6e1db AM |
759 | fi |
760 | ||
761 | for firmware in $firmware_files; do | |
dcc1b914 | 762 | inst /lib/firmware/$firmware /lib/firmware/$firmware |
9ed6e1db AM |
763 | done |
764 | ||
765 | echo "mount -t proc none /proc" >> "$linuxrc" | |
766 | echo "mount -t sysfs none /sys" >> "$linuxrc" | |
0867ab75 | 767 | echo "echo -n "/lib/firmware/firmware.sh" > /proc/sys/kernel/hotplug" >> "$linuxrc" |
9ed6e1db AM |
768 | } |
769 | ||
770 | firmware_install_module_post() { | |
c3667d07 ER |
771 | local module="$1" |
772 | local linuxrc="$2" | |
773 | local firmware_files="$3" | |
9ed6e1db AM |
774 | echo "umount /sys" >> "$linuxrc" |
775 | echo "umount /proc" >> "$linuxrc" | |
776 | } | |
777 | ||
2a5bcca9 | 778 | modules_install() { |
c3667d07 ER |
779 | local modules="$1" |
780 | local mod | |
2a5bcca9 AM |
781 | |
782 | for mod in $modules; do | |
034fdd5d ER |
783 | MODULEDIR=$(dirname "$mod") |
784 | inst_d "/lib/modules/$kernel/$MODULEDIR" | |
dd87738f | 785 | cp -a "/lib/modules/$kernel/$mod" "$MNTIMAGE/lib/modules/$kernel/$mod" |
ac085800 | 786 | gunzip "$MNTIMAGE/lib/modules/$kernel/$mod" 2> /dev/null |
2a5bcca9 AM |
787 | done |
788 | } | |
789 | ||
790 | modules_add_linuxrc() { | |
c3667d07 ER |
791 | local modules="$1" |
792 | local linuxrc="$2" | |
793 | local mod | |
ac085800 | 794 | |
2a5bcca9 | 795 | for mod in $modules; do |
87d21026 | 796 | MODULE2="`dirname "$mod"`" |
ac085800 ER |
797 | NAME2=`basename "$mod" .gz` |
798 | MODULE2=$MODULE2/$NAME2 | |
799 | module="`echo $mod | awk -F/ '{ $0=$NF } /'$modext'.*$/ { gsub(/'$modext'.*/, NIL, $0); } { print $0; }'`" | |
800 | options="`awk '{ if($1 == "options" && $2 == "'${module}'") { for(i=3;i<=NF;i++) printf("%s ",$i); }}' "$modulefile"`" | |
ffa1b198 | 801 | |
9ed6e1db AM |
802 | generic_module=$(echo "${module}" | awk ' { gsub("-", "_", $0) } { print $0; } ') |
803 | sleep_var="$(eval echo \$MODULE_${generic_module}_USLEEP)" | |
94769f11 | 804 | firmware_var="$(eval echo \$MODULE_${generic_module}_FIRMWARE)" |
2a5bcca9 | 805 | |
ac085800 ER |
806 | if [ -n "$verbose" ]; then |
807 | echo -n "Loading module [$module] " | |
07b09cf9 | 808 | if [ -n "$options" ]; then |
ac085800 ER |
809 | echo -n "with options [$options]" |
810 | else | |
811 | echo -n "without options" | |
812 | fi | |
8e598759 | 813 | if [ -n "$sleep_var" ]; then |
ba0552ce | 814 | echo " and $sleep_var usleep." |
8e598759 AM |
815 | else |
816 | echo "." | |
817 | fi | |
ac085800 ER |
818 | fi |
819 | ||
9ed6e1db AM |
820 | if [ -n "$firmware_var" ]; then |
821 | firmware_install_module_pre "$module" "$linuxrc" "$firmware_var" | |
822 | fi | |
ac085800 | 823 | echo "$insmod /lib/modules/$kernel/$MODULE2 $options" >> "$linuxrc" |
8e598759 AM |
824 | if [ -n "${sleep_var}" ]; then |
825 | echo "usleep $sleep_var" >> "$linuxrc" | |
826 | fi | |
9ed6e1db AM |
827 | if [ -n "$firmware_var" ]; then |
828 | firmware_install_module_post "$module" "$linuxrc" "$firmware_var" | |
829 | fi | |
2a5bcca9 AM |
830 | done |
831 | } | |
832 | ||
07b09cf9 | 833 | if [ -r /etc/sysconfig/geninitrd ]; then |
5dc785c7 | 834 | . /etc/sysconfig/geninitrd |
835 | fi | |
836 | ||
07b09cf9 | 837 | if [ -r /etc/sysconfig/bootsplash ]; then |
5b71959c AM |
838 | . /etc/sysconfig/bootsplash |
839 | fi | |
840 | ||
07b09cf9 | 841 | if [ -r /etc/sysconfig/fbsplash ]; then |
e4b07ddc | 842 | . /etc/sysconfig/fbsplash |
843 | fi | |
844 | ||
07b09cf9 | 845 | if [ ! -x /bin/initrd-busybox ]; then |
00eaa938 | 846 | die "/bin/initrd-busybox is missing!" |
5dc785c7 | 847 | fi |
901afd79 | 848 | |
7591cd37 | 849 | # backwards compatible |
07b09cf9 | 850 | if [ "$USE_SUSPEND2" ]; then |
7591cd37 ER |
851 | USE_TUXONICE=$USE_SUSPEND2 |
852 | echo >&2 "USE_SUSPEND2 is deprecated, use USE_TUXONICE now instead." | |
853 | fi | |
854 | ||
bb529f94 | 855 | while [ $# -gt 0 ]; do |
413878f8 | 856 | case $1 in |
6bd433bc | 857 | --fstab=*) |
c3667d07 | 858 | fstab=${1#--fstab=} |
6bd433bc AF |
859 | ;; |
860 | --fstab) | |
c3667d07 | 861 | fstab=$2 |
6bd433bc | 862 | shift |
413878f8 | 863 | ;; |
cd670d83 | 864 | --modules-conf=*) |
c3667d07 | 865 | modulefile=${1#--modules-conf=} |
cd670d83 | 866 | ;; |
57188d60 | 867 | --modules-conf) |
c3667d07 | 868 | modulefile=$2 |
cd670d83 AF |
869 | shift |
870 | ;; | |
6bd433bc | 871 | --use-raidstart|--with-raidstart) |
c3667d07 | 872 | USERAIDSTART=yes |
6bd433bc AF |
873 | ;; |
874 | --without-raidstart) | |
c3667d07 | 875 | USERAIDSTART=no |
6bd433bc | 876 | ;; |
57227e0a | 877 | --use-insmod-static|--with-insmod-static) |
c3667d07 | 878 | USEINSMODSTATIC=yes |
57227e0a AF |
879 | ;; |
880 | --without-insmod-static) | |
c3667d07 | 881 | USEINSMODSTATIC=no |
57227e0a | 882 | ;; |
ba5d09f0 | 883 | --with-bootsplash) |
c3667d07 | 884 | BOOT_SPLASH=yes |
ba5d09f0 | 885 | ;; |
5b71959c | 886 | --without-bootsplash) |
c3667d07 | 887 | BOOT_SPLASH=no |
5b71959c | 888 | ;; |
ba5d09f0 | 889 | --with-fbsplash) |
c3667d07 | 890 | FB_SPLASH=yes |
ba5d09f0 | 891 | ;; |
e4b07ddc | 892 | --without-fbsplash) |
c3667d07 | 893 | FB_SPLASH=no |
e4b07ddc | 894 | ;; |
ba5d09f0 | 895 | --with-suspend) |
c3667d07 | 896 | USE_SUSPEND=yes |
ba5d09f0 | 897 | ;; |
4ef98747 | 898 | --without-suspend) |
c3667d07 | 899 | USE_SUSPEND=no |
ba5d09f0 | 900 | ;; |
1cd2aabd | 901 | --with-suspend2 | --with-tuxonice) |
c3667d07 | 902 | USE_TUXONICE=yes |
22b0c9f4 | 903 | ;; |
1cd2aabd | 904 | --without-suspend2 | --without-tuxonice) |
c3667d07 | 905 | USE_TUXONICE=no |
2c52f208 | 906 | ;; |
e0c502bb AM |
907 | --lvmtoolsversion=|--lvmversion=) |
908 | LVMTOOLSVERSION="`echo $1 | awk -F= '{print $2;}'`" | |
77bcfc68 | 909 | ;; |
e0c502bb | 910 | --lvmtoolsversion|--lvmversion) |
c3667d07 | 911 | LVMTOOLSVERSION=$2 |
77bcfc68 AF |
912 | shift |
913 | ;; | |
1606e343 | 914 | --without-udev) |
c3667d07 | 915 | USE_UDEV=no |
1606e343 | 916 | ;; |
d7d5530e | 917 | --with-udev) |
c3667d07 | 918 | USE_UDEV=yes |
d7d5530e | 919 | ;; |
882472ae | 920 | --without-dmraid) |
c3667d07 | 921 | USE_DMRAID=no |
882472ae | 922 | ;; |
2cc3ae8b | 923 | --without-multipath) |
c3667d07 | 924 | USE_MULTPATH=no |
2cc3ae8b | 925 | ;; |
6bd433bc | 926 | --with=*) |
c3667d07 | 927 | BASICMODULES="$BASICMODULES ${1#--with=}" |
6bd433bc AF |
928 | ;; |
929 | --with) | |
930 | BASICMODULES="$BASICMODULES $2" | |
931 | shift | |
413878f8 | 932 | ;; |
bb529f94 | 933 | --version) |
9e1ceabe | 934 | echo "$PROGRAM: version $VERSION" |
413878f8 | 935 | exit 0 |
936 | ;; | |
bb529f94 | 937 | -v) |
413878f8 | 938 | verbose=-v |
939 | ;; | |
bb529f94 | 940 | --nocompress) |
c3667d07 | 941 | COMPRESS=no |
413878f8 | 942 | ;; |
bb529f94 | 943 | --ifneeded) |
413878f8 | 944 | ifneeded=1 |
945 | ;; | |
bb529f94 | 946 | -f) |
413878f8 | 947 | force=1 |
948 | ;; | |
6bd433bc | 949 | --preload=*) |
c3667d07 | 950 | PREMODS="$PREMODS ${1#--preload=}" |
6bd433bc AF |
951 | ;; |
952 | --preload) | |
72623c13 | 953 | PREMODS="$PREMODS $2" |
6bd433bc | 954 | shift |
413878f8 | 955 | ;; |
2ad94d8a | 956 | --fs=*) |
94769f11 | 957 | echo >&2 "Warning: --fs option is obsoleted. Use --initrdfs instead" |
c3667d07 | 958 | INITRDFS=${1#--fs=} |
2ad94d8a | 959 | ;; |
2ad94d8a | 960 | --fs) |
94769f11 | 961 | echo >&2 "Warning: --fs option is obsoleted. Use --initrdfs instead" |
c3667d07 | 962 | INITRDFS=$2 |
2ad94d8a | 963 | shift |
cd670d83 | 964 | ;; |
6bd433bc | 965 | --initrdfs=*) |
c3667d07 | 966 | INITRDFS=${1#--initrdfs=} |
6bd433bc | 967 | ;; |
fd2dc249 | 968 | --initrdfs) |
c3667d07 | 969 | INITRDFS=$2 |
413878f8 | 970 | shift |
971 | ;; | |
bb529f94 | 972 | --image-version) |
413878f8 | 973 | img_vers=yes |
974 | ;; | |
4f4e832d AM |
975 | --ide-only-root) |
976 | ide_only_root="yes" | |
977 | ;; | |
bb529f94 | 978 | *) |
413878f8 | 979 | if [ -z "$target" ]; then |
980 | target="$1" | |
981 | elif [ -z "$kernel" ]; then | |
982 | kernel="$1" | |
983 | else | |
984 | usage | |
985 | fi | |
986 | ;; | |
987 | esac | |
988 | ||
989 | shift | |
bb529f94 JK |
990 | done |
991 | ||
06ac05d6 | 992 | if [ -z "$target" -o -z "$kernel" ]; then |
413878f8 | 993 | usage |
06ac05d6 AF |
994 | fi |
995 | ||
0868f49f | 996 | pack_version="`echo "$kernel"|awk -F. '{print sprintf("%03d%03d",$1,$2)}'`" |
64497ebb | 997 | pack_version_long="`echo "$kernel"|awk -F. '{print sprintf("%03d%03d%03d",$1,$2,$3)}'`" |
0868f49f | 998 | |
07b09cf9 ER |
999 | if [ "x" = "x$INITRDFS" ]; then |
1000 | if [ "x" = "x$FS" ]; then | |
48413b7f | 1001 | # default value |
07b09cf9 | 1002 | if [ "$pack_version" -ge "002005" ]; then |
8d6cdf87 | 1003 | INITRDFS="initramfs" |
1004 | else | |
ac085800 | 1005 | INITRDFS="rom" |
8d6cdf87 | 1006 | fi |
48413b7f | 1007 | else |
94769f11 | 1008 | echo >&2 "Warning: FS configuration options is obsoleted. Use INITRDFS instead" |
48413b7f AM |
1009 | INITRDFS="$FS" |
1010 | fi | |
1011 | fi | |
1012 | ||
07b09cf9 | 1013 | if [ "$pack_version" -lt "002006" ]; then |
c3667d07 ER |
1014 | USE_UDEV=no |
1015 | USE_DMRAID=no | |
1606e343 | 1016 | fi |
ac085800 | 1017 | |
07b09cf9 | 1018 | if [ "$pack_version" -ge "002005" ]; then |
0868f49f | 1019 | modext=".ko" |
0b6536f5 | 1020 | insmod="insmod" |
0868f49f AF |
1021 | fi |
1022 | ||
57227e0a AF |
1023 | if is_yes "$USEINSMODSTATIC" ; then |
1024 | insmod="insmod.static" | |
b2e62ae1 | 1025 | INSMOD="/sbin/insmod.static" |
07b09cf9 | 1026 | if [ "$pack_version" -lt "002005" -a -f /sbin/insmod.static.modutils ]; then |
f7c18703 | 1027 | INSMOD="/sbin/insmod.static.modutils" |
b2e62ae1 | 1028 | fi |
07b09cf9 | 1029 | if [ ! -f "$INSMOD" ]; then |
00eaa938 | 1030 | die "insmod.static requested but /sbin/insmod.static not found!" |
b2e62ae1 | 1031 | fi |
57227e0a AF |
1032 | fi |
1033 | ||
2ad94d8a | 1034 | case "$INITRDFS" in |
8b1e4ac7 | 1035 | ext2) |
f5d71bb2 | 1036 | if [ ! -x /sbin/mke2fs ]; then |
00eaa938 | 1037 | die "/sbin/mke2fs is missing" |
8b1e4ac7 AF |
1038 | fi |
1039 | ;; | |
1040 | rom) | |
1041 | if [ ! -x /sbin/genromfs ]; then | |
00eaa938 | 1042 | die "/sbin/genromfs is missing" |
8b1e4ac7 AF |
1043 | fi |
1044 | ;; | |
1045 | cram) | |
1046 | if [ ! -x /sbin/mkcramfs ]; then | |
00eaa938 | 1047 | die "/sbin/mkcramfs is missing" |
8b1e4ac7 | 1048 | fi |
c31050f3 | 1049 | ;; |
48413b7f AM |
1050 | initramfs) |
1051 | if [ ! -x /bin/cpio ]; then | |
00eaa938 | 1052 | die "/bin/cpio is missing" |
48413b7f AM |
1053 | fi |
1054 | if [ ! -x /usr/bin/find ]; then | |
00eaa938 | 1055 | die "/usr/bin/find is missing" |
48413b7f AM |
1056 | fi |
1057 | ;; | |
8b1e4ac7 | 1058 | *) |
00eaa938 | 1059 | die "Filesystem $INITRDFS on initrd is not supported" |
8b1e4ac7 AF |
1060 | ;; |
1061 | esac | |
bb529f94 | 1062 | |
bb529f94 | 1063 | if [ -n "$img_vers" ]; then |
413878f8 | 1064 | target="$target-$kernel" |
bb529f94 JK |
1065 | fi |
1066 | ||
35164381 | 1067 | if [ -z "$force" -a -f "$target" ]; then |
00eaa938 | 1068 | die "$target already exists." |
bb529f94 JK |
1069 | fi |
1070 | ||
35164381 | 1071 | if [ ! -d "/lib/modules/$kernel" ]; then |
00eaa938 | 1072 | die "/lib/modules/$kernel is not a directory." |
bb529f94 JK |
1073 | fi |
1074 | ||
1cd2aabd ER |
1075 | if is_yes "$USE_SUSPEND" && is_yes "$USE_TUXONICE"; then |
1076 | die "Tuxonice shouldn't be used in parallel with mainline suspend!." | |
22b0c9f4 AM |
1077 | fi |
1078 | ||
e4b07ddc | 1079 | if is_yes "$FB_SPLASH"; then |
1080 | if is_yes "$BOOT_SPLASH"; then | |
00eaa938 | 1081 | die "You can't use both bootsplash and fbsplash! Please choose one." |
e4b07ddc | 1082 | elif [ "$INITRDFS" != "initramfs" ]; then |
00eaa938 | 1083 | die "FB_SPLASH works only if INITRDFS is initramfs!." |
e4b07ddc | 1084 | fi |
1085 | fi | |
1086 | ||
48762878 | 1087 | if [ ! -f /proc/mounts ]; then |
94769f11 | 1088 | echo >&2 "WARNING: /proc filesystem not mounted, may cause wrong results or failure." |
48762878 | 1089 | fi |
f121024f AM |
1090 | |
1091 | if [ "$pack_version" -lt "002005" ]; then | |
1092 | modulefile=/etc/modules.conf | |
1093 | if [ ! -f "$modulefile" -a -f /etc/conf.modules ]; then | |
1094 | modulefile=/etc/conf.modules | |
1095 | fi | |
1096 | else | |
1097 | modulefile=/etc/modprobe.conf | |
1098 | fi | |
ac085800 | 1099 | |
bb529f94 | 1100 | for n in $PREMODS; do |
35164381 | 1101 | findmodule "$n" |
bb529f94 JK |
1102 | done |
1103 | ||
7c38b114 AF |
1104 | # allow forcing loading SCSI and/or IDE modules |
1105 | if is_yes "$ADDSCSI" ; then | |
1106 | find_modules_scsi | |
bb529f94 JK |
1107 | fi |
1108 | ||
7c38b114 AF |
1109 | if is_yes "$ADDIDE" ; then |
1110 | find_modules_ide | |
cd670d83 AF |
1111 | fi |
1112 | ||
1cea325b ER |
1113 | find_root "$fstab" || exit |
1114 | debug "Using $rootdev as device for rootfs" | |
1115 | ||
a8007847 ER |
1116 | find_modules_for_device "$rootdev" |
1117 | [ -n "$rootdev_add" ] && find_modules_for_device "$rootdev_add" | |
cd670d83 | 1118 | |
7c38b114 | 1119 | findmodule "-$rootFs" |
bb529f94 | 1120 | |
c31050f3 | 1121 | for n in $BASICMODULES; do |
7d2fc5eb | 1122 | findmodule "$n" |
bb529f94 JK |
1123 | done |
1124 | ||
1cd2aabd | 1125 | if is_yes "$USE_TUXONICE"; then |
335cd101 JR |
1126 | findmodule "-lzf" |
1127 | fi | |
1128 | ||
e4b07ddc | 1129 | if is_yes "$FB_SPLASH"; then |
1130 | findmodule "-evdev" | |
1131 | fi | |
2cc3ae8b | 1132 | |
bb529f94 | 1133 | if [ -n "$ifneeded" -a -z "$MODULES" ]; then |
94769f11 | 1134 | debug "No modules are needed -- not building initrd image." |
7d2fc5eb | 1135 | exit 0 |
bb529f94 | 1136 | fi |
94769f11 | 1137 | debug "Using modules: $MODULES" |
bb529f94 | 1138 | |
35164381 SZ |
1139 | MNTIMAGE="`mktemp -d /tmp/initrd.XXXXXX`" |
1140 | IMAGE="`mktemp -u /tmp/initrd.img-XXXXXX`" | |
1141 | MNTPOINT="`mktemp -d /tmp/initrd.mnt-XXXXXX`" | |
1142 | RCFILE="$MNTIMAGE/linuxrc" | |
bb529f94 | 1143 | |
35164381 | 1144 | if [ -f "$MNTIMAGE" ]; then |
00eaa938 | 1145 | die "$MNTIMAGE already exists. Remove it and try again" |
bb529f94 JK |
1146 | fi |
1147 | ||
35164381 | 1148 | if [ -f "$IMAGE" ]; then |
00eaa938 | 1149 | die "$IMAGE already exists. Remove it and try again" |
bb529f94 JK |
1150 | fi |
1151 | ||
73edc0c1 | 1152 | mkdir -p "$MNTPOINT" |
bb529f94 | 1153 | # We don't need this directory, so let's save space |
35164381 | 1154 | rm -rf "$MNTPOINT"/lost+found |
bb529f94 | 1155 | |
034fdd5d ER |
1156 | inst_d /{lib,bin,etc,dev,loopfs,var} |
1157 | ||
2a5bcca9 | 1158 | modules_install "$MODULES" |
bb529f94 JK |
1159 | |
1160 | # mknod'ing the devices instead of copying them works both with and | |
1161 | # without devfs... | |
35164381 | 1162 | mknod "$MNTIMAGE/dev/console" c 5 1 |
eb6e37ff MM |
1163 | mknod "$MNTIMAGE/dev/null" c 1 3 |
1164 | mknod "$MNTIMAGE/dev/zero" c 1 5 | |
034fdd5d | 1165 | inst_d /dev/pts /dev/shm |
bb529f94 | 1166 | |
84670990 | 1167 | s="$RCFILE" |
566ad08b | 1168 | ln -s /linuxrc $MNTIMAGE/init |
ef66f232 | 1169 | |
dcc1b914 | 1170 | inst /bin/initrd-busybox /bin/initrd-busybox |
dab92b1d ER |
1171 | ln -s initrd-busybox $MNTIMAGE/bin/sh |
1172 | ln -s initrd-busybox $MNTIMAGE/bin/busybox # for older busyboxes who had /bin/busybox as EXEPATH | |
ef66f232 | 1173 | |
1775ba37 ER |
1174 | if is_yes "$USEINSMODSTATIC"; then |
1175 | inst "$INSMOD" /bin/insmod.static | |
57227e0a AF |
1176 | fi |
1177 | ||
f116bd42 | 1178 | cat > "$s" <<'EOF' |
84670990 | 1179 | #! /bin/sh |
f116bd42 | 1180 | mount -t proc none /proc |
c3e2550c AM |
1181 | if [ "$(awk ' /debuginitrd/ { print "yes"; } ' /proc/cmdline)" = "yes" ]; then |
1182 | export DEBUG=yes | |
1183 | set -x | |
1184 | fi | |
1185 | umount /proc | |
84670990 MM |
1186 | EOF |
1187 | chmod 755 "$s" | |
c31050f3 | 1188 | |
2a5bcca9 | 1189 | modules_add_linuxrc "$MODULES" "$s" |
fd2dc249 | 1190 | |
4e9eb79c | 1191 | # TODO: rewrite for busybox |
fd2dc249 AF |
1192 | #if [ -n "$loopDev" ]; then |
1193 | # if [ ! -d /initrd ]; then | |
1194 | # mkdir /initrd | |
1195 | # fi | |
1196 | # | |
1197 | # cp -a "$loopDev" "$MNTIMAGE/dev" | |
738c05d8 | 1198 | # cp -a "$rootdev" "$MNTIMAGE/dev" |
fd2dc249 AF |
1199 | # echo "echo Mounting device containing loopback root filesystem" >> "$RCFILE" |
1200 | # echo "mount -t $loopFs $loopDev /loopfs" >> "$RCFILE" | |
738c05d8 ER |
1201 | # echo "echo Setting up loopback device $rootdev" >> $RCFILE |
1202 | # echo "losetup $rootdev /loopfs$loopFile" >> "$RCFILE" | |
fd2dc249 | 1203 | #fi |
bb529f94 | 1204 | |
22b0c9f4 AM |
1205 | initrd_gen_suspend() { |
1206 | if [ ! -x /usr/sbin/resume ]; then | |
00eaa938 | 1207 | die "/usr/sbin/resume is missing!" |
22b0c9f4 | 1208 | fi |
034fdd5d | 1209 | inst_d /etc /dev |
22b0c9f4 | 1210 | resume_dev="$(awk '/^resume device =/ { print $4 } ' /etc/suspend.conf)" |
1775ba37 ER |
1211 | inst /dev/snapshot /dev |
1212 | inst $resume_dev /dev | |
1213 | inst /etc/suspend.conf /etc/suspend.conf | |
dcc1b914 | 1214 | inst /usr/sbin/resume /bin/resume |
22b0c9f4 AM |
1215 | echo "resume" >> "$s" |
1216 | } | |
1217 | ||
1cd2aabd | 1218 | initrd_gen_tuxonice() { |
034fdd5d | 1219 | inst_d /sys /proc |
5a61a17c | 1220 | cat << 'EOF' >> "$s" |
2b1a3707 | 1221 | mount -t proc none /proc |
050198fa | 1222 | mount -t sysfs none /sys |
5a61a17c | 1223 | if [ "$(awk ' /resume2=/ { print "yes"; } ' /proc/cmdline)" = "yes" ]; then |
2b1a3707 | 1224 | EOF |
2b1a3707 | 1225 | cat << EOF >> "$s" |
050198fa | 1226 | [ -e /proc/suspend2/do_resume ] && echo > /proc/suspend2/do_resume |
1227 | [ -e /sys/power/suspend2/do_resume ] && echo > /sys/power/suspend2/do_resume | |
5b26c57b | 1228 | [ -e /sys/power/tuxonice/do_resume ] && echo > /sys/power/tuxonice/do_resume |
2b1a3707 | 1229 | fi |
050198fa | 1230 | umount /sys |
2b1a3707 AM |
1231 | umount /proc |
1232 | EOF | |
2df2e995 | 1233 | } |
2c52f208 | 1234 | |
7915c8b1 | 1235 | # generate code to mount /dev on tmpfs and create initial nodes |
4ca8a6c5 ER |
1236 | # can be called multiple times. /dev is cleaned up (umounted) automatically at |
1237 | # the end of script. | |
b4d9d384 | 1238 | initrd_gen_tmpfs_dev() { |
dd856379 AG |
1239 | if [ "$INITRDFS" = "initramfs" ]; then |
1240 | # initramfs is read-write filesystem, no need for tmpfs | |
1241 | return | |
1242 | fi | |
7915c8b1 ER |
1243 | |
1244 | # we already generated tmpfs code; return | |
1245 | if is_yes "$tmpfs_dev"; then | |
1246 | return | |
1247 | fi | |
1248 | ||
b4d9d384 | 1249 | tmpfs_dev=yes |
9299682f ER |
1250 | |
1251 | busybox_applet mount mknod mkdir | |
d07b92a4 | 1252 | cat >> "$s" <<-EOF |
b4d9d384 ER |
1253 | : 'Creating /dev' |
1254 | mount -o mode=0755 -t tmpfs none /dev | |
1255 | mknod /dev/console c 5 1 | |
1256 | mknod /dev/null c 1 3 | |
1257 | mknod /dev/zero c 1 5 | |
1258 | mkdir /dev/pts | |
1259 | mkdir /dev/shm | |
1260 | EOF | |
1261 | } | |
1262 | ||
1606e343 | 1263 | initrd_gen_udev() { |
94769f11 | 1264 | debug "Setting up udev..." |
034fdd5d | 1265 | inst_d /sbin /proc /etc/udev /sys |
ac085800 | 1266 | |
9299682f | 1267 | if [ ! -x /sbin/initrd-udevd ]; then |
00eaa938 | 1268 | die "/sbin/initrd-udevd not present" |
9299682f ER |
1269 | fi |
1270 | ||
1775ba37 ER |
1271 | inst /sbin/initrd-udevd /sbin/udevd |
1272 | inst /etc/udev/udev.conf /etc/udev/udev.conf | |
1606e343 | 1273 | |
1606e343 | 1274 | if is_yes "$USE_UDEV"; then |
d07b92a4 | 1275 | initrd_gen_tmpfs_dev |
e4b07ddc | 1276 | cat >> "$s" <<- 'EOF' |
1277 | mount -t proc none /proc | |
1278 | mount -t sysfs none /sys | |
1279 | : 'Starting udev' | |
fdc8f895 | 1280 | /sbin/udevd --daemon |
7915c8b1 | 1281 | EOF |
e4b07ddc | 1282 | if is_yes "$PROBESTATICMODS"; then |
1775ba37 ER |
1283 | inst /sbin/initrd-udevtrigger /sbin/udevtrigger |
1284 | inst /sbin/initrd-udevsettle /sbin/udevsettle | |
7915c8b1 | 1285 | cat >> "$s" <<-'EOF' |
e4b07ddc | 1286 | /sbin/udevtrigger |
1287 | /sbin/udevsettle | |
7915c8b1 | 1288 | EOF |
e4b07ddc | 1289 | fi |
9299682f ER |
1290 | |
1291 | busybox_applet killall | |
1292 | cat >> "$s" <<-'EOF' | |
93f2f7c3 | 1293 | killall udevd |
e4b07ddc | 1294 | umount /proc |
1295 | umount /sys | |
7915c8b1 | 1296 | EOF |
1606e343 AM |
1297 | fi |
1298 | } | |
1299 | ||
2cc3ae8b | 1300 | initrd_gen_multipath() { |
2cc3ae8b ER |
1301 | inst_d /proc /sys /sbin /lib/udev |
1302 | # inst /sbin/multipathd /sbin | |
1303 | inst /sbin/kpartx /sbin | |
1304 | # inst /bin/mountpoint /bin | |
1305 | # inst /sbin/devmap_name /sbin | |
1306 | inst /sbin/multipath /sbin | |
1307 | # for udev callouts | |
1308 | inst /sbin/scsi_id /lib/udev | |
1309 | for a in /sbin/mpath*; do | |
1310 | inst $a /sbin | |
1311 | done | |
1312 | ||
1313 | if [ -d /lib64 ]; then | |
1314 | lib=/lib64 | |
1315 | else | |
1316 | lib=/lib | |
1317 | fi | |
1318 | inst_d $lib | |
1319 | inst /lib64/ld-linux-x86-64.so.2 $lib | |
aabf157c | 1320 | for a in $(ldd /sbin/kpartx /sbin/multipath | grep -v linux-gate.so | sort -u | awk '{print $3}'); do |
2cc3ae8b ER |
1321 | inst $a $lib |
1322 | done | |
aabf157c | 1323 | for a in $(ldd $MNTIMAGE$lib/lib* | grep -v linux-gate.so | sort -u | awk '{print $3}'); do |
2cc3ae8b ER |
1324 | inst $a $lib |
1325 | done | |
1326 | ||
1327 | cat <<-'EOF' >> "$s" | |
1328 | mount -t proc none /proc | |
1329 | mount -t sysfs none /sys | |
1330 | EOF | |
1331 | ||
1332 | initrd_gen_tmpfs_dev | |
1333 | initrd_gen_devices | |
1334 | ||
1335 | cat <<-'EOF' >> "$s" | |
1336 | /sbin/multipath -v 0 | |
1337 | ||
1338 | for a in /dev/mapper/*; do | |
1339 | [ $a = /dev/mapper/control ] && continue | |
1340 | kpartx -a $a | |
1341 | done | |
2cc3ae8b ER |
1342 | |
1343 | umount /sys | |
1344 | umount /proc | |
1345 | EOF | |
1346 | } | |
1347 | ||
882472ae | 1348 | initrd_gen_dmraid() { |
07b09cf9 | 1349 | if [ ! -x /sbin/dmraid-initrd ]; then |
6b013929 | 1350 | die "/sbin/dmraid-initrd is missing!" |
ac085800 ER |
1351 | fi |
1352 | ||
661cd523 | 1353 | # always make /dev on tmpfs |
7915c8b1 | 1354 | initrd_gen_tmpfs_dev |
ac085800 | 1355 | |
034fdd5d | 1356 | inst_d /sbin /sys |
1775ba37 | 1357 | inst /sbin/dmraid-initrd /sbin/dmraid |
9bb6d02a | 1358 | cat <<-EOF >> "$s" |
882472ae ER |
1359 | mount -t proc none /proc |
1360 | mount -t sysfs none /sys | |
2ffb1734 ER |
1361 | EOF |
1362 | ||
1363 | initrd_gen_devices | |
1364 | ||
1365 | cat <<-EOF >> "$s" | |
882472ae ER |
1366 | # 2 secs was enough for my system to initialize. but really this is udev issue? |
1367 | usleep 2000000 | |
e5d02b56 | 1368 | : 'Activating Device-Mapper RAID(s)' |
882472ae ER |
1369 | /sbin/dmraid -ay -i |
1370 | umount /sys | |
1371 | umount /proc | |
1372 | EOF | |
1373 | } | |
1374 | ||
8bd582f1 ER |
1375 | # Generates /dev nodes based on /proc/partitions information. |
1376 | # Needs /proc mounted. | |
1377 | # Can be called multiple times. | |
2ffb1734 | 1378 | initrd_gen_devices() { |
8bd582f1 ER |
1379 | if is_yes "$proc_partitions"; then |
1380 | return | |
1381 | fi | |
1382 | proc_partitions=yes | |
1383 | ||
06ae4e5a | 1384 | cat <<-'EOF' >> "$s" |
2ffb1734 ER |
1385 | : 'Making device nodes' |
1386 | # ignore first two lines, header, empty line and process rest | |
1387 | cat /proc/partitions | (read b; read b; while read major minor blocks dev rest; do | |
06ae4e5a ER |
1388 | node=/dev/$dev |
1389 | mkdir -p ${node%/*} | |
1390 | mknod $node b $major $minor | |
2ffb1734 ER |
1391 | done |
1392 | ) | |
1393 | EOF | |
1394 | } | |
1395 | ||
df738638 | 1396 | initrd_gen_md() { |
94769f11 | 1397 | debug "Setting up mdadm..." |
ac085800 | 1398 | |
00eaa938 ER |
1399 | if [ ! -x /sbin/mdadm -o ! -x /sbin/initrd-mdassemble ]; then |
1400 | die "/sbin/mdadm or /sbin/initrd-mdassemble is missing!" | |
d3fa6ec7 | 1401 | fi |
994eb509 | 1402 | |
dcc1b914 | 1403 | inst /sbin/initrd-mdassemble /bin/mdassemble |
6cca3165 | 1404 | |
4e9eb79c | 1405 | # LVM on RAID case |
6cca3165 AM |
1406 | dev_list_extra=$(awk '/^DEVICE / { for (i=2; i<=NF; i++) { printf "%s ", $i; }; } ' /etc/mdadm.conf) |
1407 | for ex_dev in $dev_list_extra; do | |
1408 | echo "DEVICE $ex_dev" >> "$MNTIMAGE/etc/mdadm.conf" | |
1409 | done | |
ac085800 | 1410 | do_md0=1 |
4e9eb79c | 1411 | for nr in `seq 1 $rootdev_nr`; do |
ac085800 ER |
1412 | eval cr_rootdev="\$rootdev${nr}" |
1413 | eval cr_dev_list="\$dev_list${nr}" | |
94769f11 | 1414 | debug echo "Setting up array ($cr_rootdev = $cr_dev_list)" |
ac085800 ER |
1415 | |
1416 | [ "$cr_rootdev" = "/dev/md0" ] && do_md0=0 | |
1417 | ||
1418 | echo "DEVICE $cr_dev_list" >> "$MNTIMAGE/etc/mdadm.conf" | |
1419 | cr_dev_list_md="$(echo "$cr_dev_list" | xargs | awk ' { gsub(/ +/,",",$0); print $0; }')" | |
a46f8bda | 1420 | cr_md_conf=$(/sbin/mdadm --detail --brief --config=/etc/mdadm.conf $cr_rootdev | awk ' { gsub(/spares=[0-9]+/, "", $0); print $0; }') |
ac085800 ER |
1421 | if [ -n "$cr_md_conf" ]; then |
1422 | echo "$cr_md_conf" >> "$MNTIMAGE/etc/mdadm.conf" | |
1423 | else | |
1424 | echo "ARRAY $cr_rootdev devices=$cr_dev_list_md" >> "$MNTIMAGE/etc/mdadm.conf" | |
1425 | fi | |
1426 | ||
1427 | for f in $cr_dev_list $cr_rootdev $dev_list_extra; do | |
1428 | # mkdir in case of devfs name | |
034fdd5d | 1429 | inst_d $(dirname $f) |
ac085800 | 1430 | [ -e "$MNTIMAGE/$f" ] && continue |
ac085800 | 1431 | # this works fine with and without devfs |
1775ba37 | 1432 | inst $f $f |
ac085800 | 1433 | done |
ef66f232 | 1434 | done |
4e9eb79c | 1435 | |
6cca3165 | 1436 | echo "mdassemble" >> "$s" |
33d24e12 | 1437 | |
4e9eb79c | 1438 | # needed to determine md-version |
07b09cf9 | 1439 | if [ "$do_md0" -eq 1 ]; then |
4e9eb79c AM |
1440 | mknod $MNTIMAGE/dev/md0 b 9 0 |
1441 | fi | |
2df2e995 | 1442 | } |
2968c9dd | 1443 | |
2df2e995 | 1444 | initrd_gen_nfs() { |
5a61a17c | 1445 | # use root=/dev/ram0 init=/linuxrc when starting kernel or you will |
51447ab3 | 1446 | # have problems like init(XX) being child process of swapper(1). |
94769f11 | 1447 | debug "Adding rootfs on NFS support to initrd (dhcp)" |
7fc1e5bd | 1448 | mknod "$MNTIMAGE/dev/urandom" c 1 9 |
5c4cec75 | 1449 | mkdir "$MNTIMAGE/newroot" |
7d400dbe | 1450 | mkdir "$MNTIMAGE/proc" |
5c4cec75 AM |
1451 | echo "ifconfig lo 127.0.0.1 up" >> "$s" |
1452 | echo "route add -net 127.0.0.0 netmask 255.0.0.0 lo" >> "$s" | |
1453 | echo "ifconfig eth0 0.0.0.0 up" >> "$s" | |
ac085800 | 1454 | echo "udhcpc -i eth0 -f -q -s /bin/setdhcp" >> "$s" |
5a61a17c | 1455 | cat << 'EOF' > "$MNTIMAGE/bin/setdhcp" |
5c4cec75 | 1456 | #!/bin/sh |
5a61a17c ER |
1457 | [ "$1" != "bound" ] && exit |
1458 | [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" | |
1459 | [ -n "$subnet" ] && NETMASK="netmask $subnet" | |
5a61a17c | 1460 | ifconfig $interface $ip $BROADCAST $NETMASK up |
5a61a17c | 1461 | if [ -n "$router" ]; then |
ac085800 | 1462 | for r in $router; do |
ac085800 | 1463 | route add default gw $r dev $interface |
ac085800 | 1464 | done |
5c4cec75 | 1465 | fi |
7d400dbe ER |
1466 | |
1467 | mount -t proc none /proc | |
5a61a17c ER |
1468 | for o in $(cat /proc/cmdline); do |
1469 | case $o in | |
7d400dbe | 1470 | nfsroot=*) |
5a61a17c | 1471 | rootpath=${o#nfsroot=} |
7d400dbe ER |
1472 | ;; |
1473 | esac | |
1474 | done | |
1475 | umount /proc | |
1476 | ||
5a61a17c | 1477 | if [ -n "$rootpath" ]; then |
ac085800 | 1478 | mount -n -t nfs -o ro,nolock,posix,tcp,wsize=8192,rsize=8192 $rootpath /newroot |
5c4cec75 | 1479 | else |
ac085800 ER |
1480 | echo "Missing rootpath in what DHCP server sent to us. Failing..." |
1481 | echo "All seen variables are listed below:" | |
1482 | set | |
5c4cec75 AM |
1483 | fi |
1484 | EOF | |
1485 | chmod 755 "$MNTIMAGE/bin/setdhcp" | |
1486 | echo "cd /newroot" >> "$s" | |
c52ba2fe | 1487 | echo "pivot_root . initrd" >> "$s" |
d4a8e40e | 1488 | echo "[ -x /sbin/chroot ] && exec /sbin/chroot . /sbin/init -i < dev/console > dev/console 2>&1" >> "$s" |
c52ba2fe | 1489 | echo "exec /usr/sbin/chroot . /sbin/init -i < dev/console > dev/console 2>&1" >> "$s" |
2df2e995 | 1490 | } |
6fe19d5b | 1491 | |
2df2e995 | 1492 | initrd_gen_lvm() { |
94769f11 | 1493 | debug "Adding LVM support to initrd" |
1775ba37 | 1494 | inst /sbin/initrd-lvm /bin/lvm |
034fdd5d | 1495 | inst_d /etc /tmp /proc /newroot |
e8d178ff ER |
1496 | |
1497 | # always make /dev on tmpfs for LVM2 | |
7915c8b1 | 1498 | if [ "$LVMTOOLSVERSION" = "2" ]; then |
d07b92a4 | 1499 | initrd_gen_tmpfs_dev |
e8d178ff ER |
1500 | fi |
1501 | ||
b4d9d384 | 1502 | if ! is_yes "$tmpfs_dev"; then |
034fdd5d | 1503 | inst_d /dev/mapper |
afaefcb5 | 1504 | mknod $MNTIMAGE/dev/mapper/control c 10 63 |
b007399c | 1505 | for device in $PVDEVICES; do |
df738638 | 1506 | # if LVM on RAID then device might be copied already in gen_md |
13b29c8f | 1507 | [ -e "$MNTIMAGE/dev/$(basename $device)" ] && continue |
1775ba37 | 1508 | inst $device /dev |
b007399c | 1509 | done |
afaefcb5 | 1510 | fi |
84670990 | 1511 | echo "mount -t proc none /proc" >> "$s" |
b78e6497 | 1512 | echo "mount -t tmpfs none /tmp" >> "$s" |
07b09cf9 | 1513 | if [ "$LVMTOOLSVERSION" = "1" ]; then |
cff3058d | 1514 | echo "lvm vgscan -T" >> "$s" |
90b5b05a | 1515 | echo "lvm vgchange -T -a y $VGVOLUME" >> "$s" |
4e1e40bd | 1516 | echo "umount /tmp" >> "$s" |
ac085800 | 1517 | # fail to umount |
ac085800 | 1518 | echo "umount /proc" >> "$s" |
cff3058d | 1519 | else |
ac085800 ER |
1520 | echo "cat /etc/lvm.conf > /tmp/lvm.conf" >> "$s" |
1521 | echo "global {" > "$MNTIMAGE/etc/lvm.conf" | |
f34c76a3 AM |
1522 | echo " locking_type = 0" >> "$MNTIMAGE/etc/lvm.conf" |
1523 | echo " locking_dir = \"/tmp\"" >> "$MNTIMAGE/etc/lvm.conf" | |
1524 | echo "}" >> "$MNTIMAGE/etc/lvm.conf" | |
ac085800 | 1525 | echo "devices {" >> "$MNTIMAGE/etc/lvm.conf" |
8fb0a4d2 | 1526 | echo " sysfs_scan=0" >> "$MNTIMAGE/etc/lvm.conf" |
df738638 | 1527 | if is_yes "$have_md"; then |
ac085800 | 1528 | echo " md_component_detection = 1" >> "$MNTIMAGE/etc/lvm.conf" |
f34c76a3 | 1529 | fi |
c083ae23 | 1530 | if is_yes "$have_dmraid" || is_yes "$have_multipath"; then |
3938fd10 | 1531 | echo ' types = [ "device-mapper", 254 ]' >> "$MNTIMAGE/etc/lvm.conf" |
2cc3ae8b | 1532 | fi |
6b013929 ER |
1533 | if [ "$lvm_ignore_devices" ]; then |
1534 | # TODO: think of merging with lvm dumpconfig output | |
2cc3ae8b | 1535 | echo ' filter = [' >> "$MNTIMAGE/etc/lvm.conf" |
6b013929 ER |
1536 | local dev |
1537 | for dev in $lvm_ignore_devices; do | |
1538 | debug "LVM2: ignore device $dev" | |
2cc3ae8b ER |
1539 | printf ' "r|^%s.*|",\n' $dev |
1540 | done >> "$MNTIMAGE/etc/lvm.conf" | |
1541 | echo ']' >> "$MNTIMAGE/etc/lvm.conf" | |
3938fd10 | 1542 | fi |
6b013929 | 1543 | # XXX filter= must be on one line! |
f34c76a3 AM |
1544 | lvm dumpconfig | awk '/filter=/' >> "$MNTIMAGE/etc/lvm.conf" |
1545 | echo "}" >> "$MNTIMAGE/etc/lvm.conf" | |
be2f3ecc | 1546 | |
2ffb1734 ER |
1547 | initrd_gen_devices |
1548 | ||
c79b26a6 | 1549 | cat <<-EOF >> "$s" |
e8d178ff | 1550 | |
dd87738f ER |
1551 | # disable noise from lvm accessing devices that aren't ready. |
1552 | printk=\$(cat /proc/sys/kernel/printk) | |
e8d178ff | 1553 | echo 0 > /proc/sys/kernel/printk |
dd87738f | 1554 | |
2cc3ae8b | 1555 | export LVM_SYSTEM_DIR=/tmp |
dd87738f | 1556 | : 'Scanning for Volume Groups' |
2cc3ae8b | 1557 | lvm vgscan --mknodes --ignorelockingfailure 2>/dev/null |
e8d178ff | 1558 | |
c79b26a6 | 1559 | : 'Activating Volume Groups' |
2cc3ae8b | 1560 | lvm vgchange --ignorelockingfailure -a y $VGVOLUME 2>/dev/null |
be2f3ecc | 1561 | |
dd87738f ER |
1562 | echo "\$printk" > /proc/sys/kernel/printk |
1563 | ||
91ed0242 | 1564 | # Find out major/minor |
2cc3ae8b | 1565 | majmin="\$(lvm lvdisplay --ignorelockingfailure -c $rootdev 2>/dev/null)" |
c79b26a6 ER |
1566 | majmin="\${majmin#*/}" |
1567 | majmin="\${majmin#*:*:*:*:*:*:*:*:*:*:*:*}" | |
1568 | major="\${majmin%:*}" | |
1569 | minor="\${majmin#*:}" | |
91ed0242 | 1570 | # Pass it to kernel |
c79b26a6 ER |
1571 | val=\$((256 * \$major + \$minor)) |
1572 | echo \$val > /proc/sys/kernel/real-root-dev | |
1573 | umount /tmp | |
1574 | umount /proc | |
1575 | EOF | |
cff3058d | 1576 | fi |
2df2e995 AM |
1577 | } |
1578 | ||
2b1a3707 | 1579 | initrd_gen_procdata() { |
94769f11 | 1580 | debug "Adding rootfs finding based on root= option support." |
034fdd5d | 1581 | inst_d /proc |
5a61a17c | 1582 | cat << 'EOF' >> "$s" |
2b1a3707 | 1583 | mount -t proc none /proc |
5a61a17c ER |
1584 | root="$(busybox awk ' /root=\/dev\// { gsub(/.*root=\/dev\//,NIL,$0); gsub(/ .*/,NIL,$0); print $0; } ' /proc/cmdline)" |
1585 | if [ -n "$root" ]; then | |
ac085800 ER |
1586 | rootnr="$(busybox awk -v root="$root" ' { if ($4 == root) { print 256*$1+$2; } } ' /proc/partitions)" |
1587 | if [ -n "$rootnr" ]; then | |
1588 | echo "$rootnr" > /proc/sys/kernel/real-root-dev | |
1589 | fi | |
2b1a3707 | 1590 | fi |
9d949203 | 1591 | umount /proc |
2b1a3707 AM |
1592 | EOF |
1593 | } | |
1594 | ||
2df2e995 | 1595 | # main generation |
1606e343 AM |
1596 | |
1597 | if is_yes "$USE_UDEV"; then | |
1598 | initrd_gen_udev | |
1599 | fi | |
1600 | ||
2ce7656a | 1601 | if is_yes "$USE_SUSPEND"; then |
22b0c9f4 AM |
1602 | initrd_gen_suspend |
1603 | fi | |
1604 | ||
1cd2aabd ER |
1605 | if is_yes "$USE_TUXONICE"; then |
1606 | initrd_gen_tuxonice | |
2df2e995 AM |
1607 | fi |
1608 | ||
c083ae23 | 1609 | if is_yes "$have_dmraid" ]; then |
882472ae ER |
1610 | initrd_gen_dmraid |
1611 | fi | |
1612 | ||
c083ae23 | 1613 | if is_yes "$have_multipath"; then |
2cc3ae8b ER |
1614 | initrd_gen_multipath |
1615 | fi | |
1616 | ||
69b1e935 | 1617 | if is_yes "$have_nfs"; then |
2df2e995 | 1618 | initrd_gen_nfs |
df738638 ER |
1619 | elif is_yes "$USERAIDSTART" && is_yes "$have_md"; then |
1620 | initrd_gen_md | |
69b1e935 | 1621 | if is_yes "$have_lvm"; then |
2df2e995 | 1622 | initrd_gen_lvm |
bfea009a AM |
1623 | else |
1624 | initrd_gen_procdata | |
2df2e995 | 1625 | fi |
69b1e935 | 1626 | elif is_yes "$have_lvm"; then |
2df2e995 | 1627 | initrd_gen_lvm |
2b1a3707 AM |
1628 | else |
1629 | initrd_gen_procdata | |
7c38b114 AF |
1630 | fi |
1631 | ||
737d5a0e | 1632 | # finally umount /dev if it was on tmpfs |
661cd523 ER |
1633 | if is_yes "$tmpfs_dev"; then |
1634 | cat <<-EOF >> "$s" | |
1635 | umount /dev | |
1636 | EOF | |
1637 | tmpfs_dev=no | |
1638 | fi | |
1639 | ||
5101a385 | 1640 | # additional devs always needed |
1775ba37 | 1641 | [ ! -e "$MNTIMAGE/$rootdev_add" ] && inst $rootdev_add /dev |
5101a385 | 1642 | |
f8f9e56d | 1643 | if [ "$INITRDFS" = "initramfs" ]; then |
034fdd5d | 1644 | inst_d /newroot |
1775ba37 | 1645 | [ ! -e "$MNTIMAGE/$rootdev" ] && inst $rootdev /dev |
e4b07ddc | 1646 | # Parsing root parameter |
81d53704 | 1647 | # We support passing root as hda3 /dev/hda3 0303 0x0303 and 303 |
e4b07ddc | 1648 | cat << 'EOF' >> "$s" |
e4b07ddc | 1649 | mount -t proc none /proc |
df391e6f | 1650 | |
1651 | CMDLINE="$(busybox cat /proc/cmdline)" | |
1652 | eval "$(busybox awk -v c="$CMDLINE" ' | |
1653 | BEGIN { | |
92ed99b6 | 1654 | num_pattern_short = "[0-9a-f][0-9a-f][0-9a-f]"; |
1655 | num_pattern = "[0-9a-f]" num_pattern_short; | |
df391e6f | 1656 | dev_pattern = "[hms][a-z][a-z]([0-9])+"; |
1657 | partition = "no_partition_found"; | |
1658 | min = -1; maj = -1; | |
1659 | ||
1660 | gsub(/.*root=/,NIL,c); | |
1661 | gsub(/ .*/,NIL,c); | |
1662 | ||
1663 | sub("^0x", "", c); | |
1664 | if (c ~ "^" num_pattern_short "$") sub("^", "0", c); | |
1665 | if (c ~ "^" num_pattern "$") { | |
92ed99b6 | 1666 | maj = sprintf("%s",substr(c,1,2)); |
1667 | min = sprintf("%s",substr(c,3)); | |
df391e6f | 1668 | } |
1669 | if (c ~ "^\/dev\/" dev_pattern "$") sub("^/dev/","", c); | |
1670 | if (c ~ "^" dev_pattern "$") partition = c; | |
1671 | } | |
1672 | ||
1673 | $4 ~ partition { maj = $1; min = $2; } | |
1674 | $1 ~ maj && $2 ~ min { partition = $4; } | |
1675 | ||
1676 | END { | |
92ed99b6 | 1677 | print sprintf("device=/dev/%s\nmaj=%s\nmin=%s", |
df391e6f | 1678 | partition, maj, min); |
1679 | } | |
1680 | ' /proc/partitions)" | |
e620b426 | 1681 | if [ "$device" != '/dev/no_partition_found' -a ! -b $device ]; then |
e4b07ddc | 1682 | mknod $device b $maj $min |
1683 | fi | |
1684 | EOF | |
92a4990b ER |
1685 | |
1686 | busybox_applet switch_root | |
e4b07ddc | 1687 | cat << EOF >> "$s" |
07b09cf9 | 1688 | if [ "\$device" = '/dev/no_partition_found' ]; then |
e620b426 AG |
1689 | device="$rootdev" |
1690 | fi | |
1691 | ||
51dc11ca | 1692 | mount -t $rootFs -r \$device /newroot |
a020063b | 1693 | init="\$(busybox awk ' /init=\// { gsub(/.*init=/,NIL,\$0); gsub(/ .*/,NIL,\$0); print \$0; } ' /proc/cmdline )" |
1694 | if [ -z "\$init" -o ! -x "/newroot\$init" ]; then | |
1695 | init=/sbin/init | |
1696 | fi | |
e4b07ddc | 1697 | umount /proc |
a020063b | 1698 | exec switch_root /newroot \$init |
f1a5a1b0 | 1699 | |
1700 | echo "Error ! initramfs should not reach this place." | |
1701 | echo "It probably means you've got old version of busybox, with broken" | |
1702 | echo "initramfs support. Trying to boot anyway, but won't promise anything." | |
1703 | ||
1704 | exec chroot /newroot \$init | |
1705 | ||
1706 | echo "Failed to chroot !" | |
e4b07ddc | 1707 | EOF |
f8f9e56d AM |
1708 | # we need real file, not symlink |
1709 | rm -f $MNTIMAGE/init | |
1710 | cp -a $MNTIMAGE/linuxrc $MNTIMAGE/init | |
1711 | fi | |
1712 | ||
35164381 | 1713 | chmod +x "$RCFILE" |
bb529f94 | 1714 | |
35164381 | 1715 | (cd "$MNTIMAGE"; tar cf - .) | (cd "$MNTPOINT"; tar xf -) |
bb529f94 | 1716 | |
2ad94d8a | 1717 | case "$INITRDFS" in |
8b1e4ac7 | 1718 | ext2) |
94d430a8 | 1719 | IMAGESIZE=$(du -ks $MNTPOINT | awk '{print int(($1+1023+512)/1024)*1024}') |
94769f11 | 1720 | debug "ext2 image size: $IMAGESIZE ($MNTPOINT)" |
73edc0c1 | 1721 | if [ "$IMAGESIZE" -gt 4096 ]; then |
7758e45c | 1722 | echo >&2 "$PROGRAM: Your image size is larger than 4096, Be sure to boot kernel with ramdisk_size=$IMAGESIZE!" |
73edc0c1 ER |
1723 | fi |
1724 | ||
1725 | dd if=/dev/zero of="$IMAGE" bs=1k count="$IMAGESIZE" 2> /dev/null | |
1726 | mke2fs -q -F -b 1024 -m 0 "$IMAGE" 2>/dev/null 1>&2 | |
1727 | tune2fs -i 0 "$IMAGE" >/dev/null 2>&1 | |
1728 | ||
1729 | tmpmnt="`mktemp -d /tmp/initrd.mnte2-XXXXXX`" | |
1730 | mount -o loop -t ext2 "$IMAGE" "$tmpmnt" | |
1731 | ||
1732 | (cd "$MNTPOINT"; tar cf - .) | (cd "$tmpmnt"; tar xf -) | |
1733 | ||
35164381 | 1734 | umount "$IMAGE" |
8b1e4ac7 AF |
1735 | ;; |
1736 | rom) | |
1737 | genromfs -f "$IMAGE" -d "$MNTPOINT" -V "PLD initrd for kernel $kernel" | |
cdf1e7c9 | 1738 | IMAGESIZE=$(stat -c %s $IMAGE | awk '{print int((($1/1024)+1023)/1024)*1024}') |
a8b63949 ER |
1739 | debug "romfs image size: $IMAGESIZE ($IMAGE)" |
1740 | if [ "$IMAGESIZE" -gt 4096 ]; then | |
7758e45c | 1741 | echo >&2 "$PROGRAM: Your image size is larger than 4096, Be sure to boot kernel with ramdisk_size=$IMAGESIZE!" |
a8b63949 | 1742 | fi |
8b1e4ac7 AF |
1743 | ;; |
1744 | cram) | |
1745 | mkcramfs "$MNTPOINT" "$IMAGE" | |
8b1e4ac7 | 1746 | ;; |
48413b7f | 1747 | initramfs) |
26939e7a | 1748 | (cd $MNTPOINT ; find . | cpio --quiet -H newc -o > "$IMAGE") |
48413b7f | 1749 | ;; |
8b1e4ac7 | 1750 | *) |
7758e45c | 1751 | echo "Filesystem $INITRDFS not supported by $PROGRAM"; |
c31050f3 | 1752 | esac |
bb529f94 JK |
1753 | |
1754 | if is_yes "$COMPRESS" ; then | |
7d2fc5eb | 1755 | gzip -9 < "$IMAGE" > "$target" |
bb529f94 | 1756 | else |
7d2fc5eb | 1757 | cp -a "$IMAGE" "$target" |
bb529f94 | 1758 | fi |
5b71959c AM |
1759 | |
1760 | if is_yes "$BOOT_SPLASH"; then | |
1761 | if [ ! -x /bin/splash.bin ]; then | |
94769f11 | 1762 | echo >&2 "Failed to execute /bin/splash.bin. Is bootsplash package installed?" |
5b71959c | 1763 | elif [ -z "$THEME" ]; then |
94769f11 ER |
1764 | echo >&2 "Please configure your /etc/sysconfig/bootsplash first." |
1765 | echo >&2 "Generating bootsplashes skipped." | |
5b71959c | 1766 | else |
ac085800 ER |
1767 | if [ -n "$BOOT_SPLASH_RESOLUTIONS" ]; then |
1768 | for res in $BOOT_SPLASH_RESOLUTIONS; do | |
1769 | if [ -f "/etc/bootsplash/themes/$THEME/config/bootsplash-$res.cfg" ]; then | |
1770 | /bin/splash.bin -s -f "/etc/bootsplash/themes/$THEME/config/bootsplash-$res.cfg" >> "$target" && \ | |
94769f11 | 1771 | debug "Added $res $THEME theme to initrd." |
ac085800 | 1772 | else |
94769f11 | 1773 | echo >&2 "/etc/bootsplash/themes/$THEME/config/bootsplash-$res.cfg doesn't exist, skipped" |
ac085800 ER |
1774 | fi |
1775 | done | |
1776 | else | |
94769f11 ER |
1777 | echo >&2 "No BOOT_SPLASH_RESOLUTIONS specified in /etc/sysconfig/bootsplash." |
1778 | echo >&2 "Not adding bootsplash to initrd." | |
ac085800 | 1779 | fi |
5b71959c AM |
1780 | fi |
1781 | fi | |
1782 | ||
e4b07ddc | 1783 | if is_yes "$FB_SPLASH"; then |
1784 | if [ ! -x /usr/bin/splash_geninitramfs ]; then | |
1785 | echo >&2 "Failed to execute /usr/bin/splash_geninitramfs. Is splashutils package installed?" | |
1786 | elif [ -z "$SPLASH_THEME" ]; then | |
1787 | echo >&2 "Please configure your /etc/sysconfig/fbsplash first." | |
1788 | echo >&2 "Generating fbsplashes skipped." | |
1789 | else | |
1790 | if [ -n "$FB_SPLASH_RESOLUTIONS" ]; then | |
1791 | for res in $FB_SPLASH_RESOLUTIONS; do | |
1792 | if [ -f "/etc/splash/$SPLASH_THEME/$res.cfg" ]; then | |
1793 | /usr/bin/splash_geninitramfs -a $target -r $res $SPLASH_THEME && \ | |
1794 | debug "Added $res $SPLASH_THEME theme to initramfs." | |
1795 | else | |
1796 | echo >&2 "/etc/splash/$SPLASH_THEME/$res.cfg doesn't exist, skipped" | |
1797 | fi | |
1798 | done | |
1799 | else | |
1800 | echo >&2 "No FB_SPLASH_RESOLUTIONS specified in /etc/sysconfig/fbsplash." | |
1801 | echo >&2 "Not adding fbsplash to initramfs." | |
1802 | fi | |
1803 | fi | |
1804 | fi | |
1805 | ||
35164381 | 1806 | rm -rf "$MNTIMAGE" "$MNTPOINT" "$IMAGE" |
ac085800 ER |
1807 | |
1808 | # vim:ts=4:sw=4:noet:fdm=marker |