FreeBSD 10.2: exec: /usr/local/lib/virtualbox/VirtualBox: Permission denied

先日、64bit FreeBSD 10.2 のテスト環境でBoincを動かすために Linux エミュレーション環境を入れました。そして、その Boinc プロジェクトの中に Virtual Box で動作するプロジェクト VirtualLHC@home があり、これに参加するために、virtualbox-ose もインストールしました。

インストールは簡単で、

pkg install virtualbox-ose

とすれば、関連パッケージも含めてインストールが完了します。

Boinc はこの Virtual Box環境用のHDDイメージをダウンロードして演算を始めたようです。

せっかく Virtual Box を入れたので、私も Virtual Box を立ち上げてみようとして四苦八苦。

そもそも VirtualBox 起動コマンドが分からない。バイナリーインストールを使っているので、インストールが簡単になったものの、ドキュメントを読まなくなっていて、どこに何が入ってどんなコマンドで起動すればいいかを調べないといけないとうマイナス面がありますが、まあ、virtualbox だろうとコマンドをタイプしてみると、

% virtualbox
exec: /usr/local/lib/virtualbox/VirtualBox: Permission denied

では、virtualbox コマンドはどこにインストールされているの?オンラインマニュアルは?と、インストール状況を調べてみると、次のようになっています。

% man virtualbox
No manual entry for virtualbox

% which virtualbox
/usr/local/bin/virtualbox

% file /usr/local/bin/virtualbox
/usr/local/bin/virtualbox: symbolic link to /usr/local/lib/virtualbox/VBox.sh
% ll /usr/local/bin/virtualbox 
lrwxr-xr-x  1 root  wheel  33 Sep 17 20:53 /usr/local/bin/virtualbox -> /usr/local/lib/virtualbox/VBox.sh

% ll /usr/local/lib/virtualbox/VBox.sh
-r-xr-xr-x  1 root  wheel  1705 Sep 17 20:53 /usr/local/lib/virtualbox/VBox.sh

なんなの、このリンクのループは!?

% sh -x /usr/local/bin/virtualbox 
+ PATH=/usr/bin:/bin:/usr/sbin:/sbin
+ CONFIG=/usr/local/etc/vbox/vbox.cfg
+ test -r /usr/local/etc/vbox/vbox.cfg
+ test -z ''
+ test -d /usr/local/lib/virtualbox
+ test -f /usr/local/lib/virtualbox/VBoxRT.so
+ INSTALL_DIR=/usr/local/lib/virtualbox
+ basename /usr/local/bin/virtualbox
+ APP=virtualbox
+ exec /usr/local/lib/virtualbox/VirtualBox
exec: /usr/local/lib/virtualbox/VirtualBox: Permission denied

スクリプトをデバッグモードで動かしてみて、ようやくヒントにたどり着きました。

% ll /usr/local/lib/virtualbox/VirtualBox
-r-s--x---  1 root  vboxusers  29336 Sep 17 20:53 /usr/local/lib/virtualbox/VirtualBox

VirtualBox コマンドのパーミッションが、普通と違う。
ハードウェアリソースにアクセスするためか、一般ユーザーにアクセス権がありません。virtualbox コマンドを実行したいユーザーは、vboxusers にグループ登録しなくちゃいけないようです。

/etc/group に、私のアカウントを登録して、実行したところヘルプメッセージが出てくるようになり、実行可能なようです。

% virtualbox --help
Oracle VM VirtualBox Manager 4.3.30_OSE

Usage:
  --startvm <vmname|UUID>    start a VM by specifying its UUID or name
  --seamless                 switch to seamless mode during startup
  --fullscreen               switch to fullscreen mode during startup
  --rmode image              select different render mode (default is image)
  --no-startvm-errormsgbox   do not show a message box for VM start errors
  --restore-current          restore the current snapshot before starting
  --no-aggressive-caching    delays caching media info in VM processes
  --dbg                      enable the GUI debug menu
  --debug                    like --dbg and show debug windows at VM startup
  --debug-command-line       like --dbg and show command line window at VM startup
  --debug-statistics         like --dbg and show statistics window at VM startup
  --no-debug                 disable the GUI debug menu and debug windows
  --start-paused             start the VM in the paused state
  --start-running            start the VM running (for overriding --debug*)

Expert options:
  --disable-patm             disable code patching (ignored by AMD-V/VT-x)
  --disable-csam             disable code scanning (ignored by AMD-V/VT-x)
  --recompile-supervisor     recompiled execution of supervisor code (*)
  --recompile-user           recompiled execution of user code (*)
  --recompile-all            recompiled execution of all code, with disabled
                             code patching and scanning
  --execute-all-in-iem       For debugging the interpreted execution mode.
  --warp-pct            time warp factor, 100% (= 1.0) = normal speed
  (*) For AMD-V/VT-x setups the effect is --recompile-all.

The following environment (and extra data) variables are evaluated:
  VBOX_GUI_DBG_ENABLED (GUI/Dbg/Enabled)
                             enable the GUI debug menu if set
  VBOX_GUI_DBG_AUTO_SHOW (GUI/Dbg/AutoShow)
                             show debug windows at VM startup
  VBOX_GUI_NO_DEBUGGER       disable the GUI debug menu and debug windows

しかし、コンソール上でX11を使っていないので、結果は次の通り。

% virtualbox 
Failed to open the X11 display!

追記:

virtualbox インストールメッセージを見てみたら、しっかりと

You also have to add all users to your vboxusers group in order to use vbox.
% pw groupmod vboxusers -m jerry

と書いてありました。手動で、vboxusers グループにユーザー登録するのが正式手順という事。

バイナリーインストールすると、メッセージを見逃すわ。

コメントを残す