Changeset 3398 in MondoRescue
- Timestamp:
- Aug 4, 2015, 8:57:25 AM (9 years ago)
- Location:
- branches/3.2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi/mindi
r3397 r3398 1732 1732 if [ "$type" = "elilo" ]; then 1733 1733 sep="=" 1734 sepdef="=" 1734 1735 else 1735 1736 sep=" " 1737 sepdef=" " 1738 if [ "$type" = "grub" ]; then 1739 sepdef="=" 1740 fi 1736 1741 fi 1737 1742 1738 1743 # Generic header for conf file 1739 if [ "$type" != "elilo" ] ; then 1744 if [ "$type" = "elilo" ]; then 1745 echo -en "prompt\n" 1746 elif [ "$type" = "grub" ]; then 1747 echo -en "pause Press a key when ready to restore\n" 1748 else 1740 1749 echo -en "prompt 1\ndisplay message.txt\nF1 message.txt\nF2 boot1.txt\nF3 boot2.txt\nF4 pxe.txt\n" 1741 else1742 echo -en "prompt\n"1743 1750 fi 1744 1751 1745 1752 # Compute which default option to boot from 1753 echo -en "default${sepdef}" 1746 1754 if [ "$CDRECOVERY" = "yes" ] ; then 1747 echo -en "default${sep}RESTORE\n" 1755 if [ "$type" = "grub" ]; then 1756 # BCO: Which num ??? 1757 echo -en "0\n" 1758 else 1759 echo -en "RESTORE\n" 1760 fi 1748 1761 # In case it's mondoarchive 1749 1762 elif [ _"$MONDO_SHARE" != _"" ]; then 1750 1763 if [ -e "$MINDI_TMP/NETFS-SERVER-MOUNT" ] ; then 1751 echo -en "default${sep}iso\n" 1752 else 1753 echo -en "default${sep}${MINDI_DEFAULT_BOOT_OPTION}\n" 1764 if [ "$type" = "grub" ]; then 1765 echo -en "3\n" 1766 else 1767 echo -en "iso\n" 1768 fi 1769 else 1770 if [ "$type" = "grub" ]; then 1771 echo -en "1\n" 1772 else 1773 echo -en "${MINDI_DEFAULT_BOOT_OPTION}\n" 1774 fi 1754 1775 fi 1755 1776 else 1756 echo -en "default${sep}expert\n" 1777 if [ "$type" = "grub" ]; then 1778 echo -en "0\n" 1779 else 1780 echo -en "expert\n" 1781 fi 1757 1782 fi 1758 1783 … … 1782 1807 if [ "$type" = "elilo" ]; then 1783 1808 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" 1809 elif [ "$type" = "grub" ]; then 1810 outstr="title $i\n\tkernel /EFI/vmlinuz root=/dev/ram0 rw ramdisk_size=$ramdisk_size ${ooo} $MINDI_ADDITIONAL_BOOT_PARAMS\n\tinitrd=/EFI/initrd.img\n" 1784 1811 else 1785 1812 ps="/" … … 1799 1826 echo -en "image=/memtest.bin\n\tlabel=memtest\n" 1800 1827 echo -en "image=/memdisk\n\tlabel=memdisk\nappend=\"initrd=memtest.img\"\n" 1828 elif [ "$type" = "grub" ]; then 1829 echo -en "title memtest\n\tkernel /EFI/memtest.efi\n\tinitrd=/EFI/memtest.img\n" 1801 1830 else 1802 1831 ps="/" … … 1810 1839 } 1811 1840 1812 1813 PrepareBootDiskImage_LILO() { 1814 local imagesdir dev imagefile fname i kernelpath cfg_file testpath options retval outstr old_pwd ooo max_kernel_size liloconf 1841 PrepareBootDiskImage() { 1842 # LILO originally 1843 local imagesdir dev imagefile fname i kernelpath cfg_file testpath options retval outstr old_pwd ooo max_kernel_size liloconf bootimage 1815 1844 imagesdir=$MINDI_CACHE 1816 1845 kernelpath=$1 1817 1818 1846 retval=0 1819 1847 1820 1848 old_pwd=`pwd` 1821 [ ! -e "$kernelpath" ] && Die "PBDI lilo - cannot find $kernelpath kernel" 1822 echo -en "Making "$BOOT_SIZE"KB boot disk..." 1823 TurnTgzIntoRdz $MINDI_LIB/rootfs $MINDI_TMP/initrd.img `du -sk $kernelpath | cut -f1` || Die "Could not turn rootfs into initrd.img; are you SURE your kernel supports loopfs?" 1824 echo -en "..." 1825 imagefile=$imagesdir/mindi-bootroot.$BOOT_SIZE.img 1826 mkdir -p $mountpoint 1827 dd if=/dev/zero of=$imagefile bs=1k count=$BOOT_SIZE &> /dev/null || Die "Cannot dd blank file" 1828 LogFile "Creating vfat filesystem on $imagefile" 1829 mkdosfs $imagefile >> $LOGFILE 2>> $LOGFILE 1830 mount -t vfat -o loop $imagefile $mountpoint || LogAll "ERROR: Cannot mount (PBDI)" 1831 1832 # copy Mindi's skeleton fs & lilo/syslinux/whatever stuff into it 1833 mkdir -p $mountpoint/etc 1834 liloconf=$mountpoint/elilo.conf 1835 1836 MakeBootConfFile elilo > $liloconf 1837 1838 # Copy it so that CD-ROM menu entry is satisfied 1839 mountefi=0 1840 df -T | grep /boot/efi | grep -q vfat 1841 if [ $? -ne 0 ]; then 1842 mount /boot/efi 1843 if [ $? -ne 0 ]; then 1844 echo "You have to mount your EFI partition when using mindi" 1845 MindiExit -1 1846 fi 1847 mountefi=1 1848 fi 1849 el=`find /boot/efi -name elilo.efi` 1850 cp $el $mountpoint 1851 cp $liloconf $mountpoint 1852 if [ $mountefi -eq 1 ]; then 1853 umount /boot/efi 2>&1 > /dev/null 1854 fi 1855 1856 LogFile "INFO: Copying $MINDI_TMP/initrd.img to $mountpoint..." 1857 cp -f $MINDI_TMP/initrd.img $mountpoint 2>> $LOGFILE 1858 if [ "$?" -ne "0" ] ; then 1859 LogIt "ERROR: Failed to copy $MINDI_TMP/initrd.img to $mountpoint" 1860 cat $MINDI_TMP/mtpt.$$ >> $LOGFILE 1861 LogIt " Please unload some of your modules and try again. Or increase EXTRA_SPACE and BOOT_SIZE in $MINDI_CONFIG" 1862 rm -f $MINDI_TMP/mtpt.$$ 1863 LogIt "ERROR: Cannot incorporate initrd.img in bootdisk (kernel / modules too big?)" 1864 retval=$(($retval+1)) 1865 fi 1866 MakeMessageFile $mountpoint | cut -c1-80 > $mountpoint/message.txt 1867 1868 mkdir -p $mountpoint/tmp 1869 if [ -f "$MINDI_TMP/$MRCFG" ]; then 1870 cp -f $MINDI_TMP/$MRCFG $mountpoint/tmp 1871 fi 1872 1873 # copy the kernel across 1874 [ "$mountpoint" != "" ] && rm -Rf $mountpoint/lost+found 1875 dd if=/dev/zero of=$mountpoint/zero bs=1k count=16 &> /dev/null 1876 free_space=`df -k -P $mountpoint | tail -n1 | tr -s ' ' '\t' | cut -f4` 1877 cp -f $kernelpath $mountpoint/vmlinuz > /dev/null 2>> $LOGFILE 1878 if [ "$?" -ne "0" ] ; then 1879 LogFile "INFO: Files at mountpoint ($mountpoint) :" 1880 du -sk $mountpoint/* >> $LOGFILE 1881 LogFile "--- end of list of files ---" 1882 echo -en "Kernel size = `du -sk $kernelpath | cut -f1` K\nRamdisk free = $free_space K\n" >> $LOGFILE 1883 [ "$mountpoint" != "" ] && rm -f $mountpoint/vmlinuz 1884 cd "$old_pwd" 1885 umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)" 1886 rmdir $mountpoint || LogIt "ERROR: Cannot rmdir (PBDI)" 1887 # losetup /dev/loop0 -d 1888 [ "$imagefile" != "" ] && rm -f $imagefile 1889 LogIt "ERROR: Sorry, your kernel is too big for your image" 1890 Die "Try to increase EXTRA_SPACE and BOOT_SIZE in $MINDI_CONFIG" 1891 return 0 1892 fi 1893 max_kernel_size=$(($free_space+`du -sk $kernelpath | cut -f1`)) 1894 LogFile "INFO: Free space left on image = $free_space KB" 1895 LogFile "INFO: Max kernel size on $BOOT_SIZE KB image (est'd) = $max_kernel_size K" 1896 # make it bootable 1897 [ "$mountpoint" != "" ] && rm -f $mountpoint/zero 1898 [ -e "$MINDI_LIB/memdisk" ] && cp -f $MINDI_LIB/memdisk $mountpoint 2>> $LOGFILE 1899 if [ "$KERN_DISK_MADE" ] ; then 1900 LogFile "INFO: Not running LILO. It's not that kind of disk." 1901 fi 1902 1903 cp `dirname $kernelpath`/*.efi $mountpoint 2>> $LOGFILE 1904 umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)" 1905 echo -en "..." 1906 rmdir $mountpoint || LogIt "ERROR: Cannot rmdir (PBDI)" 1907 if [ "$retval" -eq "0" ] ; then 1908 echo -en "...$DONE\n" 1909 if [ "$KERN_DISK_MADE" ] ; then 1910 LogIt "INFO: $BOOT_SIZE KB boot disks were created OK\n" 1911 fi 1912 else 1913 echo -en "...failed\n" 1914 LogIt "WARNING: $BOOT_SIZE""KB boot disk was NOT created\n" 1915 [ "$imagefile" != "" ] && rm -f $imagefile 1916 fi 1917 [ "$retval" -ne "0" ] && LogIt "WARNING: PrepareBootDiskImage() is returning nonzero" 1918 return $retval 1919 } 1920 1921 1922 PrepareBootDiskImage_ISOLINUX() { 1923 local imagesdir dev imagefile fname i kernelpath cfg_file testpath options retval outstr old_pwd ooo max_kernel_size bootimage retval 1924 imagesdir=$MINDI_CACHE 1925 kernelpath=$1 1926 do_boot_root_thingy="" 1927 retval=0 1928 1929 old_pwd=`pwd` 1930 [ ! -e "$kernelpath" ] && Die "PBDI isolinux - cannot find $kernelpath kernel" 1849 [ ! -e "$kernelpath" ] && Die "PBDI - cannot find $kernelpath kernel" 1931 1850 echo -en "Making "$BOOT_SIZE"KB boot disk..." 1932 1851 TurnTgzIntoRdz $MINDI_LIB/rootfs $MINDI_TMP/initrd.img `du -sk $kernelpath | cut -f1` || Die "Could not turn rootfs into initrd.img; are you SURE your kernel supports loopfs?" … … 1937 1856 LogFile "INFO: Creating vfat filesystem on $imagefile" 1938 1857 mkfs.vfat $imagefile >> $LOGFILE 2>> $LOGFILE 1939 # syslinux should be run on a local file (doen't work through NFS Cf: #297) 1940 syslinux $imagefile >> $LOGFILE 2>> $LOGFILE 1858 if [ $BOOT_TYPE = "BIOS" ]; then 1859 # syslinux should be run on a local file (doen't work through NFS Cf: #297) 1860 syslinux $imagefile >> $LOGFILE 2>> $LOGFILE 1861 fi 1941 1862 1942 1863 # Only move it now to its final destination and use it now … … 1944 1865 imagefile=$imagesdir/mindi-bootroot.$BOOT_SIZE.img 1945 1866 1946 mount -t vfat -o loop $imagefile $mountpoint || Log It"ERROR: Cannot mount (PBDI)"1867 mount -t vfat -o loop $imagefile $mountpoint || LogAll "ERROR: Cannot mount (PBDI)" 1947 1868 1948 1869 # copy Mindi's skeleton fs & lilo/syslinux/whatever stuff into it 1949 MakeMessageFile $mountpoint | cut -c1-80 > $mountpoint/message.txt 1950 MakeBootConfFile isolinux > $mountpoint/syslinux.cfg 1870 if [ $BOOT_TYPE != "BIOS" ]; then 1871 if [ $BOOT_TYPE = "UNKNOWN" ]; then 1872 LogAll "ERROR: UNKNOWN BOOT_TYPE. Please report upstream" 1873 MindiExit -1 1874 fi 1875 # EFI or UEFI 1876 if [ $BOOT_TYPE = "UEFI" ]; then 1877 # UEFI 1878 lilodir=$mountpoint/EFI 1879 mkdir -p $lilodir 1880 liloconf=$lilodir/BOOTX64.conf 1881 lilobin=BOOTX64.efi 1882 1883 MakeBootConfFile grub > $liloconf 1884 else 1885 # EFI 1886 lilodir=$mountpoint 1887 mkdir -p $lilodir 1888 liloconf=$mountpoint/elilo.conf 1889 lilobin=elilo.efi 1890 1891 MakeBootConfFile elilo > $liloconf 1892 fi 1893 1894 # Copy it so that CD-ROM menu entry is satisfied 1895 mountefi=0 1896 df -T | grep /boot/efi | grep -qE 'vfat' 1897 if [ $? -ne 0 ]; then 1898 mount /boot/efi 1899 if [ $? -ne 0 ]; then 1900 echo "You have to mount your (U)EFI partition when using mindi" 1901 MindiExit -1 1902 fi 1903 mountefi=1 1904 fi 1905 el=`find /boot/efi -name $lilobin` 1906 cp $el $lilodir 1907 cp $liloconf $lilodir 1908 if [ $mountefi -eq 1 ]; then 1909 umount /boot/efi 2>&1 > /dev/null 1910 fi 1911 else 1912 MakeBootConfFile isolinux > $mountpoint/syslinux.cfg 1913 fi 1951 1914 LogFile "INFO: Copying $MINDI_TMP/initrd.img to $mountpoint/initrd.img..." 1952 1915 cp -f $MINDI_TMP/initrd.img $mountpoint/initrd.img 2>> $LOGFILE … … 1956 1919 LogAll " Please unload some of your modules and try again." 1957 1920 rm -f $MINDI_TMP/mtpt.$$ 1958 LogAll " Cannot incorporate initrd.img in bootdisk (kernel / modules too big?)."1921 LogAll "ERROR: Cannot incorporate initrd.img in bootdisk (kernel / modules too big?)" 1959 1922 LogAll " Try to increase EXTRA_SPACE and BOOT_SIZE in $MINDI_CONFIG" 1960 1923 retval=$(($retval+1)) 1961 1924 fi 1925 MakeMessageFile $mountpoint | cut -c1-80 > $mountpoint/message.txt 1962 1926 1963 1927 mkdir -p $mountpoint/tmp … … 1972 1936 1973 1937 retval=0 1974 cp -f $kernelpath $mountpoint/vmlinuz &> /dev/null1938 cp -f $kernelpath $mountpoint/vmlinuz > /dev/null 2>> $LOGFILE 1975 1939 retval=$? 1976 1940 if [ $KERNEL_IS_XEN = "yes" ]; then … … 1988 1952 umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)" 1989 1953 rmdir $mountpoint || LogAll "ERROR: Cannot rmdir (PBDI)" 1990 1954 [ "$imagefile" != "" ] && rm -f $imagefile 1991 1955 LogIt "ERROR: Sorry, your kernel is too big for your image" 1992 1956 Die "Try to increase EXTRA_SPACE and BOOT_SIZE in $MINDI_CONFIG" … … 1998 1962 # make it bootable 1999 1963 [ "$mountpoint" != "" ] && rm -f $mountpoint/zero 2000 mkdir -p $mountpoint/etc2001 1964 [ -e "$MINDI_LIB/memdisk" ] && cp -f $MINDI_LIB/memdisk $mountpoint 2>> $LOGFILE 1965 1966 cp `dirname $kernelpath`/*.efi $mountpoint 2>> $LOGFILE 2002 1967 umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)" 2003 1968 echo -en "..." … … 2006 1971 if [ "$retval" -eq "0" ] ; then 2007 1972 echo -en "...$DONE\n" 2008 if [ "$KERN_DISK_MADE" ] ; then 2009 [ "$imagefile" != "" ] && rm -f $imagefile 2010 LogAll "INFO: $BOOT_SIZE KB boot disks were created OK\n" 2011 fi 1973 LogAll "INFO: $BOOT_SIZE KB boot disks were created OK\n" 2012 1974 else 2013 1975 echo -en "...failed\n" 2014 1976 LogAll "WARNING: $BOOT_SIZE""KB boot disk was NOT created\n" 2015 [ "$imagefile" != "" ] && rm -f $imagefile2016 fi1977 fi 1978 [ "$imagefile" != "" ] && rm -f $imagefile 2017 1979 [ "$retval" -ne "0" ] && LogAll "ERROR: PrepareBootDiskImage() is returning nonzero" 2018 1980 return $retval 2019 1981 } 2020 2021 1982 2022 1983 ParseModprobeForIncludes() { … … 3280 3241 done 3281 3242 3282 KERN_DISK_MADE=""3283 3284 3243 LogFile "DIFFERENTIAL = $DIFFERENTIAL" 3285 3244 LogFile "INTERNAL TAPE BLOCK SIZE = $INTERNAL_TAPE_BLOCK_SIZE" … … 3330 3289 3331 3290 LogFile "INFO: Ramdisk will be $ramdisk_size KB" 3332 if [ "$ARCH" = "ia64" ] ; then 3333 PrepareBootDiskImage_LILO $kernelpath || Die "Failed to create ia64 image disk image." 3334 else 3335 PrepareBootDiskImage_ISOLINUX $kernelpath || Die "Failed to create $ramdisk_size KB disk image." 3336 fi 3291 PrepareBootDiskImage $kernelpath || Die "Failed to create boot disk image." 3337 3292 3338 3293 [ -e "$MINDI_LIB/memtest.img" ] && BOOT_MEDIA_MESSAGE="$BOOT_MEDIA_MESSAGE\n\ -
branches/3.2/mondo/src/common/libmondo-devices.c
r3395 r3398 2126 2126 if (fd != NULL) { 2127 2127 ret = UEFI; 2128 log_msg(2, "UEFI boot mode detected"); 2128 2129 closedir(fd); 2129 2130 } -
branches/3.2/mondo/src/mondorestore/mondo-prep.c
r3380 r3398 798 798 #else 799 799 #ifdef __IA64__ 800 /* For EFI partitions take fat16800 /* For EFI or UEFI partitions take fat16 801 801 * as we want to make small ones */ 802 802 mr_asprintf(program, "mkfs -t %s -F 16 %s", format, device);
Note:
See TracChangeset
for help on using the changeset viewer.