Changeset 1230


Ignore:
Timestamp:
Mar 8, 2007, 5:41:17 PM (13 years ago)
Author:
bruno
Message:

Imported relevant mindi modifications from stable to create a 1.2.2 version of mindi

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.2/mindi/mindi

    r1021 r1230  
    6969NET_MODS="sunrpc nfs nfs_acl lockd loop mii 3c59x e100 bcm5700 bnx2 e1000 eepro100 ne2k-pci tg3 pcnet32 8139cp 8139too 8390 vmxnet vmnet"
    7070EXTRA_MODS="$CDROM_MODS vfat fat loop md-mod linear raid0 raid1 xor raid5 lvm-mod dm-mod jfs xfs xfs_support pagebuf reiserfs ext2 ext3 minix nfs nfs_acl nfsd lockd sunrpc jbd"
     71# Replace with that line for HP OCMP e.g.
     72#DENY_MODS="MPS_Driver_Mapper mps octtldrv tscttl streams"
     73DENY_MODS=""
    7174
    7275LOGFILE=/var/log/mindi.log
     
    831834
    832835
     836# Check kernel filesystem capabilites for accessing initrd image
     837#
     838# Interface definition:
     839# param #1: absolute path to kernel image
     840GetInitrdFilesystemToUse() {
     841
     842    # interface test: make sure we have one parameter
     843    if [ $# -ne 1 ]; then
     844        Die "GetInitrdFilesystemToUse(): Expected 1 parameter, got $#."
     845    fi
     846
     847    # interface parameters
     848    local lvKernelImage=$1
     849
     850    # local constants (filesystem magic strings)
     851    local lcMagicCramfs="<3>cramfs: wrong magic"
     852    local lcMagicExt2fs="<3>EXT2-fs: blocksize too small for device."
     853    local lcMagicInitfs="<6>checking if image is initramfs..."
     854
     855    # local variables
     856    local lvOffset
     857    local lvScanRes
     858    local lvUseFilesystem
     859
     860    # say where we are.
     861    echo "  GetInitrdFilesystemToUse(): called with parameter: $lvKernelImage.\n" >> $LOGFILE
     862
     863    # verify that file exists
     864    [ ! -f $lvKernelImage ] && Die "File $lvKernelImage not found. Terminating."
     865
     866    # get offet of gzip magic "1f8b0800" in file
     867    lvOffset=`od -vA n -t x1 $lvKernelImage | tr -d '[:space:]' | awk '{ print match($0, "1f8b0800")}'`
     868    [ $lvOffset -eq 0 ] && Die "gzip magic not found in file $lvKernelImage. Terminating."
     869    lvOffset=`expr $lvOffset / 2`
     870    echo "  GetInitrdFilesystemToUse(): gzip magic found at lvOffset $lvOffset.\n" >> $LOGFILE
     871
     872    # scan kernel image for initrd filessystem support
     873    lvScanRes=`dd ibs=1 skip=$lvOffset if=$lvKernelImage obs=1M 2>/dev/null | gunzip -c | strings | grep -e "$lcMagicCramfs" -e "$lcMagicExt2fs" -e "$lcMagicInitfs"`
     874
     875    # determine which filesystem to use for initrd image: ext2fs, gzip'ed cpio (initramfs ) or cramfs
     876    if [ `echo $lvScanRes | grep -c "$lcMagicExt2fs"` -eq 1 ]; then
     877        lvUseFilesystem="ext2fs"
     878    elif [ `echo $lvScanRes | grep -c "$lcMagicInitfs"` -eq 1 ]; then
     879        lvUseFilesystem="initramfs"
     880    elif [ `echo $lvScanRes | grep -c "$lcMagicCramfs"` -eq 1 ]; then
     881        lvUseFilesystem="cramfs"
     882    else
     883        lvUseFilesystem="UNSUPPORTED"
     884    fi
     885
     886    # say what we are using
     887    echo "  GetInitrdFilesystemToUse(): Filesytem to use for initrd is $lvUseFilesystem.\n" >> $LOGFILE
     888
     889    # return file system to use
     890    echo "$lvUseFilesystem"
     891
     892}
     893
    833894# Searches parent raid device of given disk device
    834895# $1: disk device (i.e. /dev/hda1)
     
    886947    local module_list module fname oss r kern
    887948    oss="/root/oss/modules"
    888     module_list="`lsmod | sed -n '2,$s/ .*//p'`"
     949    module_list="`lsmod | sed -n '2,$s/ .*//'`"
     950    # Remove unwanted modules from list
     951    for i in $DENY_MODS; do
     952        module_list=`echo ${module_list} | tr ' ' '\n' | grep -Ev "^${i}$" | tr '\n' ' '`
     953    done
    889954###
    890955### Sq-Modification ... Use kernelname for module search path if specified
     
    9491014        echo "Problem with dead link on $file -> $link" >> $LOGFILE
    9501015    fi
    951     if [ "`echo $link | cut -c1`" = "/" ]; then
    952         echo "$link `ReadAllLink $link`"
    953     else
    954         d=`dirname $file`
    955         echo "$link `ReadAllLink $d/$link`"
    956     fi 
     1016    if [ -h "$d" ]; then
     1017        echo "$link $d"
     1018    else
     1019        echo "$link"
     1020    fi
    9571021}
    9581022
     
    10711135   
    10721136    echo -en "for outerloop in 1 2 3 4 5 ; do\necho -en \".\"\n" >> $outfile
    1073     list_to_echo="`lsmod | sed -n '2,$s/ .*//p'`"
     1137    # BERLIOS: That code is duplicated - Should be done once only
     1138    list_to_echo="`lsmod | sed -n '2,$s/ .*//'`"
     1139    # Remove unwanted modules from list
     1140    for i in $DENY_MODS; do
     1141        list_to_echo=`echo ${list_to_echo} | tr ' ' '\n' | grep -Ev "^${i}$" | tr '\n' ' '`
     1142    done
    10741143
    10751144    # Make temporary modprobe.conf file if we are told so
     
    17341803            rootpart=""
    17351804        fi
    1736         outstr="image=vmlinuz\n\tlabel=$i\n\tinitrd=/mindi.rdz\n\t${rootpart}append=\" rw ramdisk=$ramdisksize ramdisk_size=$ramdisksize maxcpus=1 $ooo_mode $ADDITIONAL_BOOT_PARAMS"
     1805        outstr="image=/vmlinuz\n\tlabel=$i\n\tinitrd=/mindi.rdz\n\t${rootpart}append=\" rw ramdisk=$ramdisksize ramdisk_size=$ramdisksize maxcpus=1 $ooo_mode $ADDITIONAL_BOOT_PARAMS"
    17371806   
    17381807        outstr=$outstr" $ooo_mode"
     
    17921861
    17931862    MakeLiloConfFile $disksize > $liloconf
     1863
     1864    # Copy it so that CD-ROM menu entry is satisfied
     1865    if [ "$ARCH" = "ia64" ] ; then
     1866        mountefi=0
     1867        df -T | grep /boot/efi | grep -q vfat
     1868        if [ $? -ne 0 ]; then
     1869            mount /boot/efi
     1870            if [ $? -ne 0 ]; then
     1871                echo "You have to mount your EFI partition when using mindi"
     1872                MindiExit -1
     1873            fi
     1874            mountefi=1
     1875        fi
     1876        cp /boot/efi/elilo.efi $mountpoint
     1877        cp $liloconf $mountpoint/elilo.efi $mountpoint/efi/boot
     1878        if [ $mountefi -eq 1 ]; then
     1879            umount /boot/efi 2>&1 > /dev/null
     1880        fi
     1881    fi
    17941882
    17951883    echo "Copying $MINDI_TMP/mindi.rdz to $mountpoint..." >> $LOGFILE
     
    18141902
    18151903    # copy the kernel across
    1816     rm -Rf $mountpoint/lost+found
     1904    [ "$mountpoint" != "" ] && rm -Rf $mountpoint/lost+found
    18171905    dd if=/dev/zero of=$mountpoint/zero bs=1k count=16 &> /dev/null
    18181906    free_space=`df -k -P $mountpoint | tail -n1 | tr -s ' ' '\t' | cut -f4`
     
    19542042
    19552043    # copy the kernel across
    1956     rm -Rf $mountpoint/lost+found
     2044    [ "$mountpoint" != "" ] && rm -Rf $mountpoint/lost+found
    19572045    dd if=/dev/zero of=$mountpoint/zero bs=1k count=16 &> /dev/null
    19582046    free_space=`df -k -P $mountpoint | tail -n1 | tr -s ' ' '\t' | cut -f4`
     
    22742362    bigdir=$1
    22752363    minidir_root=$2
    2276     rm -Rf $minidir_root/*
     2364    [ "$minidir_root" != "" ] && rm -Rf $minidir_root/*
    22772365
    22782366    TryToFitDataIntoSeveralDirs $bigdir $minidir_root
     
    22832371    fi
    22842372    RejigHyperlinks $minidir_root $noof_disks
    2285     rm -Rf $bigdir/*
     2373    [ "$bigdir" != "" ] && rm -Rf $bigdir/*
    22862374    return $noof_disks
    22872375}
     
    24612549    cd $old_pwd
    24622550    echo -en "\rThe files have been subdivided into $noof_disks directories.                                                            \r"
    2463     rm -Rf $minidir_root/compressed
     2551    [ "$minidir_root" != "" ] && rm -Rf $minidir_root/compressed
    24642552    if [ "$retval" -gt "0" ] ; then
    24652553        return 0
     
    25932681    echo "$disksize" > $mountpoint/tmp/$disksize.siz
    25942682    find $mountpoint -name CVS -exec rm -rf '{}' \;
    2595     umount $mountpoint || Die "Cannot unmount $tempfile"
    2596     dd if=$tempfile bs=1k 2> /dev/null | gzip -v9 > $rdz_fname 2> /dev/null
    2597 #    gzip -9 $tempfile
    2598 #    mv $tempfile.gz $rdz_fname
     2683    # Determine what filesystem to use for initrd image
     2684    echo "Call GetInitrdFilesystemToUse() with parameter ${kernelpath} to get filesystem to use for initrd." >> $LOGFILE
     2685    gvFileSystem=`GetInitrdFilesystemToUse ${kernelpath}`
     2686    [ -z  gvFileSystem ] && Die "GetFilesystemToUse() failed. Terminating."
     2687    case "$gvFileSystem" in
     2688    "ext2fs")
     2689        # say what will be used
     2690        echo "Creating an ext2 initrd image..." >> $LOGFILE
     2691        # kernel expects linuxrc in ext2 filesystem
     2692        ( cd $mountpoint && ln -sf sbin/init linuxrc )
     2693        # unmount loop filesystem and create image file using the standard approach
     2694        umount $mountpoint || Die "Cannot unmount $tempfile"
     2695        dd if=$tempfile bs=1k 2> /dev/null | gzip -v9 > $rdz_fname 2> /dev/null
     2696        # log that we are done
     2697        echo "...done." >> $LOGFILE
     2698    ;;
     2699    "initramfs")
     2700        # say what will be used
     2701        echo "Creating a gzip'ed cpio (AKA initramfs) initrd image..." >> $LOGFILE
     2702        # make sure that cpio is there
     2703        which cpio &> /dev/null; [ $? -eq 0 ] || Die "cpio not found. Please install package cpio and try again."
     2704        # go into filesystem
     2705        cd $mountpoint
     2706        # kernel expects init in cpio filesystem
     2707        ln -sf sbin/init init
     2708        # create cpio image file and unmount loop filesystem
     2709        find . -print | cpio -o -H newc | gzip -9 > $old_pwd/$rdz_fname 2> /dev/null
     2710        cd $old_pwd
     2711        umount $mountpoint || Die "Cannot unmount $tempfile"
     2712        # log that we are done
     2713        echo "...done." >> $LOGFILE
     2714    ;;
     2715    *)
     2716        Die "Filesystem $gvFileSystem not supported for initrd image. Terminating."
     2717    ;;
     2718    esac
    25992719    if [ "$res" -eq "0" ] ; then
    26002720        echo -en "..."
     
    26492769    [ "`du -sm $imagesdir/all.tar.gz | cut -f1`" -ge "30" ] && Die "You have too many tools in your shed"
    26502770    cd $old_pwd
    2651     rm -Rf $minidir_root
     2771    [ "$minidir_root" != "" ] && rm -Rf $minidir_root
    26522772    echo -e "$DONE"
    26532773}
     
    27642884echo "df result:" >> $LOGFILE
    27652885echo "----------" >> $LOGFILE
    2766 df >> $LOGFILE
     2886df -T >> $LOGFILE
     2887echo "-------------" >> $LOGFILE
     2888echo "mount result:" >> $LOGFILE
     2889echo "-------------" >> $LOGFILE
     2890mount >> $LOGFILE
    27672891echo "-------------" >> $LOGFILE
    27682892echo "lsmod result:" >> $LOGFILE
    27692893echo "-------------" >> $LOGFILE
    27702894lsmod >> $LOGFILE
     2895echo "-------------" >> $LOGFILE
     2896echo "Liste of extra modules is:" >> $LOGFILE
     2897echo "$EXTRA_MODS" >> $LOGFILE
    27712898echo "-------------" >> $LOGFILE
    27722899
Note: See TracChangeset for help on using the changeset viewer.