bug-grub
[Top][All Lists]
Advanced

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

grub-install fails when installing into a loopback created by kpartx


From: David A Dunn
Subject: grub-install fails when installing into a loopback created by kpartx
Date: Sun, 17 Nov 2013 12:10:12 -0800

I need to create a full GPT disk image in a file and install grub into that image.

When doing so, grub-install fails due to problems in grub-probe handling of /dev/mapper/disk0part2.

This seems to be a bug in grub since the documentation implies this will work properly.  The script attached below can be used with Ubuntu 12.04 to reproduce the issue.

Thanks,

Dave Dunn

This is the output from the grub-probe you requested:

/usr/sbin/grub-probe: error: cannot find a GRUB drive for /dev/mapper/loop0part2.  Check your device.map.
Auto-detection of a filesystem of /dev/mapper/loop0part2 failed.
Try with --recheck.
If the problem persists please report this together with the output of "/usr/sbin/grub-probe --device-map="mnt/boot/grub/device.map" --target=fs -v mnt/boot/grub" to <address@hidden>
-- doing what the error message says to do --
grub-probe: info: Cannot stat `/dev/loop0part1', skipping.
grub-probe: info: Cannot stat `/dev/loop0part2', skipping.
grub-probe: info: Scanning for dmraid_nv RAID devices on disk hd0.
grub-probe: info: the size of hd0 is 2097152.
grub-probe: info: the size of hd0 is 2097152.
grub-probe: info: scanning hd0 for LVM.
grub-probe: info: the size of hd0 is 2097152.
grub-probe: info: no LVM signature found.
grub-probe: info: the size of hd0 is 2097152.
grub-probe: info: Scanning for mdraid09 RAID devices on disk hd0.
grub-probe: info: the size of hd0 is 2097152.
grub-probe: info: the size of hd0 is 2097152.
grub-probe: info: Scanning for mdraid1x RAID devices on disk hd0.
grub-probe: info: the size of hd0 is 2097152.
grub-probe: info: the size of hd0 is 2097152.
grub-probe: info: Scanning for mdraid09 RAID devices on disk hd0.
grub-probe: info: the size of hd0 is 2097152.
grub-probe: info: the size of hd0 is 2097152.
grub-probe: info: Scanning for mdraid09 RAID devices on disk hd0,gpt2.
grub-probe: info: the size of hd0 is 2097152.
grub-probe: info: Scanning for mdraid09 RAID devices on disk hd0,gpt1.
grub-probe: info: the size of hd0 is 2097152.
grub-probe: info: Scanning for mdraid1x RAID devices on disk hd0.
grub-probe: info: the size of hd0 is 2097152.
grub-probe: info: the size of hd0 is 2097152.
grub-probe: info: Scanning for mdraid1x RAID devices on disk hd0,gpt2.
grub-probe: info: the size of hd0 is 2097152.
grub-probe: info: Scanning for mdraid1x RAID devices on disk hd0,gpt1.
grub-probe: info: the size of hd0 is 2097152.
grub-probe: info: scanning hd0 for LVM.
grub-probe: info: the size of hd0 is 2097152.
grub-probe: info: no LVM signature found.
grub-probe: info: the size of hd0 is 2097152.
grub-probe: info: scanning hd0,gpt2 for LVM.
grub-probe: info: the size of hd0 is 2097152.
grub-probe: info: no LVM signature found.
grub-probe: info: scanning hd0,gpt1 for LVM.
grub-probe: info: the size of hd0 is 2097152.
grub-probe: info: no LVM signature found.
grub-probe: info: changing current directory to /dev/mapper.
grub-probe: info: changing current directory to /dev/mapper.
grub-probe: info: changing current directory to /dev/mapper.
grub-probe: info: no mapping exists for `/dev/mapper/loop0part2'.
grub-probe: error: cannot find a GRUB drive for /dev/mapper/loop0part2.  Check your device.map.

And this is a full script that you can use on Ubuntu 12.04 to reproduce the problem:
#!/bin/bash

# script to install grub into loopback image with GPT partitions

# there is no /boot/grub/grub.cfg, so expected result in is a non-rescue
# grub prompt

# create 1gb empty image
rm disk.img
dd if=/dev/zero of=disk.img bs=1024 count=1048576

# create partitions
    # mark this as a gpt disk
    parted -s -- disk.img mklabel gpt

    # add bios_grub partition
    parted -s -- disk.img mkpart grub 2MiB 3MiB
    parted -s -- disk.img set 1 bios_grub on

    # add normal partition
    parted -s -- disk.img mkpart linux 3MiB -0
    sync

    # verify the partitions
    parted -s -- disk.img unit MiB print

# map and format the partitions
loop=loop0
    # map into /dev/loop0 and /dev/mapper/loop0part[12]
    kpartx -avg -p part disk.img

    # format /dev/mapper/loop0part1 as ext4
    mkfs.ext4 -L linux /dev/mapper/${loop}part2
    sync

    # mount 
    mkdir -p mnt
    mount /dev/mapper/${loop}part2 mnt
    mkdir -p mnt/boot/grub

# install grub (this doesn't work)
    # create a device.map to be used during grub install
    rm -f device.map
    echo "(hd0) /dev/${loop}" >> device.map
    echo "(hd0,1) /dev/${loop}part1" >> device.map
    echo "(hd0,2) /dev/${loop}part2" >> device.map

    # grub install to loop0
    echo
    echo "-- invoking grub-install --"
    grub-install --grub-mkdevicemap="device.map" --boot-directory=mnt/boot /dev/${loop}

    echo "-- doing what the error message says to do --"
    grub-probe --device-map="device.map" --target=fs -v mnt/boot/grub

# cleanup mounts and loopback
echo "--- all done, cleaning up ---"
umount mnt
sleep 5
dmsetup remove /dev/mapper/${loop}part1
dmsetup remove /dev/mapper/${loop}part2
losetup -d /dev/${loop}


reply via email to

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