You are not logged in.
Pages: 1
Installing grub to a image file, and run under qemu follow bellow steps. I got failed.
$ fdisk -l --bytes sys.img
Disklabel type: gpt
Disk identifier: 9CB15CF3-83C7-4D26-8EED-B3BFF89EFE9A
Device Start End Sectors Size Type
sys.img1 2048 4095 2048 1048576 BIOS boot
sys.img2 4096 61406 57311 29343232 Linux filesystem
setup loop device
$ sudo losetup -f --offset 2097152 --sizelimit 29343232 sys.img
$ losetup
NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO
/dev/loop0 29343232 2097152 0 0 /home/arm/sys.img 0
making a ext4 format
$ mkfs.ext4 /dev/loop0
Discarding device blocks: done
Creating filesystem with 28652 1k blocks and 7168 inodes
Filesystem UUID: e3e10180-9512-477b-9451-2dd0ead5af23
Superblock backups stored on blocks:
8193, 24577
Allocating group tables: done
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done
mount to /mnt for grub-install
$ sudo mount /dev/loop0 /mnt
final step, install grub
$ sudo grub-install --target=i386-pc --boot-directory=/mnt/boot sys.img
Installing for i386-pc platform.
Installation finished. No error reported.
and I launched qemu with sys.img
qemu sys.img
I get grub load fail and enter rescue mode as bellow
error: no such device: e3e10180-9512-477b-9451-2dd0ead5af23
error: unknown filesystem.
Entering rescue mode...
It's prefect work when I do those procedure on physical driver. I found the report of qemu: no such device's UUID is same as the step mkfs.ext4's result.
And the deference between image file and physical driver are loop device setup.
Should I miss something on this step?
Thanks in advance.
Last edited by liangxiao (2016-11-27 00:35:23)
Offline
It works when I load archlinux iso in qemu, and run grub-install inside qemu guest system.
Offline
Pages: 1