[Top][All Lists]

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

Failure of grub-install to auto-insert needed module

From: Jake Thomas
Subject: Failure of grub-install to auto-insert needed module
Date: Sat, 26 May 2012 19:31:20 -0700

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
sudo losetup -o1020264448 --sizelimit 1048576 /dev/loop2
sudo losetup -o1022361600 --sizelimit 26214400 /dev/loop3

The "-o" is the offset, which is the first byte to be connected to the
abstraction file. This is simply the "Start (sector)" times 512, since
there are 512 bytes
in a sector (at least these ones).

The "--sizelimit" keeps it from going until the end of the image file
(which would be catastrophic, very similar to a switch-case with no
breaks). This is simply
determined by taking the size of the partition, provided by gdisk's
printout, which is in mebibytes (MiB), except for the middle one,
which is in kibibytes (KiB),
multiplying the mebibytes by 1024 to get kibibytes, then by 1024 again
to get bytes. Partition #2's provided size is obviously only
multiplied by 1024 once.

I used mkfs.ext3 to format the first partition, now represented by /dev/loop1:
sudo mkfs.ext3 -L play1 /dev/loop1

And mkdosfs to format the 3rd partition as FAT16:
sudo mkdosfs -F 16 -n ESP /dev/loop3

Then I made directories to mount the partitions to:
sudo mkdir /media/play1
(and /media/esp already existed from prior experiments)

Then I mounted them:
sudo mount -o users /dev/loop1 /media/play1

//Gives me permission to my mount:
sudo chmod 777 -R /media/play1

sudo mount -o users /dev/loop3 /media/esp
sudo chmod 777 -R /media/esp

Then I installed grub2.00~beta5 to /dev/loop0:
sudo grub-install --boot-directory=/media/play1 /dev/loop0

Then I added CH.jpg and unicode.pf2 to /media/play1, and this grub.cfg:

# BIOS Grub2 config file

set timeout=-1
search --no-floppy --fs-uuid --set=root 51a92edb-0839-4b31-9cfb-7adf0b0af5a5
set debug=video
insmod vbe
loadfont /grub/unicode.pf2
set gfxmode=3488x2228
set gfxmode=keep
insmod gfxterm
terminal_output gfxterm
terminal gfxterm
insmod gettext
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
insmod jpeg
background_image /grub/CH.jpg

menuentry "ArchBang 64-Bit Live (install_ER_)"{
        linux /arch64/boot/x86_64/vmlinuz archisobasedir=arch64 
        initrd /arch64/boot/x86_64/archiso.img

*NOTICE* I made a mistake, archisolabel should have been set to
"play1", but I had copied and pasted this grub entry from a grub.cfg I
made before, and
overlooked that I needed to change it. It is now corrected. I don't
think it has to do with the problem.

I did "sudo blkid /dev/loop1" to acquire the UUID in the "search
--no-floppy --fs........" line.

And, of course, I copied the appropriate stuff out of the ArchBang iso
to the first partition, linked to /dev/loop1.

Then I did:
qemu -hda '/home/shjake/Desktop/playimage'

The window came up, and it said that no such whatever exists:
I was put at a grub command line.

I re-verifed with blkid, and this is in fact the UUID of the partition.

I suspected that either the ext2 or the part_gpt module was not
loaded. At the grub-command line, I did "ls". All I got was: (hd0).

Yep. No part_gpt module pre-loaded. And of course I can't do "insmod
part_gpt" because I can't get to the part_gpt file.

I tried installing again like this:
sudo grub-install --boot-directory=/media/play1 --modules=part_gpt /dev/loop0

And Grub got further. Honestly, it's still not loading the ArchBang
64-bit installer, but I think that might be me messing up. Looks like
Grub works and
ArchBang or my config file doesn't. The background loaded, the text
menu showed up, up and down arrow key selection works, can hit c to
get to command line
then esc to get back to the menu, looks pretty good Grub-wise.


P.S. Please consider adding the following to grub-install's help
output: To specify more than one module to be pre-loaded, they must be
surrounded by quotes, and the delimiter is a space. One space. No
comma. Double quotes. Like the following:

--modules="part_gpt ext2"

Because that's an inconvenient number of possible combinations to go
through to figure that out. Here's what I tried before getting the
right 6 numbers:

--modules=part_gpt ext2
--modules=part_gpt, ext2
--modules="part_gpt, ext2"

and then finially: --modules="part_gpt ext2", which worked. One space.
No comma. Double quotes.

If you're a terminal guru, maybe that would be obvious. Apparently,
not everyone is a terminal guru.

P.P.S The reason I'm doing this is because there is a bug in the
version of QEMU I have that makes it freeze at the ISOLINUX
bootloader, so I can't just boot the ArchBang installer iso.
VirtualBox boots it just fine, but the virtual machine in VirtualBox
crashes everytime I run rankmirrors. So, in my effort to deduce
whether this is a VirtualBox bug or a bug within ArchBang, I decided
I'd simply try it out in QEMU. If QEMU crahses, it's probably
something in ArchBang. If not, it's a VirtualBox bug. But due to
QEMU's ISOLINUX bug, I have this extra step, yeilding another bug.

I tried compiling newer QEMU from source, both out of the git and the
latest released tarball. Couldn't get past make. Not even with
--disable-werror, which is the secret to compiling Grub. I am using
the latest QEMU in the ubuntu repository.

reply via email to

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