LoginSignup
2
1

More than 5 years have passed since last update.

BitVisorをUbuntu 18.04.1でビルドしてUEFIブートする(GRUB2)

Last updated at Posted at 2018-11-20

必要なパッケージをインストールする

sudo apt -y install mercurial make gcc mingw-w64

レポジトリをcloneしてビルドする

$ hg clone https://bitbucket.org/bitvisor/bitvisor
$ cd bitvisor
$ make config
$ make
$ make -C boot/loader
$ make -C boot/uefi-loader

ファイルシステムを調べる

/dev/sda1がファイルシステムでマウントポイントが/boot/efiであることがわかる.

moly@yayoi:~$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/ubuntu--vg-root /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sda1 during installation
UUID=D9A0-E1B5  /boot/efi       vfat    umask=0077      0       1
/dev/mapper/ubuntu--vg-swap_1 none            swap    sw              0       0

ビルドした結果をマウントポイントに格納する

先程確認したマウントポイント/boot/efiにビルドした産物をコピーする.

sudo cp bitvisor.elf /boot/efi
sudo cp boot/uefi-loader/loadvmm.efi /boot/efi

GRUB2の設定ファイルを書く

設定ファイルは/etc/grub.d/99_bitvisorなど適当に名付ける.
BitVisorの開発者メーリングリスト によると,multibootではBIOSモードで起動してしまうので,chainloadを使用する必要があるらしい.

#!/bin/sh
set -e

datarootdir="/usr/share"

. "${datarootdir}/grub/grub-mkconfig_lib"

if [ \! -f /boot/efi/bitvisor.elf ]; then
    exit 0
fi

if [ \! -f /boot/efi/loadvmm.efi ]; then
    exit 0
fi

echo "Found BitVisor image" >&2

cat << EOF
menuentry "BitVisor" {
    echo 'Loading Bitvisor ...'
    insmod chain
    insmod part_gpt
    insmod search_fs_uuid
    search --fs-uuid --no-floppy --set=root ここにさっき調べたUUIDを書く
    chainloader (\${root})/loadvmm.efi
    boot
}
EOF

GRUB2の設定を反映させる

sudo update-grub2
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1