-1

我正在Buildroot-2017.05.2上的Ubuntu 17.04上工作(我的配置:在这里)并希望用作引导加载程序GRUB2

我构建了 buildroot 并遵循内置指令:

dd if=/dev/zero of=170831_disk_1.img bs=1M count=300
cfdisk 170831_disk_1.img
     dos -> primary & bootable & 0x83
sudo losetup -f 170831_disk_1.img
sudo partx -a /dev/loop0
sudo mkfs.ext4 -L root /dev/loop0p1
sudo mount /dev/loop0p1 /mnt
sudo tar -C /mnt -xf rootfs.tar
sudo umount /mnt

之后运行(当前目录以防万一:/home/user/buildroot/buildroot-2017.05.02/output/images/170831/):

sudo ../../host/usr/sbin/grub-bios-setup  -b ../../host/usr/lib/grub/i386-pc/boot.img -c grub.img -d . /dev/loop0

我收到以下错误(详细模式):

./output/host/usr/sbin/grub-bios-setup: info: cannot open `/boot/grub/device.map': No such file or directory.
./output/host/usr/sbin/grub-bios-setup: info: Looking for /dev/loop0.
./output/host/usr/sbin/grub-bios-setup: info: /dev/loop0 is a parent of /dev/loop0.
./output/host/usr/sbin/grub-bios-setup: info: Looking for /dev/loop0.
./output/host/usr/sbin/grub-bios-setup: info: /dev/loop0 is a parent of /dev/loop0.
./output/host/usr/sbin/grub-bios-setup: info: transformed OS device `/dev/loop0' into GRUB device `hostdisk//dev/loop0'.
./output/host/usr/sbin/grub-bios-setup: info: getting the size of ././output/host/usr/lib/grub/i386-pc/boot.img.
./output/host/usr/sbin/grub-bios-setup: info: reading ././output/host/usr/lib/grub/i386-pc/boot.img.
./output/host/usr/sbin/grub-bios-setup: info: getting the size of ././output/host/usr/lib/grub/i386-pc/boot.img.
./output/host/usr/sbin/grub-bios-setup: info: getting the size of ././output/images/170831/grub.img.
./output/host/usr/sbin/grub-bios-setup: info: reading ././output/images/170831/grub.img.
./output/host/usr/sbin/grub-bios-setup: info: getting the size of ././output/images/170831/grub.img.
./output/host/usr/sbin/grub-bios-setup: info: root is `(null)', dest is `hostdisk//dev/loop0'.
./output/host/usr/sbin/grub-bios-setup: info: Opening dest.
./output/host/usr/sbin/grub-bios-setup: info: the size of hostdisk//dev/loop0 is 512000.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to /dev.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to dri.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to snd.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to by-path.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to vfio.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to hugepages.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to mqueue.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to shm.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to ubuntu-vg.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to disk.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to by-label.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to by-uuid.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to by-partuuid.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to by-path.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to by-id.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to block.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to char.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to pts.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to bsg.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to mapper.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to input.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to by-path.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to by-id.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to bus.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to usb.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to 002.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to 001.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to net.
./output/host/usr/sbin/grub-bios-setup: info: changing current directory to lightnvm.
Segmentation fault (core dumped)
4

1 回答 1

0

我没有解决这个问题,但我找到了另一个解决方案。如果您需要为 buildroot 安装 grub2,只需使用genimage并按照说明进行操作:

partition boot {
    in-partition-table = "no"
    image = "boot.img"
    offset = 0
    size = 512
    }
    partition grub {
    in-partition-table = "no"
    image = "grub.img"
    offset = 512
    }
}

此实用程序会将 GRUB2 写入您的存储。只要确保在您已经存在的分区之前有大约 1Mb 的空间。

它现在对我有用。

PS in IRC #buildroot 有人建议我重新编译所有内容并查找错误。它根本没有帮助。

于 2017-09-01T05:58:58.167 回答