title: GRUB2 -> Buildroot: Segmentation fault in grub-bios-setup
body: <p>I'm working on <strong>Ubuntu 17.04</strong> on <strong>Buildroot-2017.05.2</strong> (my config: <a href="http://dropmefiles.com/yhDMi" rel="nofollow noreferrer">is here</a>) and want to use as bootloader <strong>GRUB2</strong>.</p>
  
  <p>I built the buildroot and I'm following build-in instruction:</p>
  
  <pre><code>dd if=/dev/zero of=170831_disk_1.img bs=1M count=300
  cfdisk 170831_disk_1.img
       dos -&gt; primary &amp; bootable &amp; 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
  </code></pre>
  
  <p>And after that run (current directory just in case: <em>/home/user/buildroot/buildroot-2017.05.02/output/images/170831/</em>): </p>
  
  <pre><code>sudo ../../host/usr/sbin/grub-bios-setup  -b ../../host/usr/lib/grub/i386-pc/boot.img -c grub.img -d . /dev/loop0
  </code></pre>
  
  <p>And I get the following error (verbose mode):</p>
  
  <pre><code>./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)
  </code></pre>