How to create and start VirtualBox VM without GUI

Suppose you want to create and run virtual machines (VMs) on VirtualBox. However, a host machine does not support X11 environment, or you only have access to a terminal on a remote host machine. Then how can you create and run VMs on such a host machine without VirtualBox GUI? This can be a common situation for servers where VMs are managed from remotely.

In fact, VirtualBox comes with a suite of command line utilities, and you can use the VirtualBox command line interfaces (CLIs) to manage VMs on a remote headless server. In this tutorial, I will show you how to create and start a VM without VirtualBox GUI.
Prerequisite for starting VirtualBox VM without GUI

First,
you need to install VirtualBox Extension Pack. The Extension Pack is
needed to run a VRDE remote desktop server used to access headless VMs.
Its binary is available for free. To download and install VirtualBox
Extension Pack:
$ wget http://download.virtualbox.org/virtualbox/4.2.12/Oracle_VM_VirtualBox_Extension_Pack-4.2.12-84980.vbox-extpack
$ sudo VBoxManage extpack install ./Oracle_VM_VirtualBox_Extension_Pack-4.2.12-84980.vbox-extpack

Verify that the Extension Pack is successfully installed, by using the following command.
$ VBoxManage list extpacks

Extension Packs: 1
Pack no. 0:   Oracle VM VirtualBox Extension Pack
Version:      4.2.12
Revision:     84980
Edition:
Description:  USB 2.0 Host Controller, VirtualBox RDP, PXE ROM with E1000 support.
VRDE Module:  VBoxVRDP
Usable:       true
Why unusable:

Create a VirtualBox VM from the command line

I assume that the VirtualBox‘ VM directory is located in "~/VirtualBox\ VMs".

First create a VM. The name of the VM is "testvm" in this example.
$ VBoxManage createvm --basefolder /opt/vm --name "testvm" --register

Specify the hardware configurations of the VM (e.g., Ubuntu OS type, 1024MB memory, bridged networking, DVD booting).
$ VBoxManage modifyvm "testvm" --memory 1024 --acpi on --boot1 dvd --nic1 bridged --bridgeadapter1 eth0 --ostype Ubuntu

Create
a disk image (with size of 10000 MB). Optionally, you can specify disk
image format by using "--format [VDI|VMDK|VHD]" option. Without this
option, VDI image format will be used by default.
$ VBoxManage createvdi --filename ~/VirtualBox\ VMs/testvm/testvm-disk01.vdi --size 10000

Add an IDE controller to the VM.
$ VBoxManage storagectl "testvm" --name "IDE Controller" --add ide

Attach
the previously created disk image as well as CD/DVD drive to the IDE
controller. Ubuntu installation ISO image (found in
/iso/ubuntu-12.04.1-server-i386.iso) is then inserted to the CD/DVD
drive.
$ VBoxManage storageattach "testvm" --storagectl "IDE
Controller" --port 0 --device 0 --type hdd --medium ~/VirtualBox\
VMs/testvm/testvm-disk01.vdi
$ VBoxManage storageattach "testvm"
--storagectl "IDE Controller" --port 1 --device 0 --type dvddrive
--medium /iso/ubuntu-12.04.1-server-i386.iso
Start VirtualBox VM from the command line

Once a new VM is created, you can start the VM headless (i.e., without VirtualBox console GUI) as follows.
$ VBoxHeadless --startvm "testvm" &

The
above command will launch the VM, as well as VRDE remote desktop
server. The remote desktop server is needed to access the headless VM‘s
console.

By default, the VRDE server is listening on TCP port
3389. If you want to change the default port number, use "-e" option as
follows.
$ VBoxHeadless --startvm "testvm" -e "TCP/Ports=4444" &

If you don‘t need remote desktop support, launch a VM with "--vrde off" option.
$ VBoxHeadless --startvm "testvm" --vrde off &

Connect to headless VirtualBox VM via remote desktop

Once
a VM is launched with remote desktop support, you can access the VM‘s
console via any remote desktop client (e.g., rdesktop).

To install rdesktop on Ubuntu or Debian:
$ sudo apt-get install rdesktop

To install rdesktop on CentOS, RHEL or Fedora, configure Repoforge on your system, and then run the following.
$ sudo yum install rdesktop

To access a headless VM on a remote host machine, run the following.
$ rdesktop -a 16 <IP_address_host_machine>

If you use a custom port number for a remote desktop server, run the following instead.
$ rdesktop -a 16 <IP_address_host_machine:port_number>

Once rdesktop is successfully connected to the VM via remote desktop, you will see the initial installation screen.

时间: 2024-10-11 03:47:28

How to create and start VirtualBox VM without GUI的相关文章

在Mac上自动启动VirutalBox中的虚拟机 (Auto start VirtualBox VM in mac OSX)

Auto start VM in mac OSX(10.15) 1. Install VirtualBox(6.1.4)        2. Copy file "/Applications/VirtualBox.app/Contents/MacOS/org.virtualbox.vboxautostart.plist" to "/Library/LaunchDaemons"        3. Edit the file "/Library/LanchD

XenServer 6.5实战系列之十:Create VMs from a VM Template

1.  Create VMs 1.1 右键点击对应的模板"Test-01",点击"New VM wizard" 1.2 选择对应的模板"Test-01",Next 1.3 为新虚机命名, Next 1.4 保持默认,通过模板创建虚拟机不需要插入DVD光盘,Next 1.5 选择该虚拟机默认启动的服务器,Next 1.6 根据需求调整vCPU 数量,内存大小,Next 1.7 选择相应的存储,Next 1.8 选择VM 使用的网络,Next 1.9

vagrant virtualbox VM inaccessible解决办法

vagrant无法访问的提示:Please open VirtualBox and clear out your inaccessible virtual machines or find a way to fix them.看到这句话,于是打开virtualbox界面,virtualbox也提示该虚拟机无法启动,是因为C:\Users\denglj\VirtualBox VMs\vagrant_default_1411538218356_15372\vagrant_default_141153

使用docker-machine 创建virtualbox虚拟机时指定boot2docker.iso位置和设置docker镜像加速的命令

docker-machine create -d virtualbox --virtualbox-boot2docker-url=/home/当前用户/.docker/machine/cache/boot2docker2.iso --engine-registry-mirror=https://3qtk5f5j.mirror.aliyuncs.com node1 -d virtualbox为指定virtualbox创建虚拟机 -virtualbox-boot2docker-url=/home/当

在Oracle VirtualBox运行Citrix NetScaler VPX

我们都知道Citrix NetScaler VPX版本支持很多的底层虚拟化平台和云计算平台,但是唯独不支持Oracle VirtualBox平台.但是我们可以通过修改Oracle VirtualBox VM的BIOS来实现Citrix NetScaler VPX运行在Oracle VirtualBox上.那么是这么做到的呢?原理是什么? 其实原理也很简单,就是通过修改BIOS和一些配置文件,欺骗Citrix NetScaler VPX虚拟机,让虚拟机认为他是运行在Vmware平台上的,这样就达到

VirtualBox+Ubuntu设置

1. 在Windows或Mac中下载安装VirtualBox 2. 在VitrualBox中建立新的VM 3. 安装Ubuntu镜像文件 4. 设置网卡(局域网) 5. 网卡(广域网) 5. 开机安装OS 6. 设置VM全屏显示 VirtualBox VM -> Devices -> Insert Guest Additions CD image... Reboot VM

win8.1 virtualbox 安装centos7注意事项

win8.1是64位的,一开始在virtualbox中选择版本时,怎么也选不到64位的,这时要改BIOS设置,把CPU虚拟化改为允许. virtualbox是32位的,没必要非得是64位(64位的也不好找) centos是最新版的,centos7,64位. virtualbox是最新版本,新建虚拟机成功,可是启动时,总弹出错误: ---------------------------VirtualBox - Error In supR3HardenedWinReSpawn------------

Getting Started with OpenStack on Oracle Linux and Oracle VM Hands-On Lab 1

最近开始学习OpenStack,由于没有任何环境,所以不知道如何上手,因此下载了OpenStack for Oracle Linux版本,准备玩一下(有Oracle账户,嘿嘿).这个的相关参考还是很多的,在Oracle网站上有大量资料,本人参考的是Ronen Kofman的Hands-On Lab: Getting Started with OpenStack on Oracle Linux and Oracle VM,链接如下: http://www.oracle.com/technetwor

VirtualBox复制拷贝新建虚拟机系统UUID出错解决

例如: 在vbox中以安装完Win7,想要在拷贝复制一份 额外另打开一个Win7,即同时存在两个,(而不是用virtualbox自带的克隆,是手动添加),会出错提示大概意思是已经存在了一个相同序列号uuid的硬盘,因为拷贝复制的会把UUID一同复制,VBOX不支持相同UUID. 1.命令行切换到后者的文件夹目录(含有.vdi文件夹)例如我的是/home/linux234/VirtualBox VMs/Win7 2.输入命令:[[email protected]~~]$cd /home/linux