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: Jordan Uggla
Subject: Re: Installing GRUB to drive image
Date: Thu, 29 Mar 2012 02:00:06 -0700

On Wed, Mar 28, 2012 at 10:32 PM, Charles Yost <address@hidden> wrote:
> Here are the commands I used.
>
> #!/bin/bash
> # disk is a 1GB image, with 4 primary partitions, starting at: 1049kB,
> 50M, 71M, 547M
> # grub is compiled and waiting in the the grub directory next to disk.img
> IMAGE_FILE=disk.img
> IMAGE_FILE_LOOP=$(losetup --find)
> IMAGE_FILE_LOOP_BASE=$(basename ${IMAGE_FILE_LOOP})
> losetup --verbose ${IMAGE_FILE_LOOP} ${IMAGE_FILE}

I can understand this use of losetup in the script, and only this use,
because this is a script and using "losetup --find" you can
conveniently and safely store the loop device being used for later in
the script. If it were not in a script then I would simply do "kpartx
-a -v /path/to/image" and let kpartx setup the loopback device as well
since it's one less step to worry about.

> BOOT_LOOP=$(losetup --find)
> losetup --verbose ${BOOT_LOOP} /dev/mapper/${IMAGE_FILE_BASENAME}p1

I explicitly said not to do this and this is what is causing the
problem. Just do

mount /dev/mapper/${IMAGE_FILE_BASENAME}p1 /mnt/disk_image-boot

> cp grub/* /mnt/disk_image-os

If the grub directory referenced here contains anything other than a
grub.cfg file then I am suspicious that you're doing something wrong.
grub-install will create and populate the grub directory itself, you
should *not* be copying around grub's modules manually. Having a
pre-populated grub directory won't prevent grub-install from working
as it will overwrite files as needed, but you should still remove this
cp command to avoid confusing yourself or others.

-- 
Jordan Uggla (Jordan_U on irc.freenode.net)



reply via email to

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