Manage Virtualbox virtual machines under command line

virtualbox

VirtualBox is a very useful x86/AMD64 virtualization application, we usually use it to test different operating systems, or do some computer science related practices, or maybe we just want to slice the hardware resource for resource utilization.

I would like to run a virtualbox program on my powerful servers, and use a lightweight but not powerful computer like Chromebook to remotely connect to the virtual machines under the virtualbox, so that I don’t have to bring a heavy computer every where, I can still have multiple machines with several different systems to run different programs.

From the beginning, I use vnc server with x window via ssh tunnel to create a secure connection and then launch virtualbox, in fact, the window manager is not always needed, especially we have installed the operating system, and the system runs properly, so I wonder if is possible to control the virtual machines under command line interface, and the answer is yes, and the command line virtual is much more powerful than I thought, I guess all the tasks and configurations can be done via command line now, of course including create/clone a vm or modify a vm hardware resource, vm import/export, share folder, network interface or usb device attach/detach, etc.

Without controlling via GUI, but from command line, I don’t need to start a vncclient then connect to my vncserver, also don’t need to forward the x window to my client, that’s very helpful, and that machine can run “in the background”, in fact, under the x window by vncserver, note that virtualbox still need a x window environment with virtualbox launched(at least by virtualbox v4.3.34), by my test result, if you don’t have a GUI virtual launched, the startvm command I will talk about later will not work, it will tell you vm started successfully, but in fact not, and will return 1(exit status).

I want to share some basic and commonly used commands, to help us control a virtualbox created virtual machine, if you didn’t know that before, hope this can help you.

Command ‘virtualbox’ usually means the GUI version of VirtualBox, here, for command line, we use ‘vboxmanage’, remember, I use the “vm name” to control a version machine here, you can also use its UUID at the same place, okay, here we go:

List all the virtual machines
– vboxmanage list vms

List the running virtual machines
– vboxmanage list runningvms

List the dhcp server info
– vboxmanage list dhcpservers

Show info about a virtual machine
– vboxmanage showvminfo “vm name”

Power on a vm:
– vboxmanage startvm “vm name”

Force reset/reboot a vm:
– vboxmanage controlvm “vm name” reset

Force power off a vm(cut the power down):
– vboxmanage controlvm “vm name” poweroff

Power off a vm as “Press its power button”(acpi, send power off signal, to power off in normal process, not cut the power down):
– vboxmanage controlvm “vm name” acpipowerbutton

Make a vm sleep as “Press its power button”(acpi, send sleep signal):
– vboxmanage controlvm “vm name” acpisleepbutton

Pause a vm:
– vboxmanage controlvm “vm name” pause

Resume a paused vm:
– vboxmanage controlvm “vm name” resume

Save a vm’s state(like poweroff but all states will be saved):
– vboxmanage controlvm “vm name” savestate

Take a png image screenshot of a vm:
– vboxmanage controlvm “vm name” screenshotpng filename.png

繼續閱讀

Linux Mint 17 “Qiana” Mate筆記及安裝紀錄(虛擬機)

Linux Mint 17 “Qiana” 按照原定計畫(無正式官方資料來源、參考資訊為 List of Linux Mint releases – Wikipedia) 在五月底(昨天)推出正式版了,初期只有 Cinnamon 以及 Mate 兩種桌面環境的版本,KDE 及 xfce 桌面環境的版本還得再多等一小段時間。奇妙的是這次官網上資訊截至目前為止都還沒有更新,只有 RC released 的消息,應該是太忙還沒更新吧。

科技網站 ZDNet 日前針對 Linux Mint 17 RC(release candidate) 候選發布版本發表了一篇 Mint 17: The best Linux desktop to date 來推薦這套作業系統,由於 Linux Mint 主要發行版都是基於Ubuntu的關係,這次的版本同樣和所基於的 Ubuntu 14.04 是所謂的 LTS(long-term support) 長期支援版本,擁有五年的後續支援,所以也是公司企業可以考量使用的版本。

剛好最近有些人問到推薦的 Linux distribution,個人在 Debian GNU/Linux系列遊走至目前為止的經驗,以 Desktop 來說,Linux Mint的使用者體驗真的不錯,這邊就記錄一下 Linux Mint 17 Mate的安裝過程,因為在虛擬機上記憶體比較小一點,這邊選的是32位元的 Mate 版本,如果記憶體有到4GB或是更大的容量則建議選擇64位元版本。

繼續閱讀

原來HipHop VM(HHVM)不支援 32-bit 的環境 …

以前的HipHop似乎比較不友善 現在簡單多了!

剛剛在Lubuntu 13.04(raring)上要編譯HHVM

竟然到了最後倒數兩步給我出現…

CMake Error at CMakeLists.txt:26 (message):

32-bit support is currently unsupported, check back with a later version of HipHop.

— Configuring incomplete, errors occurred!

因為沒甚麼特殊用途…

手上拿來灌unix-like os的主機大概都只有2G的RAM

理所當然就是安裝32位元的OS了

看來要先在VirtualBox上面灌一套64bit的來玩玩看了