Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1IawBp-0004OW-US for mharc-grub-devel@gnu.org; Thu, 27 Sep 2007 12:26:13 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IawBo-0004O9-HC for grub-devel@gnu.org; Thu, 27 Sep 2007 12:26:12 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IawBn-0004Nf-Ts for grub-devel@gnu.org; Thu, 27 Sep 2007 12:26:12 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IawBn-0004Nc-MD for grub-devel@gnu.org; Thu, 27 Sep 2007 12:26:11 -0400 Received: from nf-out-0910.google.com ([64.233.182.188]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IawBn-0008P8-2p for grub-devel@gnu.org; Thu, 27 Sep 2007 12:26:11 -0400 Received: by nf-out-0910.google.com with SMTP id f5so2068121nfh for ; Thu, 27 Sep 2007 09:26:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=wy21wAwDXI2pCnQj6yccIo8Fg6y0vVc/qWMvYKjRhDw=; b=g/YbF9vRAS2UutJIrv+LrB5uhzraloeCIqQbD7RJdFgIwMTs4hfRv1Ij/UxLZ3zGot2ruiDlPGrWd9qBYHMK3nRyjuRM4JNONInu/BLu9qTZ+KxuMkSo/X4m6EiRIJzO3PPtFswBnxgCe62UtwWcM5BzBtPw1ihYuTtBA154AwQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=bFLM3VQjIP2bhYnPS8+eNAcq/PhRLDv+/JywlnnaFSXHx0C+y9lqBQ0lhk1UJ8HAmUNRYFPrOOTXqeStqDk0HIPIvcKHCbeIzmhl8czvf+FqsdvB1L2kunrPO+NYKA3UkO8E6GOw79i4reTPH5al17VIhg6piiwHW0slgej97GY= Received: by 10.78.132.2 with SMTP id f2mr1990837hud.1190910357639; Thu, 27 Sep 2007 09:25:57 -0700 (PDT) Received: by 10.78.180.19 with HTTP; Thu, 27 Sep 2007 09:25:57 -0700 (PDT) Message-ID: Date: Thu, 27 Sep 2007 13:25:57 -0300 From: "Eduardo Ochs" To: grub-devel@gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Detected-Kernel: Linux 2.6 (newer, 2) Subject: Installing grub on an HD image 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: Thu, 27 Sep 2007 16:26:12 -0000 Hi list, Maybe I'm missing something basic, but how do I install grub (preferably grub2) on an HD image that will later be used as an hd0 on a Flash IDE adapter? Here's what I'm trying to do (the real script is at ): --snip--snip-- # Create a zeroed HD image with 20MB rm -v /tmp/test.img dd if=/dev/zero of=/tmp/test.img bs=1M count=20 # Create two primary partitions: 1st=4M, 2nd=16MB sudo fdisk -C 20 -H 64 -S 32 /tmp/test.img n p 1 4 n p 2 20 u p w # Some notes about how to get the offsets for "losetup -o", # and the sizes of the partitions for mke2fs... # (find-sh "echo -e 'u\\np\\nq' | sudo fdisk /tmp/test.img") # 64 heads, 32 sectors/track, 0 cylinders, total 0 sectors # Units = sectors of 1 * 512 = 512 bytes # Device Boot Start End Blocks Id System # /tmp/test.img1 32 8191 4080 83 Linux # /tmp/test.img2 8192 40959 16384 83 Linux # Sizes, in 512-byte blocks: # (list "/tmp/test.img1" (+ -32 8191 1) (* 4080 2)) # (list "/tmp/test.img2" (+ -8192 40959 1) (* 16384 2)) # Associate the full image to a loop device # (grub-setup may need this) sudo losetup -f | tee /tmp/test.dev0 sudo losetup $(cat /tmp/test.dev0) /tmp/test.img # Associate the first partition to a loop device, # clear it, make an ext2 filesystem there, mount it. sudo losetup -f | tee /tmp/test.dev1 sudo losetup -o $[512*32] $(cat /tmp/test.dev1) /tmp/test.img sudo dd if=/dev/zero of=$(cat /tmp/test.dev1) bs=1024 count=4080 sudo mke2fs -b 1024 -v $(cat /tmp/test.dev1) 4080 mkdir /tmp/dev1 sudo mount -o loop $(cat /tmp/test.dev1) /tmp/dev1 # Associate the second partition to a loop device, # clear it, make an ext2 filesystem there, mount it. sudo losetup -f | tee /tmp/test.dev2 sudo losetup -o $[512*8192] $(cat /tmp/test.dev2) /tmp/test.img sudo dd if=/dev/zero of=$(cat /tmp/test.dev2) bs=1024 count=16384 sudo mke2fs -b 1024 -v $(cat /tmp/test.dev2) 16384 mkdir /tmp/dev2 sudo mount -o loop $(cat /tmp/test.dev2) /tmp/dev2 df # Now copy the grub files to /tmp/dev1/boot/grub/ # and install grub on MBR of the HD image. # (Omitted - my attempts to install grub on the image have failed!...) # Umount, release loop devices sudo umount /tmp/dev1 sudo umount /tmp/dev2 sudo losetup -d $(cat /tmp/test.dev2) 2>&1 > /dev/null sudo losetup -d $(cat /tmp/test.dev1) 2>&1 > /dev/null sudo losetup -d $(cat /tmp/test.dev0) 2>&1 > /dev/null --snip--snip-- By the way, after installing grub on the image the next steps are: * try to boot from that HD image with qemu, * make sure that grub recognizes the two partitions, * extract a linux kernel and an initrd from a certain liveCD (http://www.devil-linux.org/) and put them in the first partition, * enlarge the HD size to 256MB, * copy the CD image to the second partition (so that it cease to be ext2 and will become a compressed iso) * change the /linuxrc onthe initrd to make it start an interactive shell, * use that shell to mount (manually) the CD image from /dev/hda2 instead of from a CD device, and then try to run pivotroot into it to run the liveCD, * change the CD detection functions in the /linuxrc script to make them handle a boot parameter like "cddevice=/dev/hda2". If this works well then we will be able to run small liveCD images (Devil Linux is ~ 200MB) on scrap machines that have no CD drive and no HD, just by putting a 256MB flash IDE adapter on them... Cheers, Eduardo Ochs eduardoochs@gmail.com http://angg.twu.net/