help-grub
[Top][All Lists]
Advanced

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

Re: Installing GRUB to drive image


From: Charles Yost
Subject: Re: Installing GRUB to drive image
Date: Wed, 28 Mar 2012 13:32:49 -0400

On Wed, Mar 28, 2012 at 1:38 AM, Jordan Uggla <address@hidden> wrote:
> On Tue, Mar 27, 2012 at 9:28 PM, Charles Yost <address@hidden> wrote:
>> I am attempting to install grub as the bootloader to a drive image.
>> After attempting to use grub-install, then grub-mkimage and
>> grub-setup, I cannot find a way to make it work. Can anyone help me?
>
> What commands did you run, and in what way did they "not work"? (And
> for future references this is the type of information that you should
> start with when asking for support).
>
> grub-mkrescue is probably the simplest way to make a bootable disk
> image but kpartx and grub-install should work as well (with grub 1.99
> or newer for the kpartx support).
>
Thanks for the response Jordan.
I am using grub 1.99, but I'm not sure that grub-mkrescue will do what
I want, because I'm attempting to create a bootable hard-disk image
with separate /boot and /root directories.
I used dd to create a 1GB image. Then I used parted to partition it
with 4 partitions, (partition 1 for /boot, and partition 3 as /)
1049kB-50M, 50M-71M, 71M-547M, 547M-1023MB. Next I used losetup to
find a free loop, and losetup $FREE_LOOP disk.img. Next kpartx -a
$FREE_LOOP to create block devices for the partitions. I used
mkfs.ext3 to format the partitions (such as mkfs.ext3 -b 1024 -L boot
/dev/mapper/${FREE_LOOP}p1). I then used losetup --find to select more
free loop devices, and used them to mount each partition, keeping
track of which ones I used for which partition. I then write the
device.map file using all the loops (eg: (hd0,1) /dev/loop2). Finally
I copied in all the files needed (such as all the grub files). For the
next few steps I tried several methods. Method 1: using grub-install
from the host directory, then chrooting into the mounted image and
using grub-mkconfig (eg: --modules=serial
--boot-directory=$BOOT_MOUNTPOINT --root-directory=$ROOT_MOUNTPOINT).
Method 2:  Copying in the GRUB images from /usr/lib/grub/i386-pc, then
using grub-editenv to create the grubenv file, then grub-mkimage to
create the core.img ($ROOT_MOUNTPOINT/usr/bin/grub-mkimage
--directory=$ROOT_MOUNTPOINT/usr/lib/grub/i386-pc --format=i386-pc
--output=$BOOT_MOUNTPOINT/grub/core.img --prefix="(hd0,msdos1)/grub"
biosdisk ext2 part_msdos serial), then grub-setup (eg:
$ROOT_MOUNTPOINT/usr/sbin/grub-setup --directory=$BOOT_MOUNTPOINT/grub
--device-map=$CREATED_DEV_MAP "(hd0)")
Neither of these methods worked. GRUB starts up, says "error: no such
disk" and then dumps me to the rescue prompt. And if I enter 'ls' it
shows no disks.
I hope I didn't leave anything important out.
Thanks,
=> Charles Y.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]