[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Installing grub directly to a file



On Wed, Nov 07, 2001 at 01:38:30AM +0800, csj wrote:
> I want to burn grub, along with a kernel, onto a cdrom. My present 
> system has been to install grub to a floppy, make changes to that 
> floppy, and finally "dd" the floppy to a file, which I then set as the 
> boot image in cdrecord. Is there a way to install grub direct to a 
> floppy image file produced, say, by the following commands?
> 
> dd if=/dev/hda of=grub_boot.fdd bs=1024 count=2880
> mke2fs grub_boot.fdd
> 
> Is there a way for me to install grub directly to "grub_boot.fdd" and 
> have a file system on that file at the same time? Following the grub 
> doc, I have only been able to produce a 100K file which I can't loop 
> mount to make the changes I want:
> 
> dd if=/boot/grub/stage1 of=grub_boot.test bs=512 count=1
> dd if=/boot/grub/stage2 of=grub_boot.test bs=512 seek=1
> 
> alpha:/foo/tmp$ ls -sh
> total 3.0M
> 2.9M grub_boot.fdd  100k grub_boot.test
Try the following:

this recipe is heavily based on information provided to me by 
Petr Konecny.

first make a 2.88MB zeroed image file.
dd if=/dev/zero of=/tmp/boot288.img bs=512 count=5760

then set up the loop device.
losetup /dev/loop0 /tmp/boot288.img

then format it with the ext2 filesystem.
mke2fs /dev/loop0

mount it under /mnt.
mount /dev/loop0 /mnt

create a directory named grub.
mkdir /mnt/grub

copy the grub stage files onto the floppy image.
cp /usr/lib/grub/i386-pc/stage[12] /mnt/grub

create a device map file.
echo "(fd0) /dev/loop4" > /tmp/dev.map

install grub to the image.
/sbin/grub --device-map=/tmp/dev.map <<END
root (fd0)
setup (fd0)
END

-----<snip>------
# grub menu file menu.lst

timeout 5
title Rescue System
root (fd0)
kernel /vmlinuz root=/dev/ram0 ramdisk_size=4096 init=/linuxrc rw
-----<snap>------

now copy the initrdfs.gz and the kernel to /mnt and unmount /mnt. 
finally detach the loop device:
losetup -d /dev/loop0

voila, that's it.

HTH
-timo

-- 
gpg key fingerprint = 6832 C8EC D823 4059 0CD1  6FBF 9383 7DBD 109E 98DC

Attachment: pgpQ1Sqcn8oqI.pgp
Description: PGP signature


Reply to: