Oracle VM VirtualBox は仮想マシンのソフトウエア.
このページでは Windows での VirtualBox バージョン 5.2 の主要な機能をコマンドラインで行ないます.GUI を避けたい場合には便利だと思います(リモート操作とか、操作の自動化とか)
【外部ページへのリンク】
Virtual Box の公式ページ: https://www.virtualbox.org/
以下 Windows での操作例を示す.
VBoxManage -v
仮想マシン(仮想マシン名: 文字列, 仮想マシンID: 文字列)
◆ 実行結果の例
ここでの実行結果では、仮想マシンがない(まだ仮想マシンを作成していないので)
VBoxManage list vms
仮想ストレージ(UUID, ParentUUID, Format, Location, Staus, Type, Usage...)
◆ 実行結果の例
ここでの実行結果では、仮想ストレージがない(まだ仮想ストレージを作成していないので)
VBoxManage list hdds
仮想DVDドライブ(UUID, Format, Location, Status, Type, Usage...)
◆ 実行結果の例
ここでの実行結果では、仮想DVDドライブがない(まだ仮想DVDドライブを作成していないので)
VBoxManage list dvds
◆ 実行例
※ ホスト側のハードウェアや設定によって違う値になる
VBoxManage list ostypes
仮想マシンブリッジインタフェース(Name, GUID, Dhcp, IPAddress, NetworkMask, IPV6Address, IPV6NetworkMaskPrefixLength, HardwareAddress, MediumType, Status, VBoxNetworkName)
◆ 実行例
VBoxManage list bridgedifs
仮想マシンホストオンリーインタフェース(Name, GUID, Dhcp, IPAddress, NetworkMask, IPV6Address, IPV6NetworkMaskPrefixLength, HardwareAddress, MediumType, Status, VBoxNetworkName)
◆ 実行例
※ ホスト側のハードウェアや設定によって違う値になる
VBoxManage list hostonlyifs
DHCPサーバ(NetworkName, IP, NetworkMask, lowerIPAddress, upperIPAddress, Enabled)
◆ 実行例
※ ホスト側のハードウェアや設定によって違う値になる
VBoxManage list dhcpservers
ホスト情報(HostTime, ProcessorOnlineCount, ProcessorCount, Processor description ..., MemorySize, MemoryAvailable, OPeratingSystem, OperatingSystemVersion)
◆ 実行例
※ ホスト側のハードウェアや設定によって違う値になる
VBoxManage list hostinfo
◆ 実行例
※ ホスト側のハードウェアや設定によって違う値になる
VBoxManage list hostcpuids
◆ 実行例
※ ホスト側のハードウェアや設定によって違う値になる
VBoxManage list systemproperties
※ 上記「...」は list(番号付き) あるいは set
【関連する外部ページ】 http://www.virtualbox.org/manual/ch08.html#vboxmanage-list
ここで実行するコマンド
VBoxManage createvm --name ubuntu1804 VBoxManage registervm /home/kaneko/VirtualBox\ VMs/ubuntu1804/ubuntu1804.vbox VBoxManage modifyvm ubuntu1804 --ostype Ubuntu_64 --memory 8000 --acpi on --hwvirtex on --nestedpaging on --largepages on --vtxvpid on --accelerate3d on --accelerate2dvideo on --nic1 bridged --bridgeadapter1 enp0s31f6 --usb on --usbehci off rm -f /home/ubuntu1804.vdi VBoxManage createhd --filename /home/ubuntu1804.vdi --size 80000 VBoxManage storagectl ubuntu1804 --name ubuntu1804sata1 --add sata --bootable on VBoxManage storageattach ubuntu1804 --storagectl ubuntu1804sata1 --port 1 --type hdd --medium /home/ubuntu1804.vdi VBoxManage storageattach ubuntu1804 --storagectl ubuntu1804sata1 --port 2 --type dvddrive --medium /home/www/computer/linux/ubuntu-18.04.1-desktop-amd64.iso VBoxManage startvm ubuntu1804
◆ ここでの設定内容(例)
◆ 実行例
VBoxManage createvm --name ubuntu1804
◆ 実行例
VBoxManage registervm /home/kaneko/VirtualBox\ VMs/ubuntu1804/ubuntu1804.vbox VBoxManage list vms
enp0s31f6 という名前は 「VBoxManage list bridgedifs」で調べることができる.
◆ NAT 接続にしたいときの実行例 (未確認)
VBoxManage modifyvm ubuntu1804 --ostype Ubuntu_64 --memory 8000 --acpi on --hwvirtex on --nestedpaging on --largepages on --vtxvpid on --accelerate3d on --accelerate2dvideo on --nic1 nat --usb on --usbehci off
◆ ブリッジ接続にしたいときの実行例
VBoxManage modifyvm ubuntu1804 --ostype Ubuntu_64 --memory 8000 --acpi on --hwvirtex on --nestedpaging on --largepages on --vtxvpid on --accelerate3d on --accelerate2dvideo on --nic1 bridged --bridgeadapter1 enp0s31f6 --usb on --usbehci off
◆ 実行例
VBoxManage createhd --filename /home/ubuntu1804.vdi --size 80000
◆ 実行例
VBoxManage storagectl ubuntu1804 --name ubuntu1804sata1 --add sata --bootable on
◆ 実行例
VBoxManage storageattach ubuntu1804 --storagectl ubuntu1804sata1 --port 1 --type hdd --medium /home/ubuntu1804.vdi
◆ 実行例
VBoxManage storageattach ubuntu1804 --storagectl ubuntu1804sata1 --port 2 --type dvddrive --medium /home/www/computer/linux/ubuntu-18.04.1-desktop-amd64.iso
◆ 実行例
なぜ、ここで GUI を使って起動するのかというと、その理由は、エラー時のエラーメッセージを確認しやすいし、設定の変更もしやすいから.
virtualbox
VBoxManage startvm ubuntu1804
◆ 実行例
VBoxManage controlvm ubuntu1804 pause VBoxManage snapshot ubuntu1804 take ubuntu1804-snap1 VBoxManage controlvm ubuntu1804 resume
仮想マシンの電源が切れた状態で、次のコマンドを実行
VBoxManage clonevm ubuntu1804 --mode machine --name ubuntu1804-new1 --register