LoginSignup
3
1

More than 5 years have passed since last update.

vmrcでvmを起動してみる

Last updated at Posted at 2015-12-05

vmrcはハイパーバイザーであるbhyve及びXenを管理するためのスクリプトです。vmrcのインストールから仮想マシンの起動までを試してみます。

vmrc

v0.9 betaで記事を書いていて、vmの起動まではできたのですが、OSが起動しませんでした。治り次第記事を修正するので、現時点では触りまでということで。

実行環境

  • FreeBSD 10.2
  • vmrc v0.9
  • ハイパーバイザー bhyve

0.8.9から0.9にかけて大きな変更が行われました。Xenの対応もv0.9からになります。ただ、Xenは試していません。

michaeldexter/vmrc · GitHub

vmrcのインストール

% git clone https://github.com/michaeldexter/vmrc

% sudo sh install-vmrc.sh

Running cp vm /usr/local/etc/rc.d/

Running chmod o+x /usr/local/etc/rc.d/vm

Running chmod a-w /usr/local/etc/rc.d/vm

Running cp vm.conf /usr/local/etc/

Creating /usr/local/vmrc directories

Running cp -p templates/centos7iso templates/debian8amd64iso templates/fbsd11amd64img templates/fbsd11amd64iso templates/master_template templates/nbsd615amd64iso templates/nbsd7iso templates/obsd57amd64img templates/obsd57amd64iso templates/old templates/win2016iso /vmrc/templates/
cp: templates/old is a directory (not copied).

Running cp -p mkvm.sh mkvm.sh.functions /vmrc/

Running cp -p vmrcd /vmrc/

Running chmod o+x /vmrc/vmrcd

At a minimum, verify the network device in /usr/local/etc/vm.conf

/vmrc配下にテンプレート、仮想マシンの設定ファイル、イメージのマウントポイントが作成されます。コメントが間違ってますね、/usr/local/vmrcではなく/vmrcに作成されます。v0.8.9までは/usr/localでしたが。

vmrcの設定

/usr/local/etc/vm.confをいじります。

# Host configuration file for vmrc

host_zpool="bhyve"                      # Host zpool
host_templates="/vmrc/templates/"       # VM Templates
host_distdir="/vmrc/distributions/"     # OS Distributions
host_vmdir="/vmrc/vm/"          # VM configurations, images and mount points

# Auto-configured bridges for simple bhyve configurations starting at bridge0
# and incrementing sequentially. If absent, bridges requested by VMs will be
# assumed to pre-exist on the host.

bridge0nic="em0"                        # The hardware NIC to add
#bridge1="em1 02:00:00:00:00:00"        # Optional MAC address for the bridge

# VNC Listen Address for Xen
vnc_ip="0.0.0.0"

# Logging methods:
info_method="logger"                    # "stdio", "quiet" or "logger"
error_method="logger"                   # "stdio", "quiet" or "logger"

問題ないのでこのまま行きます。

vmの作成

既存のテンプレートはリンク切れでした。以下の通り修正します。

% diff -u /vmrc/templates/fbsd11amd64img /vmrc/templates/fbsd11amd64img.old
--- /vmrc/templates/fbsd11amd64img      2015-12-05 17:24:02.393914628 +0900
+++ /vmrc/templates/fbsd11amd64img.old  2015-10-16 14:49:36.000000000 +0900
@@ -3,12 +3,12 @@

 # Provisioning Variables (See FreeBSD-specific VM provisioning variables below)
 install_method="img"      # "raw", "iso", "img", "distset" or "obj"
-install_site="ftp://ftp.jpix.ad.jp"
+install_site="ftp://freebsd.org"
                           # Distribution payload site i.e. ftp://ftp.freebsd.org
 #install_site="file://"   # Local payload option once downloaded (choose one)
 site_path="/pub/FreeBSD/snapshots/ISO-IMAGES/11.0/"
                           # Distribution payload directory path
-site_payload="FreeBSD-11.0-CURRENT-amd64-20151130-r291495-memstick.img.xz"
+site_payload="FreeBSD-11.0-CURRENT-amd64-20150903-r287437-memstick.img.xz"
                           # Distribution payload file(s) (space separated)
 bootrom_site=""           # bhyve and QEMU bootrom payload site
 bootrom_path=""           # bootrom payload directory path

作成します。

cd /vmrc
sudo sh mkvm.sh fbsd11amd64img freebsd

vmが作成されました。まだ空っぽですのでOSをインストールします。

OSのインストール

インストールします。

% sudo service vm oneinstall freebsd0

freebsd0の0はvmを作成するごとに増えて行きます。vm作成時に番号が表示されるので、適時置き換えてください。

コンソールにアタッチします。

% sudo service vm attach freebsd0

コンソールはtmuxです。

残念ながら、ACPI errorで起動していません。

VM:freebsd0 is not created.
Consoles: userboot

FreeBSD/amd64 User boot, Revision 1.1
(root@releng1.nyi.freebsd.org, Wed Aug 12 15:21:01 UTC 2015)
Loading /boot/defaults/loader.conf
-
  ______               ____   _____ _____
 |  ____|             |  _ \ / ____|  __ \
 | |___ _ __ ___  ___ | |_) | (___ | |  | |
 |  ___| '__/ _ \/ _ \|  _ < \___ \| |  | |
 | |   | | |  __/  __/| |_) |____) | |__| |
 | |   | | |    |    ||     |      |      |
 |_|   |_|  \___|\___||____/|_____/|_____/    ```                        `
                                             s` `.....---.......--.```   -/
 +============Welcome to FreeBSD===========+ +o   .--`         /y:`      +.
 |                                         |  yo`:.            :o      `+-
 |  1. Boot Multi User [Enter]             |   y/               -/`   -o/
 |  2. Boot [S]ingle User                  |  .-                  ::/sy+:.
 |  3. [Esc]ape to loader prompt           |  /                     `--  /
 |  4. Reboot                              | `:                          :`
 |                                         | `:                          :`
 |  Options:                               |  /                          /
 |  5. [K]ernel: kernel (1 of 2)           |  .-                        -.
 |  6. Configure Boot [O]ptions...         |   --                      -.
 |                                         |    `:`                  `:`
 |                                         |      .--             `--.
 |                                         |         .---.....----.
 +=========================================+


/boot/kernel/kernel text=0x13a1978 data=0x1346c0+0x4d8c40 syms=[0x8+0x15c030+0x8+0x17792d]
Booting...
GDB: no debug ports present
KDB: debugger backends: ddb
KDB: current backend: ddb
ACPI BIOS Error (bug): A valid RSDP was not found (20150818/tbxfroot-258)
panic: running without device atpic requires a local APIC
cpuid = 0
KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xffffffff82088b50
vpanic() at vpanic+0x182/frame 0xffffffff82088bd0
panic() at panic+0x43/frame 0xffffffff82088c30
apic_init() at apic_init+0x113/frame 0xffffffff82088c50
mi_startup() at mi_startup+0x108/frame 0xffffffff82088c70
btext() at btext+0x2c
KDB: enter: panic
[ thread pid 0 tid 0 ]
Stopped at      kdb_enter+0x3b: movq    $0,kdb_why
db>
3
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
3
1