Hi, I'm trying to install grub into a hard disk image, however I'm encountering a problem. Below are the steps I've taken to create the disk image, partition it, create the file system, and copy the grub images into it. At the end are the grub commands I use to attempt to install grub into the image. There should be enough info to reproduce what I did. All of this was done on Mandrake 10.1 (important detail; 2.6.8.1-20mdk kernel, grub 0.95) The error message I get from grub is shown below the last command I use.
Can anyone offer any help or suggestion? Thanks, Nick # # Building a raw disk image # # bytes per sector bytes=512 # sectors per track sectors=63 # heads per track heads=16 # bytes per cylinder is bytes*sectors*head bpc=$(( bytes*sectors*heads )) # number of cylinders # For a image of $size MB, cylinders = (($size*1024*1024)/$bpc) size=200 cylinders=$(( ($size*1024*1024) / $bpc )) # Path to disk image image="/home/nicbrown/Software/disk.img" # Path to location to mount image mount="/home/nicbrown/Software/dev-partition" # Create raw disk image dd if=/dev/zero of=$image bs=$bpc count=$cylinders # Attach image as raw device and partition it losetup /dev/loop0 $image fdisk -u -C$cylinders -S$sectors -H$heads /dev/loop0 # Create a ext2 partition # With commands like these; # o n p 1 <return> <return> a 1 p w # Note the start sector and block count of partition # start=63 # count=204592 losetup -d /dev/loop0 # Mount a specfic parition offset=$(( start*bytes )) losetup -o$offset /dev/loop0 $image # Format the partition mke2fs -o hurd -b1024 /dev/loop0 $count # Mount the partition mount -tauto /dev/loop0 $mount # Unmount the partition umount /dev/loop0 losetup -d /dev/loop0 # # Installing GRUB into the raw disk image # # Easy mounting mount -tauto -oloop=/dev/loop0,offset=$offset $image $mount # Copy across needed grub images cd $mount mkdir -p boot/grub cd /boot/grub cp stage1 stage2 e2fs_stage1_5 $mount/boot/grub cd sync umount -d $mount # Install grub losetup /dev/loop0 $image grub # Commands like this; # device (hd0) /dev/loop0 # geometry (hd0) $cylinders $heads $sectors # root (hd0,0) # setup (hd0) grub> setup (hd0) Checking if "/boot/grub/stage1" exists... yes Checking if "/boot/grub/stage2" exists... yes Checking if "/boot/grub/e2fs_stage1_5" exists... yes Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 22 sectors are embedded. succeeded Running "install /boot/grub/stage1 (hd0) (hd0)1+22 p (hd0,0)/boot/grub/stage2 /boot/grub/menu.lst"... failed Error 22: No such partition _______________________________________________ Bug-grub mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-grub
