]> git.pld-linux.org Git - projects/geninitrd.git/blob - geninitrd
Put information which devices belong to which array when having multiple raid arrays...
[projects/geninitrd.git] / geninitrd
1 #!/bin/sh
2
3 # geninitrd
4 #
5 #       by Jacek Konieczny <jajcus@pld-linux.org>
6 #
7 # based on mkinitrd from RedHat
8
9 RCSID='$Id$'
10 PATH=/sbin:$PATH
11 export PATH
12
13 VERSION="`echo "$RCSID"|awk '{print $3}'`"
14
15 . /etc/rc.d/init.d/functions
16
17 COMPRESS="yes"
18 # INITRDFS is set later (catch obsoleted FS option)
19 #INITRDFS="rom"
20 USERAIDSTART="yes"
21 USEMDADMSTATIC="no"
22 USEINSMODSTATIC="no"
23 USESUSPEND="yes"
24 uselvm="no"
25 usenfs="no"
26 # it should be safe to remove scsi_mod from here, but I'm not sure...
27 PRESCSIMODS="-scsi_mod unknown -sd_mod"
28 PREIDEMODS="-ide-core unknown -ide-detect -ide-disk"
29 PREIDEMODSOLD="-ide-probe -ide-probe-mod -ide-disk"
30 SUSPENDMODS="-suspend2_core -suspend2_lzf -suspend2_block_io -suspend2_swap -suspend_core -suspend_text -suspend_lzf -suspend_block_io -suspend_swap"
31 target=""
32 kernel=""
33 force=""
34 verbose=""
35 MODULES=""
36 img_vers=""
37 modulefile=""
38 raidtab="/etc/raidtab"
39 fstab="/etc/fstab"
40 insmod="insmod"
41 modext=".o"
42 rootdev_nr=0
43 # default bootsplash is off, if it have to be on, install bootsplash package
44 BOOT_SPLASH=no
45
46 usage () {
47         echo "usage: `basename $0` [--version] [-v] [-f] [--ifneeded] [--preload <module>]" 
48         echo "       [--with=<module>] [--image-version] [--fstab=<fstab>] [--nocompress]" 
49         echo "       [--initrdfs=rom|ext2|cram] [--modules-conf=<modules.conf>]" 
50         echo "       [--with-raidstart] [--without-raidstart] [--with-insmod-static]" 
51         echo "       [--without-bootsplash] [--lvmtoolsversion=1|2]" 
52         echo "       <initrd-image> <kernel-version>" 
53         echo "       (ex: `basename $0` /boot/initrd-2.2.5-15.img 2.2.5-15)" 
54         exit 1
55 }
56
57
58 my_dirname() {
59         echo $1|awk -F/ '{print substr($0, 0, length($0) - length($NF));}'
60 }
61
62 find_depmod () {
63         typeset mods module f level depfile first
64
65         depfile=/lib/modules/$kernel/modules.dep
66         
67         if [ -f $depfile ] ; then
68                 : ok
69         else
70                 echo "Error: no $depfile ! Run depmod and rerun geninitrd." 1>&2
71                 exit 1
72         fi
73         
74         # prepend / if no path given, append $modext.gz if not given,
75         # quote /
76         origmodule="$2"
77         module=$(echo "$2" | \
78                  awk '/\// {print;next} {print "/" $0}' | \
79                  awk '/\./ {print;next} {print $0 "'$modext'.gz"}' |
80                  awk '{gsub("/","\\/");print}')
81         mods=$(awk '
82 BEGIN { here = 0 }
83 /'"$module"':(.*)/ { gsub(/:/," "); gsub(/\\/," "); print; here = 1; next }
84 /:/ { here = 0 }
85 /(.*)/ { gsub(/\\/," "); if (here) print }
86 ' $depfile | xargs)
87
88         # fallback to $modext
89         if [ "$mods" = "" ] ; then
90             module=$(echo "$module" | \
91                     awk '{gsub("\'$modext'\.gz$","\'$modext'",$0);print}')
92         fi 
93         mods=$(awk '
94 BEGIN { here = 0 }
95 /'"$module"':(.*)/ { gsub(/:/," "); gsub(/\\/," "); print; here = 1; next }
96 /:/ { here = 0 }
97 /(.*)/ { gsub(/\\/," "); if (here) print }
98 ' $depfile | xargs)
99
100         if [ "$mods" = "" ] ; then
101                 if [ "$1" != silent ] ; then
102                         echo "$origmodule: module not found in $depfile" 1>&2
103                 fi
104                 if ! is_no "$EXIT_IF_MISSING" ; then 
105                         exit 1
106                 else
107                         echo "If $origmodule isn't compiled in kernel then this initrd may not start your system". 1>&2
108                 fi
109         fi
110         
111         level=$3
112         if [ "$level" = "" ] ; then
113                 level=0
114         fi
115         level=$(awk "BEGIN{print $level + 1}")
116         if [ $level -gt 20 ] ; then
117                 echo "$origmodule: cycle in $depfile" 1>&2
118                 exit 1
119         fi
120         
121         first=
122         for f in $mods ; do
123                 if [ "$first" = "" ] ; then
124                         first=$f
125                 else
126                         find_depmod $1 $f $level
127                 fi
128         done
129         
130         echo $first
131 }
132
133 addmodule() {
134         fmPath=$1
135         skiperrors=$2
136
137         if [ ! -f "/lib/modules/$kernel/$fmPath" ]; then
138                 if [ -n "$skiperrors" ]; then
139                         return
140                 fi
141
142                 echo "module $fmPath present in modules.dep, but not in filesystem (kernel = $kernel)" 1>&2
143                 exit 1
144         fi
145
146         # only need to add each module once
147         # quote /
148         tmpFmPath=$(echo $fmPath | awk '{gsub(/\//,"\\/");print}')
149         if echo "$MODULES" | awk '/'"$tmpFmPath"'/ {exit 1}' ; then
150                 MODULES="$MODULES $fmPath"
151         fi
152 }
153
154 findmodule() {
155         skiperrors=""
156         modName=$1
157
158         if [ "$(echo $modName | awk '{print(substr($0,1,1));}')" = "-" ]; then
159                 skiperrors=1
160                 modName="$(echo $modName | awk '{print(substr($0,2));}')"
161         fi
162
163         # what's that?
164         if [ "$modName" = "pluto" ]; then
165                 findmodule fc4
166                 findmodule soc
167         fi
168         if [ "$modName" = "fcal" ]; then
169                 findmodule fc4
170                 findmodule socal
171         fi
172
173         if [ -n "$skiperrors" ]; then
174                 allModulesToFind=`find_depmod silent $modName`
175         else
176                 allModulesToFind=`find_depmod normal $modName`
177                 if [ $? != 0 ] ; then
178                         exit 1
179                 fi
180         fi
181         
182         for mod in $allModulesToFind ; do
183                 mod=$(echo $mod | \
184                       awk '{sub(/^\/lib\/modules\/[^\/]*\//,"");print}')
185                 addmodule $mod "$skiperrors"
186         done
187 }
188
189 inst() {
190         if [ "$#" != "2" ];then
191                 echo "usage: inst <file> <destination>"
192                 return
193         fi
194         [ -n "$verbose" ] && echo "$1 -> $2"
195         cp "$1" "$2"
196 }
197
198 get_label_ext2 () {
199         /sbin/e2label $1 2> /dev/null
200 }
201
202 get_uuid_ext2 () {
203         /sbin/tune2fs -l $1 2> /dev/null | awk -F: '/UUID:/ {gsub(" ",""); print $2}'
204 }
205
206 get_label_xfs () {
207         /usr/sbin/xfs_db -x -p xfs_admin -c label -r "$1"|awk -F= '{sub("^\"","", $2); sub("\"$", "", $2); print $2}'
208
209 }
210
211 get_uuid_xfs () {
212         /usr/sbin/xfs_db -x -p xfs_admin -c uuid -r "$1"|awk -F= '{print $2}'
213 }
214
215 find_root() {
216         eval `awk '/^[\t ]*#/ {next} {if ( $2 == "/" ) {print "rootdev=\"" $1 "\"\nrootFs=\"" $3 "\""}}' $fstab`
217         case $rootdev in
218         LABEL=*)
219                 if [ -x /sbin/findfs -a \( "$rootFs." = "ext2." -o "$rootFs." = "ext3." \) ] ; then
220                         rootdev2="`/sbin/findfs $rootdev 2>/dev/null`"
221                         if [ -n "$rootdev2" ] ; then
222                                 rootdev=$rootdev2
223                                 rootdev_found=1
224                         fi
225                 fi
226                 if [ "$rootdev_found." != "1." ] ; then
227                         case $rootFs in
228                         ext2|ext3)
229                                 if [ ! -x /sbin/e2label ] ; then
230                                         echo "/sbin/e2label is missing" 1>&2
231                                         exit 1
232                                 fi
233                                 get_label="get_label_ext2"
234                                 ;;
235                         xfs)
236                                 if [ ! -x /usr/sbin/xfs_db ] ; then
237                                         echo "/usr/sbin/xfs_db is missing" 1>&2
238                                         exit 1
239                                 fi
240                                 get_label="get_label_xfs"
241                                 ;;
242                         *)
243                                 echo "LABEL on $rootFs in not supported by geninitrd" 1>&2
244                                 exit 1
245                                 ;;
246                         esac
247                         if [ ! -r /proc/partitions ] ; then
248                                 echo '/proc/partitions is not readable'; 1>&2
249                                 exit 1
250                         fi
251                         label=${rootdev#"LABEL="}
252                         for dev in `awk 'BEGIN {getline;getline} {print "/dev/" $4}' /proc/partitions` ; do
253                                 if [ -r $dev ] && [ "$label" = "`$get_label $dev`" ] ; then
254                                         if [ -n "$verbose" ] ; then
255                                                 echo "Using $dev as device for rootfs"
256                                         fi
257                                         rootdev=$dev
258                                         rootdev_found=1
259                                         break
260                                 fi
261                         done
262                         if [ "$rootdev_found." != "1." ] ; then
263                                 echo "geninitrd can't find real device for LABEL=$label" 1>&2
264                                 exit 1
265                         fi
266                 fi
267                 ;;
268         UUID=*)
269                 if [ -x /sbin/findfs -a \( "$rootFs." = "ext2." -o "$rootFs." = "ext3." \) ] ; then
270                         rootdev2="`/sbin/findfs $rootdev 2>/dev/null`"
271                         if [ -n "$rootdev2" ] ; then
272                                 rootdev=$rootdev2
273                                 rootdev_found=1
274                         fi
275                 fi
276                 if [ "$rootdev_found." != "1." ] ; then
277                         case $rootFs in
278                         ext2|ext3)
279                                 if [ ! -x /sbin/tune2fs ] ; then
280                                         echo "/sbin/tune2fs is missing" 1>&2
281                                         exit 1
282                                 fi
283                                 get_uuid="get_uuid_ext2"
284                                 ;;
285                         xfs)
286                                 if [ ! -x /usr/sbin/xfs_db ] ; then
287                                         echo "/usr/sbin/xfs_db is missing" 1>&2
288                                         exit 1
289                                 fi
290                                 get_label="get_uuid_xfs"
291                                 ;;
292                         *)
293                                 echo "UUID on $rootFs in not supported by geninitrd" 1>&2
294                                 exit 1
295                                 ;;
296                         esac
297                         if [ ! -r /proc/partitions ] ; then
298                                 echo '/proc/partitions is not readable'; 1>&2
299                                 exit 1
300                         fi
301                         uuid=${rootdev#"UUID="}
302                         for dev in `awk 'BEGIN {getline;getline} {print "/dev/" $4}' /proc/partitions` ; do
303                                 if [ -r $dev ] && [ "$uuid" = "`$get_uuid $dev`" ] ; then
304                                         if [ -n "$verbose" ] ; then
305                                                 echo "Using $dev as device for rootfs"
306                                         fi
307                                         rootdev=$dev
308                                         rootdev_found=1
309                                         break
310                                 fi
311                         done
312                         if [ "$rootdev_found" != 1 ] ; then
313                                 echo "geninitrd can't find real device for UUID=$uuid" 1>&2
314                                 exit 1
315                         fi
316                 fi
317                 ;;
318         esac
319         rootdev1=${rootdev}
320 }
321
322 find_modules_softraid() {
323         if [ -f /etc/mdadm.conf ] ; then
324             [ -n "$verbose" ] && echo "Finding RAID details using mdadm for rootdev=$1"
325             eval `/sbin/mdadm --examine  --scan --config=/etc/mdadm.conf | \
326                   awk -v rootdev="$1" '
327         BEGIN {
328                 found = "no";
329                 dev_list = "";
330                 raidlevel = ""
331                 rootdev_devfs = rootdev;
332                 if (rootdev ~ /\/dev\/md\/[0-9]/) {
333                     gsub(/\/dev\/md\//,"/dev/md",rootdev_devfs);
334                 }
335         }
336
337         /^ARRAY/ {
338             if (($2 == rootdev) || ($2 == rootdev_devfs)) {
339                 raidlevel=$3;
340                 gsub(/level=/,NUL,raidlevel);
341                 if (raidlevel ~ /^raid[0-5]/) {
342                     gsub(/raid/,NUL,raidlevel);
343                 };
344                 found="yes";
345                 getline x;
346                 if (x ~ /devices=/) {
347                         dev_list = x;
348                         gsub("devices=", NUL, dev_list);
349                         gsub(",", " ", dev_list);
350                 }
351             }
352         }
353  
354         END {
355                 print "raidfound=" found;
356                 print "raidlevel=" raidlevel;
357                 print "dev_list=\"" dev_list "\"";
358         }'`
359         fi
360         if [ "$raidfound" != "yes" ]; then
361             [ -n "$verbose" ] && echo "Finding RAID details using raidtab for rootdev=$1"
362             eval `awk -v rootdev="$1" 'BEGIN {
363         found="no";
364         dev_list="";
365         rootdev_devfs = rootdev;
366         if (rootdev ~ /\/dev\/md\/[0-9]/) {
367             gsub(/\/dev\/md\//,"/dev/md",rootdev_devfs);
368         }
369 }
370
371 {
372         gsub("\t"," ");
373         gsub("  +", " ");
374         gsub("^ ","");
375         if (/^[\t ]*#/)
376                 next;
377         if (/^raiddev/) {
378                 if (($2 == rootdev) || ($2 == rootdev_devfs)) {
379                         found="yes";
380                 } else {
381                         if (found == "yes") {
382                                 exit 0;
383                         };
384                 };
385         };
386         if (found == "yes") {
387                 if ($1 == "device") {
388                         dev_list = dev_list " " $2;
389                 };
390                 if ($1 == "raid-level") {
391                         raidlevel=$2;
392                 }
393         };
394 }
395
396 END {
397         print "raidfound=" found "\nraidlevel=" raidlevel "\ndev_list=\"" dev_list "\"\n";
398 }' $raidtab `
399         fi
400         
401         if is_yes "$raidfound" ; then
402                 case "$raidlevel" in
403                 [0145])
404                         findmodule "raid$raidlevel"
405                         ;;
406                 linear)
407                         findmodule "linear"
408                         ;;
409                 *)
410                         echo "raid level $number (in $raidtab) not recognized" 1>&2
411                         ;;
412                 esac
413         else
414                 echo "ERROR: RAID devices not found for \"$1\", check your configuration!" 1>&2
415                 exit 1
416         fi
417
418         rootdev_nr=$(( $rootdev_nr + 1 ))
419         eval "rootdev${rootdev_nr}=\"$1\""
420         eval "dev_list${rootdev_nr}=\"${dev_list}\""
421         
422         for device in $dev_list; do
423                 find_modules_for $device
424         done
425 }
426
427 find_modules_scsi() {
428         for n in $PRESCSIMODS; do
429                 if [ "X$n" = "Xunknown" ] ; then
430                         if [ -f "$modulefile" ]; then
431                                 scsimodules="`awk '/scsi_hostadapter/ && ! /^[\t ]*#/ { print $3; }' $modulefile`"
432                                 for n in $scsimodules; do
433                         # for now allow scsi modules to come from anywhere. There are some
434                         # RAID controllers with drivers in block
435                                         findmodule "$n"
436                                 done
437                         fi
438                 else
439                         findmodule "$n"
440                 fi
441         done
442 }
443
444 find_modules_ide() {
445         typeset rootdev
446
447         rootdev="$(echo "$1" | awk ' { gsub(/\/dev\//,NUL); gsub(/[0-9].*/, NUL); print $0 } ')"
448         if [ "$pack_version_long" -lt "002004021" ]; then
449             [ -n "$verbose" ] && echo "Finding IDE modules for kernels <= 2.4.20"
450             for n in $PREIDEMODSOLD; do
451                 findmodule "$n"
452             done
453         else
454             tryauto=1
455             for n in $PREIDEMODS; do
456                 if [ "X$n" = "Xunknown" ] ; then
457                     if [ -f "$modulefile" ]; then
458                          [ -n "$verbose" ] && echo "Finding IDE modules using ide_hostadapter"
459                         idemodules="`awk '/ide_hostadapter/ && ! /^[\t ]*#/ { print $3; }' $modulefile`"
460                         for na in $idemodules; do
461                             tryauto=0;
462                             findmodule "$na"
463                         done
464                     fi
465
466                     if [ "$tryauto" -eq 1 ]; then
467                       if [ -r /usr/share/pci-database/ide.pci -a -r /proc/bus/pci/devices  ]; then
468                         [ -n "$verbose" ] && echo "Finding IDE modules using PCI ID database"
469                         if is_yes "${ide_only_root}"; then
470                           if [ -f /sys/block/${rootdev}/device/../../vendor -a -f /sys/block/${rootdev}/device/../../device ] ; then
471                             vendorid="$(awk ' { gsub(/0x/,NUL); print $0 } ' /sys/block/${rootdev}/device/../../vendor)"
472                             deviceid="$(awk ' { gsub(/0x/,NUL); print $0 } ' /sys/block/${rootdev}/device/../../device)"
473                             searchpciid="${vendorid}${deviceid}"
474                           elif [ -f /proc/ide/${rootdev}/../config ]; then
475                             searchpciid="$(awk ' /pci bus/ { print $7$9 } ' /proc/ide/${rootdev}/../config)"
476                           fi
477                         fi
478                         if [ -z "${searchpciid}" ]; then
479                             searchpciid="$(awk ' { print $2 } ' /proc/bus/pci/devices)"
480                         fi
481                         idemodules=""
482                         for nb in $searchpciid; do
483                             eval `awk -v pciid="$nb" 'BEGIN {
484 }
485                 
486 {
487         gsub("\t"," ");
488         gsub("  +", " ");
489         gsub("^ ","");
490         if (/^[\t ]*#/)
491                 next;
492         compmod = $1 "";        # make sure comparison type will be string
493                                 # cause pci IDs are hexadecimal numeric
494         if (compmod == pciid) {
495                 module=$2;
496 #               min_kernel=$3;  # now in ide.pci $3,$4 = vendor and device name
497 #               max_kernel=$4;  #
498                 exit 0;
499         }
500 }
501
502 END {
503         print "module=" module "\nmin_kernel=" min_kernel "\nmax_kernel=\"" max_kernel "\"\n";
504 }' /usr/share/pci-database/ide.pci`
505                             [ -n "$module" ] && idemodules="$idemodules $module"
506                         done
507                         if is_yes "$(awk ' /ide=reverse/ { print "yes" } ' /proc/cmdline)"; then
508                                 new_idemodules=""
509                                 for nc in idemodules; do
510                                     new_idemodules="$nc $new_idemodules"
511                                 done
512                                 idemodules="${new_idemodules}"
513                         fi
514                         if [ -z "$idemodules" ]; then
515                             echo "WARNING: rootfs on IDE device but no related modules found, loading ide-generic."
516                             idemodules="ide-generic"
517                         fi
518                         for nd in $idemodules; do
519                             findmodule "-$nd"
520                         done
521                       else
522                          echo -n "WARNING: "
523                          [ -r /usr/share/pci-database/ide.pci ] || echo -n "/usr/share/pci-database/ide.pci missing."
524                          [ -r /proc/bus/pci/devices ] || echo -n "/proc/bus/pci/devices missing."
525                          echo "Automatic IDE modules finding not available."
526                       fi
527                     fi
528                 else
529                         findmodule "$n"
530                 fi
531             done
532         fi
533 }
534
535 find_modules_for() {
536         if [ -z "$1" ]; then
537                 echo "ERROR: no argument passed to find_modules_for() - is your /etc/fstab correct?" >&2
538                 exit
539         elif is_yes "`echo "$1" | awk '/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:|\/dev\/nfs)/ { print "yes"; }'`"; then
540                 if [ ! -x /usr/bin/pcidev -a -z "$NFS_ETH_MODULES" ] ; then
541                     echo "ERROR: root on NFS but /usr/bin/pcidev not found." >&2
542                     echo "Please install correct pci-database package and rerun $0." >&2
543                     exit 1
544                 fi
545                 [ -z "$NFS_ETH_MODULES" ] && NFS_ETH_MODULES=$(/usr/bin/pcidev /m net | xargs)
546                 for m in $NFS_ETH_MODULES; do
547                     findmodule "$m"
548                 done
549                 findmodule "-ipv4"
550                 findmodule "nfs"
551                 usenfs="yes"
552                 echo "Remember to use \`root=/dev/ram0 init=/linuxrc' when starting kernel" >&2
553                 echo "or you will have problems like init(xx) being child process of swapper(1)." >&2
554         elif is_yes "`echo "$1" | awk '/^\/dev\/md/ { print "yes"; }'`"; then
555                 find_modules_softraid "$1"
556         elif is_yes "$(echo "$1" | awk '/^\/dev\/(sd|scsi)/ { print "yes"; }')" ; then
557                 find_modules_scsi
558         elif is_yes "`echo "$1" | awk '/^\/dev\/(hd|ide)/ { print "yes"; }'`" ; then
559                 find_modules_ide "$1"
560         elif is_yes "`echo "$1" | awk '/\/dev\/rd\// { print "yes"; }'`" ; then
561                 findmodule "DAC960"
562         elif is_yes "`echo "$1" | awk '/\/dev\/ida\// { print "yes"; }'`" ; then
563                 findmodule "cpqarray"
564         elif is_yes "`echo "$1" | awk '/\/dev\/cciss\// { print "yes"; }'`" ; then
565                 findmodule "cciss"
566         elif is_yes "`echo "$1" | awk '/\/dev\/ataraid\// { print "yes"; }'`"; then
567                 find_modules_ide
568                 findmodule "ataraid"
569                 ataraidmodules="`awk '/ataraid_hostadapter/ && ! /^[\t ]*#/ { print $3; }' $modulefile`"
570                 if -n "$ataraidmodules" ; then
571                         # FIXME: think about modules compiled in kernel
572                         echo "ERROR: ataraid_hostadapter alias not defined in $modulefile !"
573                         echo "Please set it and run $0 again."
574                         exit 1
575                 fi
576                 for n in $ataraidmodules; do
577                         findmodule "$n"
578                 done
579         # check to see if we need to set up a loopback filesystem
580         elif is_yes "`echo "$1" | awk -F/ '{print($3);}' | awk '/loop/ { print "yes"; }'`" ; then
581                 echo "Sorry, root on loop device isn't supported." 1>&2
582                 exit 1
583                 # TODO: rewrite for bsp and make nfs ready
584                 if [ ! -x /sbin/losetup ]; then
585                         echo "losetup is missing"
586                         exit 1
587                 fi
588                 key="^# $(echo $1 | awk -F/ '{print($3);}' | tr '[a-z]' '[A-Z]'):"
589                 if ! is_yes "`awk '/'$key'/ { print( "yes"); }' $fstab`" ; then
590                         echo "The root filesystem is on a $1, but there is no magic entry in $fstab" 1>&2
591                         echo "for this device. Consult the geninitrd man page for more information" 1>&2
592                         exit 1
593                 fi
594
595                 line="`awk '/'$key'/ { print $0; }' $fstab`"
596                 loopDev="$(echo $line | awk '{print $3}')"
597                 loopFs="$(echo $line | awk '{print $4}')"
598                 loopFile="$(echo $line | awk '{print $5}')"
599
600                 BASICMODULES="$BASICMODULES -loop"
601                 findmodule "-$loopFs"
602                 BASICMODULES="$BASICMODULES -${loopFs}"
603                 # don't have any clue, how is this supposed to work
604         elif [ -e "$1" ] && ls -l "$1" 2> /dev/null | awk '{if (/^b/) { if ($5 == "58,") { exit 0; } else { exit 1; } } else { exit 1; }}' || /sbin/lvm lvdisplay "$1" > /dev/null 2>&1 ; then
605                 if [ ! -f /sbin/initrd-lvm -o ! -x /sbin/lvdisplay -o ! -x /sbin/pvdisplay ] ; then
606                         echo "ERROR: root on LVM but /sbin/initrd-lvm, /sbin/lvdisplay and /sbin/pvdisplay not found." >&2
607                         echo "Please install lvm(2) and lvm(2)-initrd package and rerun $0." >&2
608                         exit 1
609                 fi
610                 if [ -z "$LVMTOOLSVERSION" ] ; then 
611                     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}')
612                     if [ -z "$LVMTOOLSVERSION" ] ; then
613                             echo "ERROR: Can't determine LVM tools version. Please set LVMTOOLSVERSION" >&2
614                             echo "and rerun $0." >&2
615                             exit 1
616                     fi
617                 fi
618                 if [ -z "$PVDEVICES" ] ; then
619                     VGVOLUME=$(/sbin/lvdisplay -c "$1" 2> /dev/null | awk -F":" ' { print $2 } ')
620                     PVDEVICES=$(/sbin/pvdisplay -c | awk -F":" -v vg="$VGVOLUME" ' BEGIN { devices="" } { if ($2 == vg) { devices = devices " " $1 } } END { print devices } ')
621                 fi
622                 if [ -n "$PVDEVICES" ] ; then
623                         for device in $PVDEVICES; do
624                                 find_modules_for $device
625                         done
626                 else
627                         echo "ERROR: I wasn't able to find PV (via lvdisplay and pvdisplay)." >&2 
628                         echo "You can try to set PVDEVICES in /etc/sysconfig/geninitrd." >&2
629                         exit 1
630                 fi
631                 if [ "$LVMTOOLSVERSION" = "2" ]; then
632                     findmodule "-dm-mod"
633                 elif [ "$LVMTOOLSVERSION" = "1" ]; then
634                     findmodule "-lvm"
635                     findmodule "-lvm-mod"
636                 else
637                         echo "ERROR: LVM version $LVMTOOLSVERSION is not supported yet." >&2
638                         exit 1
639                 fi
640                 uselvm="yes"
641         fi
642 }
643
644 modules_install() {
645         modules="$1"
646
647         for mod in $modules; do
648                 MODULEDIR="`my_dirname "$mod"`"
649                 mkdir -p "$MNTIMAGE/lib/modules/$kernel/$MODULEDIR"
650                 cp $verbose -a "/lib/modules/$kernel/$mod" "$MNTIMAGE/lib/modules/$kernel/$mod"
651                 gunzip "$MNTIMAGE/lib/modules/$kernel/$mod" 2> /dev/null
652         done
653 }
654
655 modules_add_linuxrc() {
656         modules="$1"
657         linuxrc="$2"
658  
659         for mod in $modules; do
660                 MODULE2="`my_dirname "$mod"`"
661                 NAME2=`basename "$mod" .gz`
662                 MODULE2=$MODULE2/$NAME2
663                 module="`echo $mod | awk -F/ '{ $0=$NF } /'$modext'.*$/ { gsub(/'$modext'.*/, NIL, $0); } { print $0; }'`"
664                 options="`awk '{ if($1 == "options" && $2 == "'${module}'") { for(i=3;i<=NF;i++) printf("%s ",$i); }}' "$modulefile"`"
665
666                 if [ -n "$verbose" ]; then
667                         /bin/echo -n "Loading module [$module] "
668                         if [ -n "$options" ] ; then
669                                 echo "with options [$options]."
670                         else
671                                 echo "without options."
672                         fi
673                 fi
674                 echo "$insmod /lib/modules/$kernel/$MODULE2 $options" >> "$linuxrc"
675         done
676 }
677
678 if [ -r /etc/sysconfig/geninitrd ] ; then
679         . /etc/sysconfig/geninitrd
680 fi
681
682 if [ -r /etc/sysconfig/bootsplash ] ; then
683         . /etc/sysconfig/bootsplash
684 fi
685
686 if [ ! -x /bin/initrd-busybox ] ; then 
687         echo "/bin/initrd-busybox is missing !"
688         exit 1
689 fi
690 if [ "`uname -m`" = "ia64" ]; then
691         IMAGESIZE=3000
692 else
693         IMAGESIZE=1500
694 fi
695 while [ $# -gt 0 ]; do
696         case $1 in
697         --fstab=*)
698                 fstab="`echo $1 | awk -F= '{print $2;}'`"
699                 ;;
700         --fstab)
701                 fstab="$2"
702                 shift
703                 ;;
704         --modules-conf=*)
705                 modulefile="`echo $1 | awk -F= '{print $2;}'`"
706                 ;;
707         --modules-conf)
708                 modulefile="$2"
709                 shift
710                 ;;
711         --raidtab=*)
712                 raidtab="`echo $1 | awk -F= '{print $2;}'`"
713                 ;;
714         --raidtab)
715                 raidtab="$2"
716                 shift
717                 ;;
718         --use-raidstart|--with-raidstart)
719                 USERAIDSTART="yes"
720                 ;;
721         --without-raidstart)
722                 USERAIDSTART="no"
723                 ;;
724         --use-insmod-static|--with-insmod-static)
725                 USEINSMODSTATIC="yes"
726                 ;;
727         --without-insmod-static)
728                 USEINSMODSTATIC="no"
729                 ;;
730         --without-bootsplash)
731                 BOOT_SPLASH="no"
732                 ;;
733         --without-suspend)
734                 USESUSPEND="no";
735                 ;;
736         --lvmtoolsversion=|--lvmversion=)
737                 LVMTOOLSVERSION="`echo $1 | awk -F= '{print $2;}'`"
738                 ;;
739         --lvmtoolsversion|--lvmversion)
740                 LVMTOOLSVERSION="$2"
741                 shift
742                 ;;
743         --with=*)
744                 BASICMODULES="$BASICMODULES `echo $1 | awk -F= '{print $2;}'`"
745                 ;;
746         --with)
747                 BASICMODULES="$BASICMODULES $2"
748                 shift
749                 ;;
750         --version)
751                 echo "geninitrd: version $VERSION"
752                 exit 0
753                 ;;
754         -v)
755                 verbose=-v
756                 ;;
757         --nocompress)
758                 COMPRESS="no"
759                 ;;
760         --ifneeded)
761                 ifneeded=1
762                 ;;
763         -f)
764                 force=1
765                 ;;
766         --preload=*)
767                 PREMODS="$PREMODS `echo $1 | awk -F= '{print $2;}'`"
768                 ;;
769         --preload)
770                 PREMODS="$PREMODS $2"
771                 shift
772                 ;;
773         --fs=*)
774                 echo "Warning: --fs option is obsoleted. Use --initrdfs instead" 1>&2
775                 INITRDFS="`echo $1 | awk -F= '{print $2;}'`"
776                 ;;
777         --fs)
778                 echo "Warning: --fs option is obsoleted. Use --initrdfs instead" 1>&2
779                 INITRDFS="$2"
780                 shift
781                 ;;
782         --initrdfs=*)
783                 INITRDFS="`echo $1 | awk -F= '{print $2;}'`"
784                 ;;
785         --initrdfs)
786                 INITRDFS="$2"
787                 shift
788                 ;;
789         --image-version)
790                 img_vers=yes
791                 ;;
792         --ide-only-root)
793                 ide_only_root="yes"
794                 ;;
795         *)
796                 if [ -z "$target" ]; then
797                         target="$1"
798                 elif [ -z "$kernel" ]; then
799                         kernel="$1"
800                 else
801                         usage
802                 fi
803                 ;;
804         esac
805
806         shift
807 done
808
809 if [ -z "$target" -o -z "$kernel" ]; then
810         usage
811 fi
812
813 pack_version="`echo "$kernel"|awk -F. '{print sprintf("%03d%03d",$1,$2)}'`"
814 pack_version_long="`echo "$kernel"|awk -F. '{print sprintf("%03d%03d%03d",$1,$2,$3)}'`"
815
816 if [ "x" = "x$INITRDFS" ] ; then
817         if [ "x" = "x$FS" ] ; then
818                 # default value
819 #               if [ "$pack_version" -ge "002005" ] ; then
820 #                   INITRDFS="initramfs"
821 #               else
822                     INITRDFS="rom"
823 #               fi
824         else
825                 echo "Warning: FS configuration options is obsoleted. Use INITRDFS instead" 1>&2
826                 INITRDFS="$FS"
827         fi
828 fi
829
830 if [ "$pack_version" -ge "002005" ] ; then
831         modext=".ko"
832         insmod="insmod"
833 fi
834
835 if is_yes "$USEINSMODSTATIC" ; then
836         insmod="insmod.static"
837         INSMOD="/sbin/insmod.static"
838         if [ "$pack_version" -lt "002005" -a -f /sbin/insmod.static.modutils ] ; then
839                 INSMOD="/sbin/insmod.static.modutils"
840         fi
841         if [ ! -f "$INSMOD" ] ; then
842                 echo "insmod.static requested but /sbin/insmod.static not found !" >&2
843                 exit 1
844         fi
845 fi
846
847 case "$INITRDFS" in
848         ext2)
849                 if [ ! -x /sbin/mke2fs ]; then
850                         echo "/sbin/mke2fs is missing" 1>&2
851                         exit 1
852                 fi
853                 ;;
854         rom)
855                 if [ ! -x /sbin/genromfs ]; then
856                         echo "/sbin/genromfs is missing" 1>&2
857                         exit 1
858                 fi
859                 ;;
860         cram)
861                 if [ ! -x /sbin/mkcramfs ]; then
862                         echo "/sbin/mkcramfs is missing" 1>&2
863                         exit 1
864                 fi
865                 ;;
866         initramfs)
867                 if [ ! -x /bin/cpio ]; then
868                         echo "/bin/cpio is missing" 1>&2
869                         exit 1
870                 fi
871                 if [ ! -x /usr/bin/find ]; then
872                         echo "/usr/bin/find is missing" 1>&2
873                         exit 1
874                 fi
875                 ;;
876         *)
877                 echo "Filesystem $INITRDFS on initrd is not supported" 1>&2
878                 exit 1
879                 ;;
880 esac
881
882 if [ -n "$img_vers" ]; then
883         target="$target-$kernel"
884 fi
885
886 if [ -z "$force" -a -f "$target" ]; then
887         echo "$target already exists." 1>&2
888         exit 1
889 fi
890
891 if [ ! -d "/lib/modules/$kernel" ]; then
892         echo "/lib/modules/$kernel is not a directory." 1>&2
893         exit 1
894 fi
895
896 if [ ! -f /proc/mounts ]; then
897         echo "/proc filesystem not mounted, may cause wrong results or failure." 1>&2
898 fi
899
900 if [ "$pack_version" -lt "002005" ]; then
901         modulefile=/etc/modules.conf
902         if [ ! -f "$modulefile" -a -f /etc/conf.modules ]; then
903                 modulefile=/etc/conf.modules
904         fi
905 else
906         modulefile=/etc/modprobe.conf
907 fi
908  
909 for n in $PREMODS; do
910         findmodule "$n"
911 done
912
913 # allow forcing loading SCSI and/or IDE modules
914 if is_yes "$ADDSCSI" ; then
915         find_modules_scsi
916 fi
917
918 if is_yes "$ADDIDE" ; then
919         find_modules_ide
920 fi
921
922 find_root
923
924 org_rootdev="$rootdev1"
925
926 find_modules_for "$rootdev1"
927
928 findmodule "-$rootFs"
929
930 for n in $BASICMODULES; do
931         findmodule "$n"
932 done
933
934 if [ -n "$ifneeded" -a -z "$MODULES" ]; then
935         if [ -n "$verbose" ]; then
936                 echo "No modules are needed -- not building initrd image."
937         fi
938         exit 0
939 fi
940
941 if [ -n "$verbose" ]; then
942         echo "Using modules: $MODULES"
943 fi
944
945 MNTIMAGE="`mktemp -d /tmp/initrd.XXXXXX`"
946 IMAGE="`mktemp -u /tmp/initrd.img-XXXXXX`"
947 MNTPOINT="`mktemp -d /tmp/initrd.mnt-XXXXXX`"
948 RCFILE="$MNTIMAGE/linuxrc"
949
950 if [ -f "$MNTIMAGE" ]; then
951         echo "$MNTIMAGE already exists. Remove it and try again" 1>&2
952         exit 1
953 fi
954
955 if [ -f "$IMAGE" ]; then
956         echo "$IMAGE already exists. Remove it and try again" 1>&2
957         exit 1
958 fi
959
960 if [ "$INITRDFS" = "ext2" ] ; then
961         dd if=/dev/zero of="$IMAGE" bs=1k count="$IMAGESIZE" 2> /dev/null
962
963         # We have to "echo y |" so that it doesn't complain about $IMAGE not
964         # being a block device
965         echo y | mke2fs -F "$IMAGE" "$IMAGESIZE" >/dev/null 2>/dev/null
966
967         mkdir -p "$MNTPOINT"
968         mount -o loop -t ext2 "$IMAGE" "$MNTPOINT"
969 else
970         mkdir -p "$MNTPOINT"
971 fi
972
973
974 mkdir -p "$MNTIMAGE"/{lib,bin,etc,dev,loopfs,var}
975
976
977 # We don't need this directory, so let's save space
978 rm -rf "$MNTPOINT"/lost+found
979
980 modules_install "$MODULES"
981
982 # mknod'ing the devices instead of copying them works both with and
983 # without devfs...
984 mknod "$MNTIMAGE/dev/console" c 5 1
985 mknod "$MNTIMAGE/dev/null" c 1 3
986 mknod "$MNTIMAGE/dev/zero" c 1 5
987
988 s="$RCFILE"
989 ln -s /linuxrc $MNTIMAGE/init
990
991 inst /bin/initrd-busybox "$MNTIMAGE/bin/sh"
992 ln -s sh "$MNTIMAGE/bin/busybox"
993
994 if is_yes "$USEINSMODSTATIC" ; then
995         inst "$INSMOD" $MNTIMAGE/bin/insmod.static
996 fi
997
998 cat > "$s" <<EOF
999 #! /bin/sh
1000
1001 set -x
1002 EOF
1003 chmod 755 "$s"
1004
1005 modules_add_linuxrc "$MODULES" "$s"
1006
1007 # TODO: rewrite for busybox
1008 #if [ -n "$loopDev" ]; then
1009 #       if [ ! -d /initrd ]; then
1010 #               mkdir /initrd
1011 #       fi
1012 #
1013 #       cp -a "$loopDev" "$MNTIMAGE/dev"
1014 #       cp -a "$rootdev1" "$MNTIMAGE/dev"
1015 #       echo "echo Mounting device containing loopback root filesystem" >> "$RCFILE"
1016 #       echo "mount -t $loopFs $loopDev /loopfs" >> "$RCFILE"
1017 #       echo "echo Setting up loopback device $rootdev1" >> $RCFILE
1018 #       echo "losetup $rootdev1 /loopfs$loopFile" >> "$RCFILE"
1019 #fi
1020
1021 if is_yes "$USESUSPEND"; then
1022         MODULES=""
1023         for mod in $SUSPENDMODS; do
1024             is_yes "$BOOT_SPLASH" && [ "$mod" = "-suspend-text" ] && mod="-suspend_bootsplash"
1025             findmodule "$mod"
1026         done
1027         modules_install "$MODULES"
1028         mkdir -p $MNTIMAGE/sys
1029         mkdir -p $MNTIMAGE/proc
1030         echo "mount -t proc none /proc" >> "$s"
1031         echo "cmdline=\`cat /proc/cmdline\`" >> "$s"
1032         echo "if [ \"\$cmdline\" != \"\${cmdline#* resume2=}\" ]; then" >> "$s"
1033         modules_add_linuxrc "$MODULES" "$s"
1034         echo "  echo > /proc/software_suspend/activate" >> "$s"
1035         echo "  umount /proc" >> "$s"
1036         echo "  exit 0" >> "$s"
1037         echo "fi" >> "$s"
1038         echo "umount /proc" >> "$s"
1039 fi
1040
1041 if is_yes "$USERAIDSTART" && is_yes "$raidfound" ; then
1042         [ -n "$verbose" ] && echo "Setting up mdadm..."
1043         
1044         if [ ! -x /sbin/initrd-mdadm -a ! -x /sbin/initrd-mdassemble ] ; then
1045                 echo "/sbin/initrd-mdadm and /sbin/initrd-mdassemble are missing !"
1046                 exit 1
1047         fi
1048
1049         if [ -x /sbin/initrd-mdassemble ] ; then
1050             do_mdassemble=1
1051             inst /sbin/initrd-mdassemble "$MNTIMAGE/bin/mdassemble"
1052         else
1053             do_mdassemble=0
1054             inst /sbin/initrd-mdadm "$MNTIMAGE/bin/mdadm"
1055         fi
1056             
1057         # LVM on RAID case
1058         do_md0=1
1059         for nr in `seq 1 $rootdev_nr`; do
1060             eval cr_rootdev="\$rootdev${nr}"
1061             eval cr_dev_list="\$dev_list${nr}"
1062             [ -n "$verbose" ] && echo "Setting up array ($cr_rootdev = $cr_dev_list)"
1063
1064             [ "$cr_rootdev" = "/dev/md0" ] && do_md0=0
1065             
1066             if [ "$do_mdassemble" -eq 1 ] ; then
1067                 echo "DEVICE $cr_dev_list" >> "$MNTIMAGE/etc/mdadm.conf"
1068                 $cr_dev_list_md="$(echo "$cr_dev_list" | xargs | awk ' { gsub(/ +/,",",$0); print $0; }')"
1069                 echo "ARRAY $cr_rootdev devices=$cr_dev_list_md" >> "$MNTIMAGE/etc/mdadm.conf"
1070             else
1071                 echo "mdadm --assemble $cr_rootdev $cr_dev_list" >> "$s"
1072             fi
1073
1074             for f in $cr_dev_list $cr_rootdev ; do
1075                 # mkdir in case of devfs name
1076                 mkdir -p $MNTIMAGE/`my_dirname $f`
1077                 [ -n "$verbose" ] && echo "copying $f"
1078                 # this works fine with and without devfs
1079                 cp -HR $f $MNTIMAGE/$f
1080             done
1081         done
1082
1083         if [ "$do_mdassemble" -eq 1 ] ; then
1084             echo "mdassemble" >> "$s"
1085         fi
1086
1087         # needed to determine md-version
1088         if [ "$do_md0" -eq 1 ] ; then
1089                 mknod $MNTIMAGE/dev/md0 b 9 0
1090         fi
1091 fi
1092
1093 if is_yes "$usenfs" ; then
1094         # use root=/dev/ram0 init=/linuxrc when starting kernel or you will
1095         # have problems like init(XX) being child process of swapper(1).
1096         [ -n "$verbose" ] && echo "Adding rootfs on NFS support to initrd (dhcp)"
1097         mknod "$MNTIMAGE/dev/urandom" c 1 8
1098         mkdir "$MNTIMAGE/newroot"
1099         echo "ifconfig lo 127.0.0.1 up" >> "$s"
1100         echo "route add -net 127.0.0.0 netmask 255.0.0.0 lo" >> "$s"
1101         echo "ifconfig eth0 0.0.0.0 up" >> "$s"
1102         echo "udhcpc -i eth0 -f -q -s /bin/setdhcp"  >> "$s"
1103         cat << EOF > "$MNTIMAGE/bin/setdhcp"
1104 #!/bin/sh
1105 [ "\$1" != "bound" ] && exit
1106 [ -n "\$broadcast" ] && BROADCAST="broadcast \$broadcast"
1107 [ -n "\$subnet" ] && NETMASK="netmask \$subnet"
1108 set -x
1109 ifconfig \$interface \$ip \$BROADCAST \$NETMASK up
1110 set +x
1111 if [ -n "\$router" ]; then
1112     for r in \$router; do
1113         set -x
1114         route add default gw \$r dev \$interface
1115         set +x
1116     done
1117 fi
1118 if [ -n "\$rootpath" ]; then
1119     set -x
1120     mount -n -t nfs -o ro,nolock,posix,tcp,wsize=8192,rsize=8192 \$rootpath /newroot
1121     set +x
1122 else
1123     set +x
1124     echo "Missing rootpath in what DHCP server sent to us. Failing..."
1125     echo "All seen variables are listed below:"
1126     set
1127     set -x
1128 fi
1129 EOF
1130         chmod 755 "$MNTIMAGE/bin/setdhcp"
1131         echo "cd /newroot" >> "$s"
1132         echo "pivot_root . initrd" >> "$s"
1133         echo "[ -x /sbin/chroot ] && exec /sbin/chroot . /sbin/init -i < dev/console > dev/console 2>&1" >> "$s"
1134         echo "exec /usr/sbin/chroot . /sbin/init -i < dev/console > dev/console 2>&1" >> "$s"
1135 fi
1136
1137 if is_yes "$uselvm" ; then
1138         [ -n "$verbose" ] && echo "Adding LVM support to initrd"
1139         inst /sbin/initrd-lvm $MNTIMAGE/bin/lvm
1140         mkdir -p $MNTIMAGE/etc
1141         mkdir -p $MNTIMAGE/tmp
1142         mkdir -p $MNTIMAGE/proc
1143         mkdir -p $MNTIMAGE/newroot
1144         echo "mount -t proc none /proc" >> "$s"
1145         echo "mount -t devfs none /dev" >> "$s"
1146         echo "mount -t tmpfs none /tmp" >> "$s"
1147         if [ "$LVMTOOLSVERSION" = "1" ] ; then
1148                 echo "lvm vgscan -T" >> "$s"
1149                 echo "lvm vgchange -T -a y $VGVOLUME" >> "$s"
1150                 echo "umount /tmp" >> "$s"
1151                 # fail to umount
1152                 echo "umount /dev" >> "$s"
1153                 echo "umount /proc" >> "$s"
1154         else
1155                 echo "cat /etc/lvm.conf > /tmp/lvm.conf" >> "$s"
1156                 echo "global {" > "$MNTIMAGE/etc/lvm.conf"
1157                 echo "  locking_type = 0" >> "$MNTIMAGE/etc/lvm.conf"
1158                 echo "  locking_dir = \"/tmp\"" >> "$MNTIMAGE/etc/lvm.conf"
1159                 echo "}" >> "$MNTIMAGE/etc/lvm.conf"
1160                 echo "devices {" >> "$MNTIMAGE/etc/lvm.conf"
1161                 echo "  sysfs_scan=0" >> "$MNTIMAGE/etc/lvm.conf"
1162                 if is_yes "$raidfound"; then
1163                         echo "  md_component_detection = 1" >> "$MNTIMAGE/etc/lvm.conf"
1164                 fi
1165                 lvm dumpconfig | awk '/filter=/' >> "$MNTIMAGE/etc/lvm.conf"
1166                 echo "}" >> "$MNTIMAGE/etc/lvm.conf"
1167                 echo "LVM_SYSTEM_DIR=/tmp lvm vgscan --ignorelockingfailure" >> "$s"
1168                 echo "LVM_SYSTEM_DIR=/tmp lvm vgchange --ignorelockingfailure -a y $VGVOLUME" >> "$s"
1169                 # Find out major/minor
1170                 echo "majmin=\"\`LVM_SYSTEM_DIR=/tmp lvm lvdisplay --ignorelockingfailure -c $org_rootdev\`\"" >> "$s"
1171                 echo "majmin=\"\${majmin#*/}\"" >> "$s"
1172                 echo "majmin=\"\${majmin#*:*:*:*:*:*:*:*:*:*:*:*}\"" >> "$s"
1173                 echo "major=\"\${majmin%:*}\"" >> "$s"
1174                 echo "minor=\"\${majmin#*:}\"" >> "$s"
1175                 # Pass it to kernel
1176                 echo "val=\$((256 * \$major + \$minor))" >> "$s"
1177                 echo "echo \$val > /proc/sys/kernel/real-root-dev" >> "$s"
1178                 echo "umount /tmp" >> "$s"
1179                 echo "umount /dev" >> "$s"
1180                 echo "umount /proc" >> "$s"
1181 #               echo "mount -n -o ro $org_rootdev /newroot" >> "$s"
1182 #               echo "cd /newroot" >> "$s"
1183 #               echo "pivot_root . initrd" >> "$s"
1184 #               echo "[ -x /sbin/chroot ] && exec /sbin/chroot . /sbin/init -i < dev/console > dev/console 2>&1" >> "$s"
1185 #               echo "exec /usr/sbin/chroot . /sbin/init -i < dev/console > dev/console 2>&1" >> "$s"
1186         fi
1187 fi
1188
1189 chmod +x "$RCFILE"
1190
1191 (cd "$MNTIMAGE"; tar cf - .) | (cd "$MNTPOINT"; tar xf -)
1192
1193 case "$INITRDFS" in
1194         ext2)
1195                 umount "$IMAGE"
1196                 ;;
1197         rom)
1198                 genromfs -f "$IMAGE" -d "$MNTPOINT" -V "PLD initrd for kernel $kernel"
1199                 ;;
1200         cram)
1201                 mkcramfs "$MNTPOINT" "$IMAGE"
1202                 ;;
1203         initramfs)
1204                 (cd $MNTPOINT ; find . | cpio -H newc -o > "$IMAGE")
1205                 ;;
1206         *)
1207                 echo "Filesystem $INITRDFS not supported by $0";
1208 esac
1209
1210 if is_yes "$COMPRESS" ; then
1211         gzip -9 < "$IMAGE" > "$target"
1212 else
1213         cp -a "$IMAGE" "$target"
1214 fi
1215
1216 if is_yes "$BOOT_SPLASH"; then
1217         if [ ! -x /bin/splash.bin ]; then
1218                 echo "Failed to execute /bin/splash.bin. Is bootsplash package installed?" 1>&2
1219         elif [ -z "$THEME" ]; then
1220                 echo "Please configure your /etc/sysconfig/bootsplash first." 1>&2
1221                 echo "Generating bootsplashes skipped." 1>&2
1222         else
1223             if [ -n "$BOOT_SPLASH_RESOLUTIONS" ]; then
1224                 for res in $BOOT_SPLASH_RESOLUTIONS; do
1225                         if [ -f "/etc/bootsplash/themes/$THEME/config/bootsplash-$res.cfg" ]; then
1226                                 /bin/splash.bin -s -f "/etc/bootsplash/themes/$THEME/config/bootsplash-$res.cfg" >> "$target" && \
1227                                 [ -n "$verbose" ] && echo "Added $res $THEME theme to initrd."
1228                         else
1229                                 echo "/etc/bootsplash/themes/$THEME/config/bootsplash-$res.cfg doesn't exist, skipped" 1>&2
1230                         fi
1231                 done
1232              else
1233                  echo "No BOOT_SPLASH_RESOLUTIONS specified in /etc/sysconfig/bootsplash." 1>&2
1234                  echo "Not adding bootsplash to initrd." 1>&2
1235              fi
1236         fi
1237 fi
1238
1239 rm -rf "$MNTIMAGE" "$MNTPOINT" "$IMAGE"
This page took 0.132338 seconds and 3 git commands to generate.