help-grub
[Top][All Lists]
Advanced

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

Re: Failure of grub-install to auto-insert needed module


From: Jordan Uggla
Subject: Re: Failure of grub-install to auto-insert needed module
Date: Sun, 27 May 2012 18:30:33 -0700

On Sat, May 26, 2012 at 7:31 PM, Jake Thomas <address@hidden> wrote:
> Hello. For me, grub-install failed to realise it needed to "pre-load"
> the part_gpt module when I was installing grub to a gpt-schemed
> loopback device.
> Doing "--modules=part_gpt" worked around this, but I understand that
> grub-install should automatically pre-load all needed modules.
>
> If you're wondering what the heck I'm doing with a gpt-schemed
> loopback device, and how I made it (which might be relevant to finding
> the bug?),
> here it is:
>
>
> I made a one gibibyte (not one gigabyte, one gibibyte (GiB)) file of
> all zeros using dd.
>
> I then used gdisk on it to make 3 partitions:
>
> Disk /home/shjake/Desktop/playimage: 2048000 sectors, 1000.0 MiB
> Logical sector size: 512 bytes
> Disk identifier (GUID): 7EB71814-BE3D-4980-BB0B-D6677AA1E7D4
> Partition table holds up to 128 entries
> First usable sector is 34, last usable sector is 2047966
> Partitions will be aligned on 2048-sector boundaries
> Total free space is 6110 sectors (3.0 MiB)
>
> Number  Start (sector)    End (sector)  Size       Code  Name
>   1            2048         1990655   971.0 MiB   8300  Linux filesystem
>   2         1992704         1994751   1024.0 KiB  EF02  BIOS boot partition
>   3         1996800         2047966 25.0 MiB    EF00  EFI System
>
>
> There is a 1 mebibyte space between partition 1 & 2 as well as between
> 2 & 3. One mebibyte (1 MiB) conveniently happens to exactly equal one
> 2048-sector grouping (from one sector-boundary to the next), where
> each sector is 512 bytes.
>
> I then used losetup to hook the entire image file to /dev/loop0, like this:
>
> sudo losetup /dev/loop0 '/home/shjake/Desktop/playimage'
>
> Then, using the above printout from gdisk and gnome-calculator and
> losetup, I hooked each partition to its own loopback abstraction file:
> sudo losetup -o1048576 --sizelimit 1018167296 /dev/loop1
> '/home/shjake/Desktop/playimage'
> sudo losetup -o1020264448 --sizelimit 1048576 /dev/loop2
> '/home/shjake/Desktop/playimage'
> sudo losetup -o1022361600 --sizelimit 26214400 /dev/loop3
> '/home/shjake/Desktop/playimage'

This is where you went wrong. By using losetup with offsets to make
new loop devices for each partition you made it seem to the grub
utilities as if these were actual drives rather than partitions, and
since no partition mapping is actually being done by any layer (you
entered values manually) grub's modules can't query any layer to ask
where this "partition" (which looks like a drive anyway) came from and
what partition map module is needed to access it.

The correct way to install grub to a disk image is to let kpartx
create the device nodes for each partition with either "sudo kpartx -a
/dev/loop0" or just "sudo kpartx -a /path/to/disk.img" (the latter
will setup /dev/loop0 for you as well. Then mount the partitions, like
"mount /dev/mapper/loop0p1 /mnt" and run "sudo grub-install
--boot-directory=/mnt/boot/ /dev/loop0".

Unfortunately your email was very long so I did not read much beyond
this point, if you have any more issues please (re)state them in a
reply.

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



reply via email to

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