Changeset 3692 in MondoRescue for branches/3.3/mindi/mindi
- Timestamp:
- Oct 7, 2017, 1:30:27 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi/mindi
r3688 r3692 44 44 fi 45 45 46 EXTRA_SPACE=20000 0 # increase if you run out of ramdisk space46 EXTRA_SPACE=20000 # increase if you run out of ramdisk space - Default 20 MB 47 47 48 48 PROMPT_MAKE_CD_IMAGE="yes" … … 195 195 196 196 Die() { 197 local i198 197 if [ "$1" = "" ] ; then 199 198 LogAll "FATAL ERROR" … … 230 229 231 230 AbortHere() { 232 [ "$mountpoint" ] && sync && umount $mountpoint 2>> $LOGFILE233 231 Die "Program is terminating in response to signal received from OS/user" 234 232 } … … 716 714 717 715 GenerateListForFile() { 718 local files_found loc fname incoming i res716 local files_found fname incoming 719 717 incoming="$1" 720 718 files_found="" 721 res=0722 719 723 720 for fname in $incoming ; do … … 832 829 833 830 ListAllPartitions() { 834 local res currline partition all_partitions ap_orig remaining i j835 836 831 grep -Evx " *#.*| *none.*" $MY_FSTAB | $AWK '/^\/dev\/[imhs]d||^LABEL=\/|^UUID=/ && !/\/fdd|\/cdr|\/zip|\/floppy/ {print $1}' 837 832 [ -e "/etc/raidtab" ] && $AWK '/^ *device/ {print $2}' /etc/raidtab … … 905 900 fi 906 901 done 907 mr-read-all-link `mr-process-ldd $deps | sort -u` | sort -u902 mr-read-all-link `mr-process-ldd $deps | sort -u` $deps | sort -u 908 903 } 909 904 910 905 911 906 LocateFile() { 912 local i j path fname_to_find location output resolved tmp stub cache_id loclist907 local j dn newdn bn path fname_to_find output 913 908 fname_to_find="$1" 914 909 # It's an absolute path … … 976 971 } 977 972 978 # Called by MakeBootInitFile, to make /tmp/$MRCFG973 # Called by PrepareTargetDir, to make /tmp/$MRCFG 979 974 MakeMondoConfigFile() { 980 local outfile use_lzo use_comp use_star 975 local outfile use_lzo use_comp use_star use_gzip use_lzma 981 976 outfile=$1 982 977 > $outfile … … 1022 1017 # Get PV's for an LV 1023 1018 GetPVsForLV() { 1019 local vg 1020 1024 1021 if [ -n "$1" ]; then 1025 1022 vg=`$LVMCMD lvdisplay $1 2>/dev/null |awk '/VG Name/{print $NF;exit}'` … … 1546 1543 fi 1547 1544 1548 # copy boot stuff now generated in Prepare DataDiskImage1545 # copy boot stuff now generated in PrepareBigDir 1549 1546 if [ "$BOOT_TYPE" = "UEFI" ]; then 1550 1547 (cd $MINDI_TMP/target ; tar xfz $MINDI_CACHE/all.tar.gz ./EFI) … … 1630 1627 du -sk $MINDI_TMP/target/* >> $LOGFILE 1631 1628 LogFile "------------------------------------------" 1629 LogFile "Kernel size = `du -sk $kernelpath | cut -f1` K" 1630 LogFile "--------------------------------" 1632 1631 1633 1632 if [ "$retval" -ne "0" ] ; then 1634 LogFile "--------------------------------"1635 LogFile "INFO: Size of $MINDI_TMP/target:"1636 du -sk $MINDI_TMP/target/* >> $LOGFILE1637 LogFile "--------------------------------"1638 echo -en "Kernel size = `du -sk $kernelpath | cut -f1` K\nRamdisk free = $free_space K\n" >> $LOGFILE1639 1633 sync 1640 1634 umount $MINDI_TMP/target 1641 1635 LogAll "ERROR: Problems while creating boot media." 1642 1636 LogAll " Please unload some of your modules and try again." 1643 Die " Try to increase EXTRA_SPACE in $MINDI_CONFIG"1637 Die " Try using another temporary directory instead of $MINDI_TMP" 1644 1638 fi 1645 1639 … … 1771 1765 LogAll "ERROR: Problems while creating boot media." 1772 1766 LogAll " Please unload some of your modules and try again." 1773 Die " Try to increase EXTRA_SPACE in $MINDI_CONFIG"1767 Die " Try using another temporary directory instead of $MINDI_TMP" 1774 1768 fi 1775 1769 … … 1811 1805 cp $part $MINDI_CACHE 1812 1806 if [ "$ARCH" = "ia64" ] || [ "$BOOT_TYPE" = "UEFI" ]; then 1807 # Mount again ! 1808 LogAll "INFO: Re-Mounting $part on $MINDI_TMP/mpt" 1809 mount -t vfat $mount_opt $part $MINDI_TMP/mpt 2>> $LOGFILE 1813 1810 # We just need the EFI dir and the boot image for this case 1814 1811 mkdir -p $MINDI_TMP/mpt2 $MINDI_TMP/mpt/images $MINDI_TMP/mpt/archives … … 1900 1897 1901 1898 MakeBootableDevice ISO 1902 1903 1899 } 1904 1900 … … 2041 2037 [ "$ooo" = "RESTORE" ] && ooo="RESTORE nuke" 2042 2038 if [ "$type" = "elilo" ]; then 2043 outstr="image=/vmlinuz\n\tlabel=$i\n\tinitrd=/initrd.img\n\troot=/dev/ram0 append=\" rw ramdisk_size= $ramdisk_size$ooo $MINDI_ADDITIONAL_BOOT_PARAMS \"\n"2039 outstr="image=/vmlinuz\n\tlabel=$i\n\tinitrd=/initrd.img\n\troot=/dev/ram0 append=\" rw ramdisk_size=RAMDISK_SIZE $ooo $MINDI_ADDITIONAL_BOOT_PARAMS \"\n" 2044 2040 elif [ "$type" = "grub" ]; then 2045 outstr="title $i\n\tkernel /vmlinuz root=/dev/ram0 rw ramdisk_size= $ramdisk_size${ooo} $MINDI_ADDITIONAL_BOOT_PARAMS\n\tinitrd=/initrd.img\n"2041 outstr="title $i\n\tkernel /vmlinuz root=/dev/ram0 rw ramdisk_size=RAMDISK_SIZE ${ooo} $MINDI_ADDITIONAL_BOOT_PARAMS\n\tinitrd=/initrd.img\n" 2046 2042 elif [ "$type" = "grub2" ]; then 2047 2043 if [ "$BOOT_TYPE" = "UEFI" ]; then … … 2052 2048 iorder="initrd" 2053 2049 fi 2054 outstr="menuentry '$i' {\n\tinsmod all_video\n\tinsmod gzio\n\tinsmod part_msdos\n\tinsmod part_gpt\n\tinsmod ext2\n\tinsmod xfs\n\techo 'Loading kernel...'\n\t$lorder /vmlinuz root=/dev/ram0 rw ramdisk_size= $ramdisk_size${ooo} $MINDI_ADDITIONAL_BOOT_PARAMS\n\techo 'Loading ramdisk...'\n\t$iorder /initrd.img\n}\n"2050 outstr="menuentry '$i' {\n\tinsmod all_video\n\tinsmod gzio\n\tinsmod part_msdos\n\tinsmod part_gpt\n\tinsmod ext2\n\tinsmod xfs\n\techo 'Loading kernel...'\n\t$lorder /vmlinuz root=/dev/ram0 rw ramdisk_size=RAMDISK_SIZE ${ooo} $MINDI_ADDITIONAL_BOOT_PARAMS\n\techo 'Loading ramdisk...'\n\t$iorder /initrd.img\n}\n" 2055 2051 else 2056 2052 ps="/" 2057 2053 if [ $KERNEL_IS_XEN = "no" ]; then 2058 outstr="label $i\n\tkernel ${ps}vmlinuz\n\tappend initrd=${ps}initrd.img root=/dev/ram0 rw ramdisk_size= $ramdisk_size${ooo} $MINDI_ADDITIONAL_BOOT_PARAMS\n"2054 outstr="label $i\n\tkernel ${ps}vmlinuz\n\tappend initrd=${ps}initrd.img root=/dev/ram0 rw ramdisk_size=RAMDISK_SIZE ${ooo} $MINDI_ADDITIONAL_BOOT_PARAMS\n" 2059 2055 else 2060 outstr="label $i\n\tkernel ${ps}mboot.c32\n\tappend ${ps}xen.gz --- ${ps}vmlinuz root=/dev/ram0 rw ramdisk_size= $ramdisk_size${ooo} $MINDI_ADDITIONAL_BOOT_PARAMS --- ${ps}initrd.img\n"2056 outstr="label $i\n\tkernel ${ps}mboot.c32\n\tappend ${ps}xen.gz --- ${ps}vmlinuz root=/dev/ram0 rw ramdisk_size=RAMDISK_SIZE ${ooo} $MINDI_ADDITIONAL_BOOT_PARAMS --- ${ps}initrd.img\n" 2061 2057 fi 2062 2058 fi … … 2103 2099 PrepareBootDir() { 2104 2100 2105 2106 # Needs a bigdir variable setup before calling it2101 local detect 2102 # Needs a bigdir variable setup before calling it 2107 2103 2108 2104 # copy (e)lilo/isolinux/grub/whatever stuff into it as well … … 2234 2230 fi 2235 2231 2236 # Here we need to know the ramdisk_size2237 size_of_all_tools=`du -sk $bigdir | cut -f1`2238 export ramdisk_size=$(($size_of_all_tools+$EXTRA_SPACE))2239 LogFile "INFO: Ramdisk will be $ramdisk_size KB"2240 2241 2232 MakeBootConfFile $boottype > $bootconf 2242 2233 LogFile "Boot Conf file $bootconf content is:" … … 2255 2246 } 2256 2247 2257 Prepare AllTar() {2248 PrepareBigDirTar() { 2258 2249 echo -en "INFO: Tarring and zipping the data content..." 2259 2250 (cd "$bigdir" ; tar -b 4096 -cf - . 2>> $MINDI_TMP/$$.log | gzip -9 > $MINDI_CACHE/all.tar.gz || LogAll "ERROR: Problem creating all.tar.gz" $MINDI_TMP/$$.log) … … 2264 2255 echo -e "$DONE" 2265 2256 2266 [ "$bigdir" != "/" ] && rm -rf $bigdir 2267 } 2268 2269 PrepareDataDiskImages() { 2270 local needlist bigdir diskdir res i j k lines lfiles includefile 2257 } 2258 2259 CleanBigDir() { 2260 [ "$bigdir" != "/" ] && echo $bigdir | grep -vq $MINDI_TMP && rm -rf $bigdir 2261 } 2262 2263 PrepareBigDir() { 2264 local needlist diskdir res i j k lines lfiles includefile 2271 2265 2272 2266 rm -f $MINDI_CACHE/mindi.iso 2273 2267 needlist=$MINDI_TMP/what-we-need.txt 2274 bigdir=$MINDI_TMP/bigdir2275 2268 mkdir -p $bigdir/usr/bin 2276 2269 mkdir -p $bigdir/usr/sbin … … 2344 2337 cp -a /lib/dev-state $bigdir/lib/ 2>> $MINDI_TMP/$$.log || LogAll "ERROR: Unable to handle /lib/dev-state" $MINDI_TMP/$$.log 2345 2338 fi 2346 TOTAL_BIGDIR_SIZE=`du -sk $bigdir | cut -f1`2347 2339 MakeMountlist $MINDI_TMP/mountlist.txt 2348 2340 CheckMountlist $MINDI_TMP/mountlist.txt … … 2379 2371 2380 2372 PrepareBootDir 2381 PrepareAllTar 2373 2382 2374 } 2383 2375 … … 2620 2612 2621 2613 conf=$1 2614 mp=$2 2622 2615 echo -en "INFO: Gathering dependencies of $conf.conf..." 2616 LogFile "INFO: Gathering dependencies of $conf.conf..." 2623 2617 lis2=`grep -Ev '^#' $DEPLIST_DIR/$conf.conf | sort -u` 2624 2618 noof_lines=`echo $lis2 | wc -w` … … 2644 2638 done 2645 2639 echo -e "$DONE" 2646 echo"INFO: Processing all dependencies links for $conf.conf..."2640 LogAll "INFO: Processing all dependencies links for $conf.conf..." 2647 2641 # And their deps except dirs 2648 2642 lines=`sort -u $MINDI_TMP/$conf.lis $MINDI_TMP/$conf.lis2` … … 2653 2647 # recent bash says that -d is true for a link to a dir ! 2654 2648 for f in $lines; do 2655 #for f in `sort -u $MINDI_TMP/$conf.lis`; do2656 2649 if [ -e "$f" -a ! -d "$f" ] || [ -h "$f" ]; then 2657 2650 # Do not overwrite files already in destination (avoid using option -n of cp not portable) 2658 if [ ! -e "$m ountpoint/$f" ]; then2651 if [ ! -e "$mp/$f" ]; then 2659 2652 finallist="$finallist $f" 2660 2653 fi … … 2662 2655 done 2663 2656 # But adds the directory useful in $lis3 2664 fnllist=`echo $finallist | tr ' ' '\n' | sort -u | tr '\n' ' '`2665 LogFile "INFO: Copying $conf related files with cp -a --parents $fnllist $lis3 -t $mountpoint/"2666 cp -a --parents $fnllist $lis3 -t $mountpoint/ 2> $templog || LogAll "WARNING: Problem in $conf analysis" $templog2657 fnllist=`echo $finallist $lis3 | tr ' ' '\n' | sort -u | tr '\n' ' '` 2658 LogFile "INFO: Copying $conf related files with cp -a --parents $fnllist -t $mp/" 2659 cp -a --parents $fnllist -t $mp/ 2> $templog || LogAll "WARNING: Problem in $conf analysis" $templog 2667 2660 rm -f $MINDI_TMP/$conf.lis 2668 2661 } 2669 2662 2670 MakeBootInitFile() { 2671 local tgz_dir_fname rdz_fname tempfile nodes kernelsize res currsize not_copied j k s w needed_modules_path d thelink templog 2672 2673 tgz_dir_fname=$1 2674 rdz_fname=$2 2675 kernelsize=$3 2676 tempfile=$MINDI_TMP/temp.rd 2663 PrepareTargetDir() { 2664 local tgz_dir_fname nodes kernelsize res currsize not_copied j k s w needed_modules_path d thelink templog 2665 2666 tgz_dir_fname=$MINDI_LIB/rootfs 2667 rdz_fname=$MINDI_TMP/initrd.img 2668 kernelsize=`du -sk $kernelpath | cut -f1` 2677 2669 res=0 2678 2670 templog=$MINDI_TMP/$$.log 2679 2671 > $templog 2680 2672 2681 LogAll "INFO: Making Boot RAM Disk ($ramdisk_size KB)" 2682 dd if=/dev/zero of=$tempfile bs=1k count=$ramdisk_size &> /dev/null || Die "Not enough room for temporary ramdisk (MakeBootInitFile)" 2683 LogAll "INFO: Creating ext2 filesystem on $tempfile" 2684 mke2fs -b 1024 -m 1 -i 2048 -F $tempfile >> $LOGFILE 2>> $LOGFILE || Die "Unable to create an ext2 file system on $tempfile" 2685 mkdir -p $mountpoint 2686 mount -t ext2 -o loop $tempfile $mountpoint || Die "Cannot loopmount $tempfile to $mountpoint! The reason may be missing support for loopfs or ext2 (or both) in the running kernel." 2687 2673 mkdir -p $targetdir 2688 2674 # Check whether /lib64 or /lib or /sbin or /bin is a link and if so explicitly create one in rootfs (Fedora 17 crazyness) 2689 2675 for d in bin sbin lib lib64; do 2690 2676 if [ -h "/$d" ]; then 2691 2677 thelink=`readlink /$d` 2692 mkdir -p $ mountpoint/$thelink || LogAll "ERROR: Unable to create $thelink in $mountpoint."2693 mv $ mountpoint/$d/* $mountpoint/$d/.??* $mountpoint/$thelink 2> /dev/null2694 if [ -d "$ mountpoint/$d" -a ! -h "$mountpoint/$d" ]; then2695 rmdir $ mountpoint/$d2696 fi 2697 if [ ! -h $ mountpoint/$d ]; then2698 rm -f $ mountpoint/$d 2> /dev/null2699 (cd $ mountpoint ; ln -s $thelink $d) || LogAll "ERROR: /$d is a symbolic link, but I couldn't create it in $mountpoint."2678 mkdir -p $targetdir/$thelink || LogAll "ERROR: Unable to create $thelink in $targetdir" 2679 mv $targetdir/$d/* $targetdir/$d/.??* $targetdir/$thelink 2> /dev/null 2680 if [ -d "$targetdir/$d" -a ! -h "$targetdir/$d" ]; then 2681 rmdir $targetdir/$d 2682 fi 2683 if [ ! -h $targetdir/$d ]; then 2684 rm -f $targetdir/$d 2> /dev/null 2685 (cd $targetdir ; ln -s $thelink $d) || LogAll "ERROR: /$d is a symbolic link, but I couldn't create it in $targetdir" 2700 2686 fi 2701 2687 fi 2702 2688 done 2703 2689 2704 LogFile "INFO: what is now in $ mountpoint"2705 ls -al $ mountpoint>> $LOGFILE2690 LogFile "INFO: what is now in $targetdir" 2691 ls -al $targetdir >> $LOGFILE 2706 2692 2707 2693 # Check files before copying to discover configuration issues or McAfee preventing mindi reading these files 2708 # copy from rootfs into mountpoint2709 LogAll "INFO: Copying Mindi files onto $ mountpoint"2694 # copy from rootfs into targetdir 2695 LogAll "INFO: Copying Mindi files onto $targetdir" 2710 2696 for f in $tgz_dir_fname/*; do 2711 2697 if [ ! -r $f ]; then 2712 2698 Die "ERROR: Unable to copy $f to the target dir. Check your installation or McAfee presence" 2713 2699 else 2714 cp -af $f $ mountpoint2>&1 >> $LOGFILE2700 cp -af $f $targetdir 2>&1 >> $LOGFILE 2715 2701 fi 2716 2702 done 2717 (cd $mountpoint/etc ; ln -sf bashrc profile ; ln -sf bashrc shrc ; ln -sf ../proc/mounts mtab ; ln -sf ../usr/sbin/init linuxrc) 2718 (cd $mountpoint ; ln -sf usr/sbin/init linuxrc) 2719 2720 (cd $mountpoint/dev ; tar -zxf dev-entries.tgz || Die "Cannot untar dev-entries.tgz" ; rm -f dev-entries.tgz) 2703 (cd $targetdir/etc ; ln -sf bashrc profile ; ln -sf bashrc shrc ; ln -sf ../proc/mounts mtab ; ln -sf ../usr/sbin/init linuxrc) 2704 # kernel expects linuxrc in ext2 filesystem 2705 (cd $targetdir ; ln -sf usr/sbin/init linuxrc) 2706 # kernel expects init in cpio filesystem 2707 (cd $targetdir ; ln -sf usr/sbin/init init) 2708 2709 (cd $targetdir/dev ; tar -zxf dev-entries.tgz || Die "Cannot untar dev-entries.tgz" ; rm -f dev-entries.tgz) 2721 2710 2722 2711 for w in insmod.static insmod.static.old ; do 2723 2712 s=`which $w 2> /dev/null` 2724 2713 if [ -e "$s" ] ; then 2725 tar cf - -C / $s 2> /dev/null | (cd $ mountpoint; tar xf -)2714 tar cf - -C / $s 2> /dev/null | (cd $targetdir ; tar xf -) 2726 2715 fi 2727 2716 done … … 2730 2719 2731 2720 # Copy of files mandatory for ssh to automate mount if sshfs is used 2732 mkdir -p $ mountpoint/.ssh $mountpoint/tmp2733 cp -a ~root/.ssh/* $ mountpoint/.ssh 2> /dev/null2734 cat > $ mountpoint/tmp/myssh << EOF2735 ssh -o StrictHostKeyChecking=no $*2721 mkdir -p $targetdir/.ssh $targetdir/tmp 2722 cp -a ~root/.ssh/* $targetdir/.ssh 2> /dev/null 2723 cat > $targetdir/tmp/myssh << EOF 2724 ssh -o StrictHostKeyChecking=no \$* 2736 2725 EOF 2737 chmod 755 $ mountpoint/tmp/myssh2726 chmod 755 $targetdir/tmp/myssh 2738 2727 2739 2728 # Copy of files mandatory for ld.so 2740 cp -a /etc/ld.so.c* $ mountpoint/etc2729 cp -a /etc/ld.so.c* $targetdir/etc 2741 2730 2742 2731 # Handle the case where busybox and mount are dynamically linked … … 2744 2733 if [ $? -eq 0 ]; then 2745 2734 # We want to use the real mount and all the supported variants (nfs, cifs, ...) 2746 rm -f $ mountpoint/bin/mount2735 rm -f $targetdir/bin/mount 2747 2736 fi 2748 2737 2749 2738 # Copy of files from the minimal env needed as per the deplist.d/minimal.conf (which includes all busybox deps) 2750 CopyFromConf minimal 2751 2752 # In case target /bin dir still doesn't exist, create it before using it 2753 if [ ! -d $mountpoint/bin ]; then 2754 mkdir -p $mountpoint/bin 2755 fi 2739 CopyFromConf minimal $targetdir 2756 2740 2757 2741 # For older distributions expecting /sbin/init provides it 2758 if [ ! -e "$ mountpoint/sbin/init" ]; then2759 (cd $ mountpoint/sbin ; ln -sf ../usr/sbin/init .)2742 if [ ! -e "$targetdir/sbin/init" ]; then 2743 (cd $targetdir/sbin ; ln -sf ../usr/sbin/init .) 2760 2744 fi 2761 2745 2762 2746 # To improve support for distribution scripts, we now prefer to use bash as the std shell. Also fixes #600 2763 (cd $ mountpoint; ln -sf /bin/bash bin/sh)2747 (cd $targetdir ; ln -sf /bin/bash bin/sh) 2764 2748 LogFile "INFO: Using bash as default shell" 2765 2749 2766 2750 # Avoids an issue on some distro (RHEL5) 2767 rm -f $ mountpoint/etc/ld.so.conf.d/kernelcap*2751 rm -f $targetdir/etc/ld.so.conf.d/kernelcap* 2768 2752 2769 2753 # Management of DRBD … … 2773 2757 drbdadm sh-dev all | grep -E '^/dev' &> /dev/null 2774 2758 if [ $? -eq 0 ]; then 2775 CopyFromConf drbd 2759 CopyFromConf drbd $targetdir 2776 2760 fi 2777 2761 # DRBD requires net activation … … 2782 2766 ps auxww | grep -v grep | grep -qw udevd 2783 2767 if [ $? -eq 0 ]; then 2784 echo "udev device manager found" > $ mountpoint/tmp/USE-UDEV2768 echo "udev device manager found" > $targetdir/tmp/USE-UDEV 2785 2769 LogFile "INFO: udev device manager found" 2786 tar cf - -C / /etc/udev 2> $templog | (cd $ mountpoint; tar xf -) || LogAll "ERROR: Problem in /etc/udev analysis" $templog2770 tar cf - -C / /etc/udev 2> $templog | (cd $targetdir ; tar xf -) || LogAll "ERROR: Problem in /etc/udev analysis" $templog 2787 2771 # This avoids NIC remapping if on another machine at restore time on Debian/Ubuntu at least 2788 rm -f $ mountpoint/etc/udev/rules.d/[z]*[0-9][0-9][-_]persistent-net.rules2772 rm -f $targetdir/etc/udev/rules.d/[z]*[0-9][0-9][-_]persistent-net.rules 2789 2773 # Do not do it if it's a link (Ubuntu 64 bits #503) 2790 2774 if [ -e "/lib64/udev" ] && [ ! -h "/lib64" ] && [ ! -h "/lib64/udev" ]; then 2791 tar cf - -C / /lib64/udev 2> $templog | (cd $ mountpoint; tar xf -) || LogAll "ERROR: Problem in /lib64/udev analysis" $templog2775 tar cf - -C / /lib64/udev 2> $templog | (cd $targetdir ; tar xf -) || LogAll "ERROR: Problem in /lib64/udev analysis" $templog 2792 2776 fi 2793 2777 if [ -e "/lib32/udev" ] && [ ! -h "/lib32" ] && [ ! -h "/lib32/udev" ]; then 2794 tar cf - -C / /lib32/udev 2> $templog | (cd $ mountpoint; tar xf -) || LogAll "ERROR: Problem in /lib32/udev analysis" $templog2778 tar cf - -C / /lib32/udev 2> $templog | (cd $targetdir ; tar xf -) || LogAll "ERROR: Problem in /lib32/udev analysis" $templog 2795 2779 fi 2796 2780 if [ -e "/lib/udev" ] && [ ! -h "/lib" ] && [ ! -h "/lib/udev" ]; then 2797 tar cf - -C / /lib/udev 2> $templog | (cd $ mountpoint; tar xf -) || LogAll "ERROR: Problem in /lib/udev analysis" $templog2781 tar cf - -C / /lib/udev 2> $templog | (cd $targetdir ; tar xf -) || LogAll "ERROR: Problem in /lib/udev analysis" $templog 2798 2782 fi 2799 2783 if [ -e "/usr/lib/udev" ] && [ ! -h "/usr/lib" ] && [ ! -h "/usr/lib/udev" ]; then 2800 tar cf - -C / /usr/lib/udev 2> $templog | (cd $ mountpoint; tar xf -) || LogAll "ERROR: Problem in /usr/lib/udev analysis" $templog2784 tar cf - -C / /usr/lib/udev 2> $templog | (cd $targetdir ; tar xf -) || LogAll "ERROR: Problem in /usr/lib/udev analysis" $templog 2801 2785 fi 2802 2786 if [ -x /sbin/udevd ] || [ -x /usr/bin/udevd ] || [ -x /usr/lib/systemd/systemd-udevd ] || [ -x /lib/systemd/systemd-udevd ]; then 2803 CopyFromConf udev 2787 CopyFromConf udev $targetdir 2804 2788 else 2805 2789 LogAll "WARNING: udevd daemon not in standard place (/sbin or /usr/bin)" 2806 2790 LogAll " mindi will use static devices which may cause problems" 2807 rm -f $ mountpoint/tmp/USE-UDEV2791 rm -f $targetdir/tmp/USE-UDEV 2808 2792 fi 2809 2793 fi … … 2814 2798 if [ -d $MINDI_CACHE/bkphw ]; then 2815 2799 LogAll "INFO: Hardware Information found and saved ..." 2816 cp -rp $MINDI_CACHE/bkphw $ mountpoint2800 cp -rp $MINDI_CACHE/bkphw $targetdir 2817 2801 if [ -f $MINDI_CACHE/tools.files ]; then 2818 2802 lis=`grep -Ev '^#' $MINDI_CACHE/tools.files` 2819 2803 LocateDeps $lis > $MINDI_TMP/tools.lis 2820 tar cf - $lis `sort -u $MINDI_TMP/tools.lis` 2> $templog | (cd $ mountpoint; tar xf -) || LogAll "ERROR: Problem in tools.lis analysis" $templog2804 tar cf - $lis `sort -u $MINDI_TMP/tools.lis` 2> $templog | (cd $targetdir ; tar xf -) || LogAll "ERROR: Problem in tools.lis analysis" $templog 2821 2805 fi 2822 2806 if [ -f $MINDI_CACHE/mindi-rsthw ]; then 2823 mv -f $MINDI_CACHE/mindi-rsthw $ mountpoint2824 chmod 755 $ mountpoint/mindi-rsthw2807 mv -f $MINDI_CACHE/mindi-rsthw $targetdir 2808 chmod 755 $targetdir/mindi-rsthw 2825 2809 fi 2826 2810 rm -f $MINDI_TMP/tools.lis $MINDI_CACHE/tools.files … … 2834 2818 cat $MINDI_TMP/perl.lis >> $LOGFILE 2835 2819 LogFile "-------------------------" 2836 tar cf - `cat $MINDI_TMP/perl.lis` 2> $templog | (cd $ mountpoint; tar xf -) || LogAll "ERROR: Problem in perl scripts analysis" $templog2820 tar cf - `cat $MINDI_TMP/perl.lis` 2> $templog | (cd $targetdir ; tar xf -) || LogAll "ERROR: Problem in perl scripts analysis" $templog 2837 2821 2838 2822 for w in cdrom groovy-stuff ; do … … 2840 2824 done 2841 2825 2842 tar cf - -C / /dev/fd0*[1,2][4,7,8]* 2> $templog | (cd $ mountpoint; tar xf -) || LogAll "ERROR: Problem in fd dev analysis" $templog2826 tar cf - -C / /dev/fd0*[1,2][4,7,8]* 2> $templog | (cd $targetdir ; tar xf -) || LogAll "ERROR: Problem in fd dev analysis" $templog 2843 2827 2844 2828 needed_modules="" … … 2867 2851 2868 2852 LogFile "INFO: Adding $needed_modules to the rootfs with $mkgmopt" 2869 cp --parents -aL $needed_modules $ mountpoint/ 2> $templog || LogAll "ERROR: Unable to copy modules to $mountpoint" $templog2853 cp --parents -aL $needed_modules $targetdir/ 2> $templog || LogAll "ERROR: Unable to copy modules to $targetdir" $templog 2870 2854 2871 2855 # Uncompress modules if not using udev and native modprobe 2872 if [ ! -f $ mountpoint/tmp/USE-UDEV ]; then2856 if [ ! -f $targetdir/tmp/USE-UDEV ]; then 2873 2857 for i in $needed_modules; do 2874 2858 if [ "`echo "$i" | grep -E ".gz$"`" ]; then 2875 gunzip -f $ mountpoint/$i2859 gunzip -f $targetdir/$i 2876 2860 fi 2877 2861 if [ "`echo "$i" | grep -E ".bz$"`" ]; then 2878 bunzip2 -f $ mountpoint/$i2862 bunzip2 -f $targetdir/$i 2879 2863 fi 2880 2864 if [ "`echo "$i" | grep -E ".xz$"`" ]; then 2881 unxz -f $ mountpoint/$i2865 unxz -f $targetdir/$i 2882 2866 fi 2883 2867 LogFile "INFO: Uncompressing $i" … … 2886 2870 2887 2871 # Also copy modules.* in case of udev so that normal modprobe works 2888 tar cf - -C / /$needed_modules_path/modules.* 2> $templog | (cd "$ mountpoint" ; tar xf -) || LogAll "ERROR: Unable to copy modules.* to $mountpoint" $templog2872 tar cf - -C / /$needed_modules_path/modules.* 2> $templog | (cd "$targetdir" ; tar xf -) || LogAll "ERROR: Unable to copy modules.* to $targetdir" $templog 2889 2873 2890 2874 # Copy FW in case some drivers needs it 2891 2875 for d in "/lib" "/usr/lib"; do 2892 2876 if [ -d "$d/firmware" -a ! -h $d ]; then 2893 cp -a "$d/firmware" "$ mountpoint$d"2877 cp -a "$d/firmware" "$targetdir$d" 2894 2878 fi 2895 2879 done … … 2898 2882 for d in "/lib" "/usr/lib" "/lib64" "/usr/lib64"; do 2899 2883 if [ -d "$d/multipath" -a ! -h $d ]; then 2900 cp -a "$d/multipath" "$ mountpoint$d"2884 cp -a "$d/multipath" "$targetdir$d" 2901 2885 fi 2902 2886 done 2903 2887 2904 2888 # Ensure that with mindi-busybox 1.21, the links also exists under /bin for older distro which need it for their scripts 2905 (cd $ mountpoint/usr/bin ; for i in `ls`; do if [ ! -e "$mountpoint/bin/$i" ]; then (cd $mountpoint/bin ; ln -sf ../usr/bin/$i .); fi; done)2889 (cd $targetdir/usr/bin ; for i in `ls`; do if [ ! -e "$targetdir/bin/$i" ]; then (cd $targetdir/bin ; ln -sf ../usr/bin/$i .); fi; done) 2906 2890 2907 2891 # Copy an additional ProLiant tool for OBDR support … … 2909 2893 found=0 2910 2894 if [ -x /usr/bin/hpsa_obdr_mode ]; then 2911 mkdir -p $ mountpoint/usr/bin2912 cp -a /usr/bin/hpsa_obdr_mode $ mountpoint/usr/bin2895 mkdir -p $targetdir/usr/bin 2896 cp -a /usr/bin/hpsa_obdr_mode $targetdir/usr/bin 2913 2897 LogAll "INFO: Copying /usr/bin/hpsa_obdr_mode to ramdisk for improved Smart Array OBDR support" 2914 2898 found=1 2915 2899 fi 2916 2900 if [ -x /usr/bin/sg_wr_mode ]; then 2917 mkdir -p $ mountpoint/usr/bin2901 mkdir -p $targetdir/usr/bin 2918 2902 lis="/usr/bin/sg_map /usr/bin/sg_inq /usr/bin/sg_reset /usr/bin/rev" 2919 2903 LocateDeps $lis > $MINDI_TMP/obdr.lis 2920 tar cf - $lis -C / `sort -u $MINDI_TMP/obdr.lis` 2> $templog | (cd $ mountpoint; tar xf -) || LogAll "ERROR: Problem in obdr.lis analysis" $templog2904 tar cf - $lis -C / `sort -u $MINDI_TMP/obdr.lis` 2> $templog | (cd $targetdir ; tar xf -) || LogAll "ERROR: Problem in obdr.lis analysis" $templog 2921 2905 LogAll "INFO: Copying /usr/bin/sg_reset to ramdisk for improved SCSI OBDR support" 2922 2906 found=1 … … 2931 2915 LogFile "INFO: Deleting devfsd daemon from ramdisk" 2932 2916 [ ! -e "/sbin/devfsd" ] && LogFile " ...because /sbin/devfsd not found" 2933 rm -f $ mountpoint/sbin/devfsd2934 fi 2935 [ "$TAPEDEV" ] && echo -en "$TAPEDEV" > $ mountpoint/tmp/TAPEDEV-LIVES-HERE2917 rm -f $targetdir/sbin/devfsd 2918 fi 2919 [ "$TAPEDEV" ] && echo -en "$TAPEDEV" > $targetdir/tmp/TAPEDEV-LIVES-HERE 2936 2920 if [ _"$MONDO_SHARE" != _"" ]; then 2937 MakeMondoConfigFile $ mountpoint/tmp/$MRCFG2938 cp -f $ mountpoint/tmp/$MRCFG $MINDI_TMP 2>> $LOGFILE || Die "Cannot copy $MRCFG to ramdisk"2939 cp -f $MINDI_TMP/mountlist.txt $ mountpoint/tmp/ 2>> $LOGFILE || Die "Cannot copy mountlist to ramdisk"2940 echo -en "$FILES_IN_FILELIST" > $ mountpoint/tmp/FILES-IN-FILELIST2941 echo -en "$LAST_FILELIST_NUMBER" > $ mountpoint/tmp/LAST-FILELIST-NUMBER2921 MakeMondoConfigFile $targetdir/tmp/$MRCFG 2922 cp -f $targetdir/tmp/$MRCFG $MINDI_TMP 2>> $LOGFILE || Die "Cannot copy $MRCFG to ramdisk" 2923 cp -f $MINDI_TMP/mountlist.txt $targetdir/tmp/ 2>> $LOGFILE || Die "Cannot copy mountlist to ramdisk" 2924 echo -en "$FILES_IN_FILELIST" > $targetdir/tmp/FILES-IN-FILELIST 2925 echo -en "$LAST_FILELIST_NUMBER" > $targetdir/tmp/LAST-FILELIST-NUMBER 2942 2926 fi 2943 2927 2944 2928 # Create module list to load at restore time 2945 rm -f $ mountpoint/tmp/modules2929 rm -f $targetdir/tmp/modules 2946 2930 for m in $CDROM_MODS; do 2947 echo $m >> $ mountpoint/tmp/modules2931 echo $m >> $targetdir/tmp/modules 2948 2932 done 2949 2933 2950 mkdir -p $ mountpoint/proc2934 mkdir -p $targetdir/proc 2951 2935 LogFile "---------------------------" 2952 LogFile "Size of initial ramdisk:" 2936 LogFile "Content of initial targetdir:" 2937 LogFile "---------------------------- " 2938 (cd "$targetdir" ; ls -Rla ) >> $LOGFILE 2953 2939 LogFile "---------------------------" 2954 (cd "$mountpoint" ; du -sh .) >> $LOGFILE 2955 LogFile "---------------------------" 2956 LogFile "Content of initial ramdisk:" 2957 LogFile "---------------------------" 2958 (cd "$mountpoint" ; ls -Rla ) >> $LOGFILE 2959 LogFile "---------------------------" 2960 2940 } 2941 2942 CleanTargetDir() { 2943 [ "$targetdir" != "/" ] && rm -rf $targetdir 2944 } 2945 2946 PatchBootFiles() { 2947 2948 # Patch the real value of RAMDISK_SIZE now we have it 2949 if [ -d "$bigdir/syslinux" ]; then 2950 find $bigdir/syslinux -type f 1> $MINDI_TMP/bootf.lis 2> /dev/null 2951 fi 2952 if [ -d "$bigdir/EFI" ]; then 2953 find $bigdir/EFI -type f 1>> $MINDI_TMP/bootf.lis 2> /dev/null 2954 fi 2955 for i in `cat $MINDI_TMP/bootf.lis`; do 2956 perl -pi -e "s/RAMDISK_SIZE/$ramdisk_size/" $i 2957 done 2958 rm -f $MINDI_TMP/bootf.lis 2959 2960 } 2961 2962 MakeBootInitFile() { 2963 2964 local mountpoint tempfile res 2965 tempfile=$MINDI_TMP/temp.rd 2966 res=0 2967 2968 LogAll "INFO: Making Boot RAM Disk ($ramdisk_size KB)" 2969 dd if=/dev/zero of=$tempfile bs=1k count=$ramdisk_size &> /dev/null || Die "Not enough room for temporary ramdisk (MakeBootInitFile)" 2970 2971 LogAll "INFO: Creating ext2 filesystem on $tempfile" 2972 mke2fs -b 1024 -m 1 -i 2048 -F $tempfile >> $LOGFILE 2>> $LOGFILE || Die "Unable to create an ext2 file system on $tempfile" 2973 res=$(($res+$?)) 2974 2975 mountpoint=$MINDI_TMP/mountpoint.$$ 2976 mkdir -p $mountpoint 2977 mount -t ext2 -o loop $tempfile $mountpoint || Die "Cannot loopmount $tempfile to $mountpoint! The reason may be missing support for loopfs or ext2 (or both) in the running kernel." 2978 [ "$targetdir" = "/" ] && echo $targetdir | grep -qv $MINDI_TMP && Die "Wrong targetdir $targetdir" 2979 mv $targetdir/* $targetdir/.??* $mountpoint || Die "Unable to move files from $targetdir to $mountpoint! Please increase EXTRA_SPACE" 2980 res=$(($res+$?)) 2981 rmdir $targetdir 2982 2983 LogFile "INFO: initrd image is $rdz_fname" 2961 2984 # Determine what filesystem to use for initrd image 2962 2985 LogFile "INFO: Call GetInitrdFilesystemToUse() with parameter ${kernelpath} to get filesystem to use for initrd." … … 2966 2989 # say what will be used 2967 2990 LogFile "INFO: Creating an $gvFileSystem initrd image..." 2968 # kernel expects linuxrc in ext2 filesystem2969 (cd "$mountpoint" && ln -sf usr/sbin/init linuxrc)2970 2991 # unmount loop filesystem and create image file using the standard approach 2971 2992 sync 2972 2993 umount $mountpoint || Die "Cannot unmount $tempfile" 2973 2994 dd if=$tempfile bs=1k of=${rdz_fname}.tmp > /dev/null 2> /dev/null 2995 res=$(($res+$?)) 2974 2996 if [ "$gvFileSystem" = "ext4fs" ] && [ -x "/sbin/tune4fs" ]; then 2975 2997 bs=`/sbin/tune4fs -l ${rdz_fname}.tmp | grep -E '^Block size:' | cut -d: -f2 | sed 's/^ *//'` … … 2979 3001 MINDI_ADDITIONAL_BOOT_PARAMS="$MINDI_ADDITIONAL_BOOT_PARAMS ramdisk_blocksize=$bs" 2980 3002 gzip -c9 ${rdz_fname}.tmp > $rdz_fname 3003 res=$(($res+$?)) 2981 3004 rm -f ${rdz_fname}.tmp 2982 # log that we are done2983 3005 elif [ "$gvFileSystem" = "initramfs" ]; then 2984 3006 # say what will be used … … 2986 3008 # make sure that cpio is there 2987 3009 which cpio &> /dev/null; [ $? -eq 0 ] || Die "cpio not found. Please install package cpio and try again." 2988 # kernel expects init in cpio filesystem2989 (cd "$mountpoint" ; ln -sf usr/sbin/init init)2990 3010 # create cpio image file and unmount loop filesystem 2991 3011 (cd "$mountpoint" ; find . -print | cpio -o -H newc 2> /dev/null | gzip -9 > $rdz_fname) 3012 res=$(($res+$?)) 2992 3013 sync 2993 3014 umount $mountpoint || Die "Cannot unmount $tempfile" 2994 # log that we are done2995 3015 else 2996 3016 Die "Filesystem $gvFileSystem not supported for initrd image. Terminating." 2997 3017 fi 2998 3018 3019 # log that we are done 2999 3020 if [ "$res" -eq "0" ] ; then 3000 3021 LogAll "INFO: MakeBootInitFile finished without error." … … 3002 3023 LogAll "WARNING: MakeBootInitFile exits WITH ERRORS." 3003 3024 fi 3025 3004 3026 return 0 3005 3027 } … … 3012 3034 # Now we can create what we need 3013 3035 mkdir -p $MINDI_TMP 3036 export bigdir=$MINDI_TMP/bigdir.$$ 3037 export targetdir=$MINDI_TMP/targetdir.$$ 3014 3038 3015 3039 # --nolog needs to be first, and is used in analyze-my-lvm … … 3372 3396 kernelpath=$2 3373 3397 BOOT_TYPE=$4 3374 bigdir=$MINDI_TMP/bigdir3375 3398 # Ironic requires some specific boot parameters 3376 3399 MINDI_ADDITIONAL_BOOT_PARAMS="selinux=0 barrier=off udevtimeout=10 systemd.debug-shell boot_method=vmedia" … … 3382 3405 fi 3383 3406 PrepareBootDir 3384 PrepareAllTar 3407 PrepareBigDirTar 3408 CleanBigDir 3385 3409 cp $3 $MINDI_TMP/initrd.img 3386 3410 MakeBootableDevice ISO … … 3550 3574 [ "$(($RANDOM%64))" -eq "0" ] && LogAll "INFO: Dude, I've looked inside your computer and it's really dusty..." 3551 3575 3552 mountpoint=$MINDI_TMP/mountpoint.$$ 3553 PrepareDataDiskImages 3554 3555 MakeBootInitFile $MINDI_LIB/rootfs $MINDI_TMP/initrd.img `du -sk $kernelpath | cut -f1` || Die "Could not create initrd.img" 3576 PrepareBigDir 3577 bigdir_size=`du -sk $bigdir | cut -f1` 3578 LogFile "---------------------------" 3579 LogFile "INFO: bigdir size is $bigdir_size KB" 3580 3581 PrepareTargetDir || Die "Could not create initrd.img in target dir" 3582 targetdir_size=`du -sk $targetdir | cut -f1` 3583 LogFile "---------------------------" 3584 LogFile "INFO: targetdir size is $targetdir_size KB" 3585 LogFile "---------------------------- " 3586 3587 # Now we can compute it correctly with some extra in case of... 3588 export ramdisk_size=$(($bigdir_size+$targetdir_size+$EXTRA_SPACE)) 3589 # And now we can patch the value in conf files 3590 PatchBootFiles 3591 # And tar them 3592 PrepareBigDirTar 3593 # And prepare boot setup 3594 MakeBootInitFile 3595 # Now cleans up stuff 3596 CleanBigDir 3597 CleanTargetDir 3556 3598 3557 3599 [ -e "$MINDI_LIB/memtest.img" ] && BOOT_MEDIA_MESSAGE="$BOOT_MEDIA_MESSAGE\n\
Note:
See TracChangeset
for help on using the changeset viewer.