VMware上でFreeBSD

Let's note J9 で FreeBSD を使いたいんだけど下記のような問題があって直接使うのは諦めて,Windows7 上の VMware 上で使うことにした.

設定でいくつか気をつけないといけない事があったのでメモ.

FreeBSD は,Windows7ファイルシステム上ではなくHDDの第4パーティションにインストールした.こうしておくと,ゲストOSとしてだけでなく生で FreeBSD を起動することもできるので何かと便利.
ただし,どちらの方法で起動するかによってパーティション(ディスクラベル)の見え方が違ってくるようで,カーネル起動直後に / (ファイルシステムのルート) をマウントしようとする時点で止まってしまう.でも,手動で ufs:/dev/ad4s4a とか ufs:/dev/ad0s4a と指定すればマウントできる.その後 /etc/fstab を下記のようにして書き換えて exit すれば起動処理を続行できる.

mount -u -o rw /
mount /dev/ad4s4d /var
mount /dev/ad4s4e /usr
vi /etc/fstab

ちなみに /etc/fstab はこんな感じにしてある.

# Native
#/dev/ad4s4a            /               ufs     rw              1       1
#/dev/ad4s4f            /home           ufs     rw              2       2
#/dev/ad4s4e            /usr            ufs     rw              2       2
#/dev/ad4s4d            /var            ufs     rw              2       2
# for Guest OS
/dev/ad0s4a             /               ufs     rw              1       1
/dev/ad0s4f             /home           ufs     rw              2       2
/dev/ad0s4e             /usr            ufs     rw              2       2
/dev/ad0s4d             /var            ufs     rw              2       2
#
/dev/acd0               /mnt/cdrom      cd9660  noauto,ro       0       0

VMware 付属の VMware Tools は使わず,X のビデオドライバは ports から x11-drivers/xf86-video-vmware/ をインストールした.Xorg -configure で core dump してしまうが,xorg.conf をちゃんと書いたら起動した.このページの最後に xorg.con を貼っておく.
その他,emulators/open-vm-tools もインストールした.この ports でインストールされた mount_vmhgfs で VMware のホストOSとのファイル共有は下記のようにマウントできた.アンマウントは -f オプションが必要だった.

mount_vmhgfs .host:/ /mnt
umount -f /mnt

VMware 上での FreeBSD は思っていた以上に快適に動作している.下記のような問題に気付いたが最後の一個以外は解決したと思う.

  • Caps を Ctrl にできない
  • ときどき暴走してゲストOSを強制停止(=電源を切る)する必要がある
  • マウスの3ボタンエミュレーションが moused -3 で使えない
  • LCDのサイズ(1366x768)に合わせて X を起動しているが,VMware をフルスクリーンモードで起動してもスクロールバーが表示されてしまう時がある
  • VMware のメニューバーが邪魔

Caps を Ctrl に置き換えるのはWindows側のレジストリをいじって解決.ついでに,Windows側でASCII配列にして,VMware の設定でゲストOSからホストOSに戻るときのキーバインドを Ctrl+Alt+Win に変更(下記参照).

pref.hotkey.shift = "false"
pref.hotkey.control = "true"
pref.hotkey.alt = "true"
pref.hotkey.gui = "true"

暴走していた件は,X が /var/log/Xorg.0.log に下記のような2行を繰り返し出力していたのが原因の模様.

(II) Mouse autoprobe: Changing protocol to ImPS/2
(II) Mouse autoprobe: Changing protocol to ExplorerPS/2

これは hald を使っていると起きるような話をネットで見付けた.hald は活用してないので hald や dbus を止めて /etc/X11/xorg.conf を少し書き換えた.その後は半日くらい暴走してないのでこれで解決したのだと期待している.

xorg.conf を書き換えたついでに直したのが,マウスの3ボタンエミュレーション(マウスの2つのボタンを同時押しして第3ボタンと認識させる機能).第3ボタンはXでペーストするのに使うので機能しないと不便.試行錯誤の末に分かったのは,VMware が(?) 3ボタンエミュレーションをやってくれているので,ゲストOS側では何も設定する必要がないということ.moused に -3 オプションは不要だし,xorg.conf の mouse に関係する場合は下記のような内容.

Section "InputDevice"
  Identifier "mouse0"
  Driver     "mouse"
  Option     "Protocol"     "auto"
  Option     "Device"       "/dev/sysmouse"
EndSection

解像度がぴったりのはずなのにスクロールバーが表示されてしまう件は,VMware のフルスクリーンモードを解除して,Ctrl+Alt+F1 とかでコンソールを表示した状態でフルスクリーンモードに戻して,Alt+F9 で X の画面に切り替えると上手くいく.

一度フルスクリーンモードが解除されると,上記のスクロールバーが出てしまう問題があるので,下手にVMwareのメニューバーに触りたくなかったのだが,調べてみたら簡単に消せた.これで,Ctrl+Alt+Windowsキーを押さない限りは戻らなくなった.

pref.vmplayer.fullscreen.nobar = "TRUE"

最後に,xorg.con を貼っておく.

Section "ServerLayout"
        Identifier     "X.org Configured"
        Screen      0  "Screen0" 0 0
  InputDevice "mouse0"    "CorePointer"
  InputDevice "keyboard0" "CoreKeyboard"
EndSection

Section "ServerFlags"
  Option "DontZap"         "off"
  Option "AllowEmptyInput" "off"
  Option "AutoAddDevices"  "off"
EndSection

Section "InputDevice"
  Identifier "mouse0"
  Driver     "mouse"
  Option     "Protocol"     "auto"
  Option     "Device"       "/dev/sysmouse"
EndSection

Section "InputDevice"
  Identifier "Keyboard0"
  Driver     "kbd"
  Option     "XkbOptions" "terminate:ctrl_alt_bksp"
EndSection

Section "Files"
        ModulePath   "/usr/local/lib/xorg/modules"
        FontPath     "/usr/share/fonts/misc/"
        FontPath     "/usr/share/fonts/TTF/"
        FontPath     "/usr/share/fonts/OTF"
        FontPath     "/usr/share/fonts/Type1/"
        FontPath     "/usr/share/fonts/100dpi/"
        FontPath     "/usr/share/fonts/75dpi/"
EndSection

Section "Module"
        Load  "glx"
        Load  "extmod"
        Load  "record"
        Load  "dri2"
        Load  "dbe"
        Load  "dri"
EndSection

Section "Monitor"
        Identifier   "Monitor0"
        VendorName   "VMware"
        ModelName    "VMWare virtual monitor"
        HorizSync    1.0 - 10000.0
        VertRefresh  1.0 - 10000.0

        ModeLine "800x600" 100 800 900 1000 1100 600 700 800 900
        ModeLine "1024x768" 100 1024 1100 1200 1300 768 800 900 1000
        ModeLine "1152x864" 100 1152 1200 1300 1400 864 900 1000 1100
        ModeLine "1280x768" 100 1280 1300 1400 1500 768 800 900 1000
        ModeLine "1280x800" 100 1280 1300 1400 1500 800 900 1000 1100
        ModeLine "1280x960" 100 1280 1300 1400 1500 960 1000 1100 1200
        ModeLine "1280x1024" 100 1280 1300 1400 1500 1024 1100 1200 1300
        ModeLine "1366x768" 100 1366 1400 1500 1600 768 800 900 1000
        ModeLine "1440x900" 100 1440 1500 1600 1700 900 1000 1100 1200
        ModeLine "1600x1200" 100 1600 1700 1800 1900 1200 1300 1400 1500
        ModeLine "1680x1050" 100 1680 1700 1800 1900 1050 1100 1200 1300
        ModeLine "1920x1080" 100 1920 2000 2100 2200 1080 1100 1200 1300
        ModeLine "1920x1200" 100 1920 2000 2100 2200 1200 1300 1400 1500
EndSection

Section "Device"
        ### Available Driver options are:-
        ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
        ### <string>: "String", <freq>: "<f> Hz/kHz/MHz"
        ### [arg]: arg optional
        #Option     "HWcursor"                  # [<bool>]
        #Option     "Xinerama"                  # [<bool>]
        #Option     "StaticXinerama"            # <str>
        Identifier  "Card0"
        Driver      "vmware"
        VendorName  "VMware Inc"
        BoardName   "Abstract SVGA II Adapter"
        BusID       "PCI:0:15:0"
EndSection

Section "Screen"
        Identifier "Screen0"
        Device     "Card0"
        Monitor    "Monitor0"
        SubSection "Display"
                Viewport   0 0
                Depth     24
#               Modes  "800x600" "1024x768" "1152x864" "1280x768" "1280x800" "1280x960" "1280x1024" "1366x768" "1440x900" "1600x1200" "1680x1050" "1920x1080" "1920x1200"
                Modes  "800x600" "1024x768" "1280x768" "1366x768"
        EndSubSection
EndSection