Changeset 3895 in MondoRescue
- Timestamp:
- Dec 7, 2024, 2:29:55 AM (6 months ago)
- Location:
- tags/3.2.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
tags/3.2.3/mindi/mindi
r3573 r3895 127 127 fi 128 128 129 ISO_OPT="-J -r -v -p Mindi -publisher http://www.mondorescue.org -A Mindi -V Mindi _Image -o $MINDI_CACHE/mindi.iso "129 ISO_OPT="-J -r -v -p Mindi -publisher http://www.mondorescue.org -A Mindi -V Mindi-Image -o $MINDI_CACHE/mindi.iso " 130 130 131 131 # Mindi set this as default in case it's invoked alone … … 134 134 if [ -d "/sys/firmware/efi" ]; then 135 135 BOOT_TYPE="UEFI" 136 else 137 # Find MBR in case of bootable USB device to build 138 MBRFILE=/usr/lib/syslinux/mbr.bin 139 [ ! -r "$MBRFILE" ] && MBRFILE=/usr/lib64/syslinux/mbr.bin 140 [ ! -r "$MBRFILE" ] && MBRFILE=/usr/share/syslinux/mbr.bin 141 [ ! -r "$MBRFILE" ] && MBRFILE=/usr/share/lib/syslinux/mbr.bin 142 [ ! -r "$MBRFILE" ] && MBRFILE=/usr/share/lib64/syslinux/mbr.bin 143 fi 136 fi 137 138 # Find MBR file in case of bootable USB device to build and for restoring it 139 MBRFILE=/usr/lib/syslinux/mbr.bin 140 [ ! -r "$MBRFILE" ] && MBRFILE=/usr/lib64/syslinux/mbr.bin 141 [ ! -r "$MBRFILE" ] && MBRFILE=/usr/share/syslinux/mbr.bin 142 [ ! -r "$MBRFILE" ] && MBRFILE=/usr/share/lib/syslinux/mbr.bin 143 [ ! -r "$MBRFILE" ] && MBRFILE=/usr/share/lib64/syslinux/mbr.bin 144 145 # Find GPTMBR in case of bootable USB device to build and for restoring it 146 GPTMBRFILE=/usr/lib/syslinux/gptmbr.bin 147 [ ! -r "$GPTMBRFILE" ] && GPTMBRFILE=/usr/lib64/syslinux/gptmbr.bin 148 [ ! -r "$GPTMBRFILE" ] && GPTMBRFILE=/usr/share/syslinux/gptmbr.bin 149 [ ! -r "$GPTMBRFILE" ] && GPTMBRFILE=/usr/share/lib/syslinux/gptmbr.bin 150 [ ! -r "$GPTMBRFILE" ] && GPTMBRFILE=/usr/share/lib64/syslinux/gptmbr.bin 144 151 145 152 # Function to log on screen only … … 572 579 [ ! -e "$ISOLINUX" ] && ISOLINUX=/usr/share/lib64/syslinux/isolinux.bin 573 580 [ ! -e "$ISOLINUX" ] && ISOLINUX=/usr/lib/ISOLINUX/isolinux.bin 581 [ ! -e "$ISOLINUX" ] && ISOLINUX=/usr/lib/syslinux/bios/isolinux.bin 574 582 [ ! -e "$ISOLINUX" ] && ISOLINUX=`find / -name isolinux.bin | grep -x "/.*/isolinux.bin"` 575 583 [ ! -e "$ISOLINUX" ] && Die "Please install isolinux first. If your syslinux RPM doesn't include isolinux, you may download an isolinux RPM from Mondo's website - go to http://www.mondorescue.org/downloads.shtml" … … 1937 1945 # Type of boot file (elilo or syslinux/isolinux) 1938 1946 type=$1 1939 if [ "$type" = "elilo" ] ; then1947 if [ "$type" = "elilo" ] || [ "$type" = "grub2" ]; then 1940 1948 sep="=" 1941 1949 sepdef="=" … … 1943 1951 sep=" " 1944 1952 sepdef=" " 1945 if [ "$type" = "grub" ]; then1946 sepdef="="1947 fi1948 1953 fi 1949 1954 … … 1993 1998 1994 1999 # Handle timeout 1995 if [ "$type" = "grub" ]; then 1996 sep='=' 2000 if [ "$type" = "grub2" ]; then 2001 seppref="set " 2002 else 2003 seppref="" 1997 2004 fi 1998 2005 if [ "$CDRECOVERY" != "yes" ] ; then 1999 echo -en " timeout${sep}${MINDI_BOOT_TIMEOUT}\n"2006 echo -en "${seppref}timeout${sep}10000\n" 2000 2007 else 2001 echo -en " timeout${sep}10000\n"2008 echo -en "${seppref}timeout${sep}${MINDI_BOOT_TIMEOUT}\n" 2002 2009 fi 2003 2010 echo -en "\n" … … 2079 2086 } 2080 2087 2088 PrepareBootDir() { 2089 2090 local detect 2091 # Needs a bigdir variable setup before calling it 2092 2093 # copy (e)lilo/isolinux/grub/whatever stuff into it as well 2094 # to get it on the media (in addition to the boot part 2095 # and also to support UEFI boot mechanism 2096 if [ "$boottype" != "" ]; then 2097 detect="no" 2098 else 2099 detect="yes" 2100 boottype=syslinux 2101 fi 2102 bootdir=$bigdir/$boottype 2103 bootconf="$bootdir/$boottype.cfg" 2104 mkdir -p $bootdir 2105 FindLdlinux32Binary 2106 2107 if [ "$BOOT_TYPE" != "BIOS" ]; then 2108 if [ "$BOOT_TYPE" = "UNKNOWN" ]; then 2109 LogAll "ERROR: UNKNOWN BOOT_TYPE. Please report upstream" 2110 MindiExit -1 2111 fi 2112 2113 mountefi=0 2114 # EFI or UEFI 2115 # TODO: names are hard-coded for now 2116 if [ "$BOOT_TYPE" = "UEFI" ]; then 2117 # UEFI 2118 efidir=$bigdir/EFI/BOOT 2119 # Auto-detection if needed 2120 if [ $detect = "yes" ]; then 2121 2122 # mount /boot/efi if needed 2123 df -T | grep /boot/efi | grep -qE 'vfat' 2124 if [ $? -ne 0 ]; then 2125 mount /boot/efi 2126 if [ $? -ne 0 ]; then 2127 echo "ERROR: You have to mount your (U)EFI partition when using mindi" 2128 MindiExit -1 2129 fi 2130 mountefi=1 2131 fi 2132 2133 # On RHEL6 grub works 2134 dname=`pbdistrocheck | grep -E '^Name:' | cut -d':' -f2` 2135 dver=`pbdistrocheck | grep -E '^Ver:' | cut -d':' -f2` 2136 if [ $dname = "rhel" ] && [ $dver = "6" ]; then 2137 boottype=grub 2138 elif [ $dname = "rhel" ] && [ $dver = "7" ]; then 2139 boottype=grub2 2140 elif [ $dname = "debian" ] && [ $dver = "8" ]; then 2141 boottype=grub2 2142 else 2143 # Use syslinux.efi as the default boot loader ... but it doesn't work for now :-( 2144 boottype=syslinux 2145 fi 2146 fi 2147 if [ "$boottype" = "syslinux" ]; then 2148 if [ ! "$bootbin" ]; then 2149 FindSyslinux64EFI 2150 bootbin=$SYSLINUX64EFI 2151 fi 2152 bootconf="$efidir/syslinux.cfg" 2153 elif [ "$boottype" = "grub" ]; then 2154 if [ ! "$bootbin" ]; then 2155 bootbin=`find /boot/efi -iname "grub*.efi" | head -1` 2156 fi 2157 bootconf="$efidir/BOOTX64.conf" 2158 elif [ "$boottype" = "grub2" ]; then 2159 if [ ! "$bootbin" ]; then 2160 bootbin=`find /boot/efi -iname "grub*.efi" | head -1` 2161 fi 2162 bootconf="$efidir/grub.cfg" 2163 fi 2164 2165 # Depending on the arch, the target boot file is different 2166 if [ "$ARCH" = "x86_64" ] ; then 2167 tgbin="BOOTX64.efi" 2168 elif [ "$ARCH" = "armv8" ]; then 2169 tgbin="BOOTAA64.efi" 2170 else 2171 # i?386 2172 tgbin="BOOTIA32" 2173 fi 2174 else 2175 # EFI 2176 efidir=$bootdir 2177 bootbin=`find /boot/efi -iname "elilo.efi" | head -1` 2178 tgbin=$bootbin 2179 boottype=elilo 2180 bootconf="$efidir/elilo.conf" 2181 fi 2182 LogAll "INFO: Found $boottype boot type" 2183 mkdir -p $efidir 2184 cp $bootbin $efidir/$tgbin 2185 2186 if [ $mountefi -eq 1 ]; then 2187 umount /boot/efi 2>&1 > /dev/null 2188 fi 2189 2190 if [ $boottype = "syslinux" ]; then 2191 FindLdlinuxe64Binary 2192 if [ -e "$LDLINUXE64" ]; then 2193 LogFile "INFO: Copying $LDLINUXE64 to $efidir" 2194 cp $LDLINUXE64 $efidir 2>> $LOGFILE || Die "Cannot copy $LDLINUXE64 to $efidir). Did you run out of disk space?" 2195 cp $(dirname $LDLINUXE64)/libutil.c32 $efidir 2>> $LOGFILE || Die "Cannot copy libutil.c32 to $efidir). Did you run out of disk space?" 2196 if [ -e $(dirname $LDLINUXE64)/isolinux.c32 ]; then 2197 cp $(dirname $LDLINUXE64)/isolinux.c32 $efidir 2>> $LOGFILE || Die "Cannot copy isolinux.c32 to $efidir). Did you run out of disk space?" 2198 fi 2199 fi 2200 fi 2201 # tgdir for syslinux 2202 tgdir=$bigdir/EFI 2203 else 2204 # tgdir for syslinux 2205 tgdir=$bootdir 2206 fi 2207 # In all cases prepare syslinux content for BIOS mode 2208 # so that we can have multi boot mode media BIOS+UEFI 2209 # Useful for syslinux 5.x 2210 if [ -e "$LDLINUXC32" ]; then 2211 LogFile "INFO: Copying $LDLINUXC32 to $tgdir" 2212 cp $LDLINUXC32 "$tgdir" 2>> $LOGFILE || Die "Cannot copy $LDLINUXC32 to $tgdir. Did you run out of disk space?" 2213 fi 2214 if [ -e $(dirname $LDLINUXC32)/isolinux.c32 ]; then 2215 LogFile "INFO: Copying isolinux.c32 to $tgdir" 2216 cp $(dirname $LDLINUXC32)/isolinux.c32 $tgdir 2>> $LOGFILE || Die "Cannot copy isolinux.c32 to $tgdir). Did you run out of disk space?" 2217 fi 2218 2219 # Here we need to know the ramdisk_size 2220 size_of_all_tools=`du -sk $bigdir | cut -f1` 2221 export ramdisk_size=$(($size_of_all_tools+$EXTRA_SPACE)) 2222 LogFile "INFO: Ramdisk will be $ramdisk_size KB" 2223 2224 MakeBootConfFile $boottype > $bootconf 2225 LogFile "Boot Conf file $bootconf content is:" 2226 LogFile "------------------------------------" 2227 cat $bootconf >> $LOGFILE 2228 LogFile "------------------------------------" 2229 if [ "$BOOT_TYPE" = "UEFI" ]; then 2230 # Also generate the syslinux conf 2231 MakeBootConfFile syslinux > "$bigdir/EFI/syslinux.cfg" 2232 LogFile "Boot Conf file $bigdir/EFI/syslinux.cfg content is:" 2233 LogFile "---------------------------------------------------" 2234 cat $bigdir/EFI/syslinux.cfg >> $LOGFILE 2235 LogFile "---------------------------------------------------" 2236 fi 2237 2238 } 2239 2240 PrepareAllTar() { 2241 echo -en "INFO: Tarring and zipping the data content..." 2242 (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) 2243 LogFile "Size of the data content" 2244 LogFile "------------------------" 2245 du -sk $MINDI_CACHE/*gz >> $LOGFILE 2246 LogFile "------------------------" 2247 echo -e "$DONE" 2248 2249 [ "$bigdir" != "/" ] && rm -rf $bigdir 2250 } 2081 2251 2082 2252 PrepareDataDiskImages() { … … 2119 2289 2120 2290 CopyDependenciesToDirectory < $needlist $bigdir `wc -l $needlist` 1 2291 rm -f $needlist 2121 2292 echo -e "$DONE" 2122 2293 … … 2188 2359 cp -pRdf $MINDI_TMP/$q $bigdir/tmp 2>> $LOGFILE 2189 2360 done 2190 fi 2191 2192 # copy (e)lilo/isolinux/grub/whatever stuff into it as well 2193 # to get it on the media (in addition to the boot part 2194 # and also to support UEFI boot mechanism 2195 bootdir=$bigdir/syslinux 2196 bootconf="$bootdir/syslinux.cfg" 2197 boottype=syslinux 2198 mkdir -p $bootdir 2199 FindLdlinux32Binary 2200 if [ "$BOOT_TYPE" != "BIOS" ]; then 2201 if [ "$BOOT_TYPE" = "UNKNOWN" ]; then 2202 LogAll "ERROR: UNKNOWN BOOT_TYPE. Please report upstream" 2203 MindiExit -1 2204 fi 2205 # EFI or UEFI 2206 # TODO: names are hard-coded for now 2207 if [ "$BOOT_TYPE" = "UEFI" ]; then 2208 # UEFI 2209 efidir=$bigdir/EFI/BOOT 2210 # On RHEL6 grub works 2211 dname=`pbdistrocheck | grep -E '^Name:' | cut -d':' -f2` 2212 dver=`pbdistrocheck | grep -E '^Ver:' | cut -d':' -f2` 2213 if [ $dname = "rhel" ] && [ $dver = "6" ]; then 2214 bootbin=`find /boot/efi -iname "grub*.efi" | head -1` 2215 bootconf="$efidir/BOOTX64.conf" 2216 boottype=grub 2217 elif [ $dname = "rhel" ] && [ $dver = "7" ]; then 2218 bootbin=`find /boot/efi -iname "grub*.efi" | head -1` 2219 bootconf="$efidir/grub.cfg" 2220 boottype=grub2 2221 elif [ $dname = "debian" ] && [ $dver = "8" ]; then 2222 bootbin=`find /boot/efi -iname "grub*.efi" | head -1` 2223 bootconf="$efidir/grub.cfg" 2224 boottype=grub2 2361 for q in $MBRFILE $GPTMBRFILE; do 2362 if [ -r $q ]; then 2363 cp -a $q $bigdir/tmp 2>> $LOGFILE 2225 2364 else 2226 # Use syslinux.efi as the default boot loader ... but it doesn't work for now :-( 2227 FindSyslinux64EFI 2228 bootbin=$SYSLINUX64EFI 2229 bootconf="$efidir/syslinux.cfg" 2230 fi 2231 2232 # Depending on the arch, the target boot file is different 2233 if [ "$ARCH" = "x86_64" ] ; then 2234 tgbin="BOOTX64.efi" 2235 elif [ "$ARCH" = "armv8" ]; then 2236 tgbin="BOOTAA64.efi" 2237 else 2238 # i?386 2239 tgbin="BOOTIA32" 2240 fi 2241 else 2242 # EFI 2243 efidir=$bootdir 2244 bootbin=`find /boot/efi -iname "elilo.efi" | head -1` 2245 tgbin=$bootbin 2246 boottype=elilo 2247 bootconf="$efidir/elilo.conf" 2248 fi 2249 LogAll "INFO: Found $boottype boot type" 2250 2251 # Copy it so that CD-ROM menu entry is satisfied 2252 mountefi=0 2253 df -T | grep /boot/efi | grep -qE 'vfat' 2254 if [ $? -ne 0 ]; then 2255 mount /boot/efi 2256 if [ $? -ne 0 ]; then 2257 echo "ERROR: You have to mount your (U)EFI partition when using mindi" 2258 MindiExit -1 2259 fi 2260 mountefi=1 2261 fi 2262 mkdir -p $efidir 2263 cp $bootbin $efidir/$tgbin 2264 if [ $mountefi -eq 1 ]; then 2265 umount /boot/efi 2>&1 > /dev/null 2266 fi 2267 2268 if [ $boottype = "syslinux" ]; then 2269 FindLdlinuxe64Binary 2270 if [ -e "$LDLINUXE64" ]; then 2271 LogFile "INFO: Copying $LDLINUXE64 to $efidir" 2272 cp $LDLINUXE64 $efidir 2>> $LOGFILE || Die "Cannot copy $LDLINUXE64 to $efidir). Did you run out of disk space?" 2273 cp $LDLINUXE64/../libutil.c32 $efidir 2>> $LOGFILE || Die "Cannot copy $LDLINUXE64 to $efidir). Did you run out of disk space?" 2274 fi 2275 fi 2276 # In all cases prepare syslinux content for BIOS mode 2277 # so that we can have multi boot mode media BIOS+UEFI 2278 if [ -e "$LDLINUXC32" ]; then 2279 LogFile "INFO: Copying $LDLINUXC32 to $bigdir/EFI" 2280 cp $LDLINUXC32 "$bigdir/EFI" 2>> $LOGFILE || Die "Cannot copy $LDLINUXC32 to $bigtdir/EFI. Did you run out of disk space?" 2281 fi 2282 else 2283 # Useful for syslinux 5.x 2284 if [ -e "$LDLINUXC32" ]; then 2285 LogFile "INFO: Copying $LDLINUXC32 to $bootdir" 2286 cp $LDLINUXC32 $bootdir 2>> $LOGFILE || Die "Cannot copy $LDLINUXC32 to $bootdir. Did you run out of disk space?" 2287 fi 2288 fi 2289 2290 # Here we need to know the ramdisk_size 2291 size_of_all_tools=`du -sk $bigdir | cut -f1` 2292 export ramdisk_size=$(($size_of_all_tools+$EXTRA_SPACE)) 2293 LogFile "INFO: Ramdisk will be $ramdisk_size KB" 2294 2295 MakeBootConfFile $boottype > $bootconf 2296 LogFile "Boot Conf file $bootconf content is:" 2297 LogFile "------------------------------------" 2298 cat $bootconf >> $LOGFILE 2299 LogFile "------------------------------------" 2300 if [ "$BOOT_TYPE" = "UEFI" ]; then 2301 # Also generate the syslinux conf 2302 MakeBootConfFile syslinux > "$bigdir/EFI/syslinux.cfg" 2303 LogFile "Boot Conf file $bigdir/EFI/syslinux.cfg content is:" 2304 LogFile "---------------------------------------------------" 2305 cat $bigdir/EFI/syslinux.cfg >> $LOGFILE 2306 LogFile "---------------------------------------------------" 2307 fi 2308 2309 echo -en "INFO: Tarring and zipping the data content..." 2310 (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) 2311 LogFile "Size of the data content" 2312 LogFile "------------------------" 2313 du -sk $MINDI_CACHE/*gz >> $LOGFILE 2314 LogFile "------------------------" 2315 echo -e "$DONE" 2316 2317 [ "$bigdir" != "/" ] && rm -rf $bigdir 2318 rm -f $needlist 2365 LogFile "Unable to copy $q to bigdir. May be unable to restore MBR" 2366 fi 2367 done 2368 fi 2369 2370 PrepareBootDir 2371 PrepareAllTar 2319 2372 } 2320 2373 … … 3227 3280 $FDISK -l >> $LOGFILE 3228 3281 LogFile "----------------" 3282 LogFile "MBRFILE = $MBRFILE" 3283 LogFile "GPTMBRFILE = $GPTMBRFILE" 3229 3284 3230 3285 # Compute libata version … … 3312 3367 export MONDO_SHARE="" 3313 3368 MindiExit 0 3369 elif [ "$1" = "--ironic" ] ; then 3370 [ ! "$2" ] && [ ! -f "$2" ] && Die "Please specify the kernel to use" 3371 [ ! "$3" ] && [ ! -f "$3" ] && Die "Please specify the initramfs to use" 3372 [ "$4" ] && [ "$4" != "UEFI" ] && [ "$4" != "BIOS" ] && Die "Please specify the boot mode as BIOS or UEFI" 3373 #TODO: See how we can influence the boot loader 3374 [ "$5" ] && [ "$5" != "isolinux" ] && [ "$5" != "grub" ] && [ "$5" != "grub2" ] && Die "Please specify the boot loader as isolinux or grub or grub2" 3375 if [ "$5" ]; then 3376 boottype=$5 3377 fi 3378 [ "$6" ] && [ ! -e "$6" ] && Die "Please specify an existing boot loader path for $boottype" 3379 if [ "$6" ]; then 3380 bootbin=$6 3381 fi 3382 kernelpath=$2 3383 BOOT_TYPE=$4 3384 bigdir=$MINDI_TMP/bigdir 3385 MINDI_ADDITIONAL_BOOT_PARAMS="selinux=0 barrier=off udevtimeout=10 systemd.debug-shell boot_method=vmedia" 3386 MINDI_BOOT_TIMEOUT=10 3387 PrepareBootDir 3388 PrepareAllTar 3389 cp $3 $MINDI_TMP/initrd.img 3390 MakeBootableDevice ISO 3391 MindiExit 0 3314 3392 elif [ "$#" -ge "9" ] && [ "$1" = "--custom" ] ; then 3315 3393 MONDO_TMP=$2 … … 3394 3472 fi 3395 3473 else 3396 LogScreen "Syntax: mindi (--custom ....)" 3474 LogScreen "Syntax: mindi [--custom ....MondoRescue parameters...]" 3475 LogScreen " mindi --ironic kernel initrd [BIOS|UEFI] [syslinux|grub|grub2] [/path/to/bootloader]" 3476 LogScreen " mindi --locatedeps file" 3477 LogScreen " mindi --makemessage" 3478 LogScreen " mindi --makemountlist file" 3479 LogScreen " mindi --makebcf bootloader" 3480 LogScreen " mindi -V" 3397 3481 MindiExit -1 3398 3482 fi
Note:
See TracChangeset
for help on using the changeset viewer.