VBoxManage tutorial

Preview:

Citation preview

4 Ways to Manage VirtualBox1) VirtualBox ใชงานผาน Graphic User Interface (GUI) แบบที่ใชงานตามปกติ2) VBoxManage ใชงานผาน Command Line Interface (CLI) สามารถสั่งงานผาน

Command เลยสะดวกในการทำงานอัตโนมัติ3) VBoxSDL ใชงานผานกราฟฟกแบบงายๆ (ไมมี Config ใหเลือก)4) VBoxHeadless ใชงานผาน Command Line Interface (CLI) โหมดนี้จะทำตัวเปน

RDP Server [1]

VBoxManage --type headless VS. VBoxHeadless

ควรใช VBoxHeadless แทน VBoxManage --type headless เพราะดูขอผิดพลาดได และ VBoxHeadless มีคา default เปน force start VRDE (VirtualBox Remote Desktop Extension) ทำให Remote ไปที่ VM instance ได [2] เปน Remote ในระดับ Machine ไมตองรอ OS พรอมทำให Config บางอยางได เชนเขา Safe mode

- ตองติดตั้ง Extensions ใน Host VM เพิ่ม- VBoxManage ก็ทำของคลายกันไดแตเพิ่มคำสั่ง- การใช VRDE ตอง Remote ไปที่ IP ของ Host VM (Default port : 3389)

Create new VM

VBoxManage createvm --name [ชื่อ VM] --register

* สรางแลวตอง register ดวย ไมงั้นจะไมเห็นในระบบ (แตสั่ง Register ทีหลังผาน VBoxManage registervm '[Full path]' ก็ได)

List of VMs

VBoxManage list vms

จะพบ ชื่อ VM ภายในเครื่องหมายอัญประกาศ (Quote) และ UUID ของ VM ในวงเล็บปกกา (Curly braces)

Show VM information

VBoxManage showvminfo [ชื่อVM]

Modify VM

VBoxManage modifyvm [ชื่อ VM] [option] [option parameters]

Ex.VBoxManage modifyvm HomeWork --memory 512

Example options :

--name [new name]

--ostype [new ostype]

--usb [on/off]

--memory [new memory size in MB]

etc.

Create virtual diskVBoxManage createhd --filename [ชื่อ HD] --size [ขนาด HD]

Binding virtual harddisk drive

1) VBoxManage storagectl [ชื่อ VM] --name [ชื่อตัวควบคุม]--add sataEx. VBoxManage storagectl HomeWork --name HWDriver --add sataVBoxManage storageattach [ชื่อ VM] --storagectl HWDriver --type HDD

2) --port 0 --device 0 --medium [Disk full path]Ex. VBoxManage storageattach HomeWork --storagectl HWDriver --type HDD

--port 0 --device 0 --medium /Users/dekcom/HWData.vdi

Binding virtual dvd-drive

Ex. VBoxManage storageattach HomeWork --storagectl HWDriver --type DVDDRIVE --port 1 --device 0 --medium /Users/dekcom/Downloads/ubuntu-14.04.2-server-amd64.iso [3]

Start VMVBoxHeadless --startvm HomeWork

(ถาอยากใหทำงานเปน Background process ใสเวนวรรคแลวใส & ขางหลัง)

Control VM

VBoxManage controlvm [ชื่อ VM] [option] [option parameters]

Ex. VBoxManage controlvm HomeWork acpipowerbutton

Example options :

pause

resume

poweroff

draganddrop [disabled/hosttoguest]

etc.

Clone VM

VBoxManage clonevm [ชื่อ VM ตนแบบ] --name [ชื่อ VM ใหม] --register

Ex. VBoxManage clonevm HomeWork --name HomeWork2 --register

VBoxManage unregistervm [ชื่อ VM] --delete

Ex. VBoxManage unregistervm HomeWork2 --delete

Delete VM

Citations

[1] https://www.virtualbox.org/manual/ch01.html#frontends

[2] https://www.virtualbox.org/manual/ch07.html#vboxheadless

[3] http://superuser.com/questions/741734/virtualbox-how-can-i-add-mount-an-iso-image-file-from-command-line

Recommended