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