From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1JGzvP-0004O0-KR for mharc-grub-devel@gnu.org; Mon, 21 Jan 2008 11:55:07 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JGzvO-0004No-9G for grub-devel@gnu.org; Mon, 21 Jan 2008 11:55:06 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JGzvM-0004NP-Qa for grub-devel@gnu.org; Mon, 21 Jan 2008 11:55:06 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JGzvM-0004NG-MO for grub-devel@gnu.org; Mon, 21 Jan 2008 11:55:04 -0500 Received: from aybabtu.com ([69.60.117.155]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JGzvJ-0000vJ-Iy for grub-devel@gnu.org; Mon, 21 Jan 2008 11:55:04 -0500 Received: from [192.168.10.6] (helo=thorin) by aybabtu.com with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1JGzuo-0000nR-55 for grub-devel@gnu.org; Mon, 21 Jan 2008 17:54:51 +0100 Received: from rmh by thorin with local (Exim 4.63) (envelope-from ) id 1JGzsX-0000fg-9Q for grub-devel@gnu.org; Mon, 21 Jan 2008 17:52:09 +0100 Date: Mon, 21 Jan 2008 17:52:09 +0100 From: Robert Millan To: grub-devel@gnu.org Message-ID: <20080121165209.GA2557@thorin> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="YZ5djTAD1cGYuMQK" Content-Disposition: inline Content-Transfer-Encoding: 8bit Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.13 (2006-08-11) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [PATCH] memdisk + grub-mkrescue X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jan 2008 16:55:06 -0000 --YZ5djTAD1cGYuMQK Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit These two were predestined to get together.. attached patch for their wedding. Comments? -- Robert Millan I know my rights; I want my phone call! What use is a phone call… if you are unable to speak? (as seen on /.) --YZ5djTAD1cGYuMQK Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="memdisk_and_mkrescue_marriage.diff" * kern/i386/pc/init.c (make_install_device): When memdisk image is present, "(memdisk)/boot/grub" becomes the default prefix. * util/i386/pc/grub-mkrescue.in: Switch to a minimal core.img plus a memdisk tarball with all the modules. Add --overlay=DIR option that allows users to overlay additional files into the image. diff -x '*~' -x '*.mk' -Nurp grub2/kern/i386/pc/init.c memdisk/kern/i386/pc/init.c --- grub2/kern/i386/pc/init.c 2008-01-21 00:41:58.000000000 +0100 +++ memdisk/kern/i386/pc/init.c 2008-01-21 16:54:55.000000000 +0100 @@ -64,7 +64,12 @@ make_install_device (void) /* XXX: This should be enough. */ char dev[100]; - if (grub_install_dos_part != -2) + if (grub_memdisk_image_size) + { + grub_sprintf (dev, "(memdisk)%s", grub_prefix); + grub_strcpy (grub_prefix, dev); + } + else if (grub_install_dos_part != -2) { grub_sprintf (dev, "(%cd%u", (grub_boot_drive & 0x80) ? 'h' : 'f', diff -x '*~' -x '*.mk' -Nurp grub2/util/i386/pc/grub-mkrescue.in memdisk/util/i386/pc/grub-mkrescue.in --- grub2/util/i386/pc/grub-mkrescue.in 2007-07-22 01:32:32.000000000 +0200 +++ memdisk/util/i386/pc/grub-mkrescue.in 2008-01-21 17:46:04.000000000 +0100 @@ -42,6 +42,7 @@ Make GRUB rescue image. -h, --help print this message and exit -v, --version print the version information and exit --modules=MODULES pre-load specified modules MODULES + --overlay=DIR overlay directory DIR in the memdisk image --pkglibdir=DIR use images from directory DIR instead of ${pkglibdir} --grub-mkimage=FILE use FILE as grub-mkimage --image-type=TYPE select floppy or cdrom (default) @@ -67,6 +68,8 @@ for option in "$@"; do exit 0 ;; --modules=*) modules=`echo "$option" | sed 's/--modules=//'` ;; + --overlay=*) + overlay=`echo "$option" | sed 's/--overlay=//'` ;; --pkglibdir=*) input_dir=`echo "$option" | sed 's/--pkglibdir=//'` ;; --grub-mkimage=*) @@ -99,18 +102,29 @@ if test "x$output_image" = x; then exit 1 fi -if [ "x${modules}" = "x" ] ; then - modules=`cd ${input_dir}/ && ls *.mod` -fi - if [ "x${image_type}" = "xfloppy" ] ; then floppy_image=${output_image} else floppy_image=`mktemp` fi +memdisk_dir=`mktemp -d` +mkdir -p ${memdisk_dir}/boot/grub +cp ${input_dir}/*.mod \ + ${input_dir}/command.lst ${input_dir}/moddep.lst ${input_dir}/fs.lst \ + ${memdisk_dir}/boot/grub/ + +if test "x$overlay" = x ; then : ; else + cp -dpR ${overlay}/* ${memdisk_dir}/ +fi + +memdisk_img=`mktemp` +tar -C ${memdisk_dir} -cf ${memdisk_img} boot +rm -rf ${memdisk_dir} + core_img=`mktemp` -${grub_mkimage} -d ${input_dir}/ -o ${core_img} ${modules} +${grub_mkimage} -d ${input_dir}/ -m ${memdisk_img} -o ${core_img} memdisk cpio biosdisk ${modules} +rm -f ${memdisk_img} cat ${input_dir}/boot.img ${core_img} /dev/zero | dd bs=1024 count=1440 > $floppy_image rm -f ${core_img} --YZ5djTAD1cGYuMQK--