设为首页 收藏本站
查看: 965|回复: 0

[经验分享] VBoxManage control and manage Virtualbox from command line(转)

[复制链接]

尚未签到

发表于 2015-4-14 09:24:59 | 显示全部楼层 |阅读模式
VBoxManage control and manage Virtualbox from command line





Introduction
  VirtualBox is according to developers:

  VirtualBox is a powerful x86 and AMD64/Intel64 virtualization product for enterprise as well as home use. Not only is VirtualBox an extremely feature rich, high performance product for enterprise customers, it is also the only professional solution that is freely available as Open Source Software under the terms of the GNU General Public License (GPL). See “About VirtualBox” for an introduction.

  And according to Wikipedia:

  Oracle VM VirtualBox is an x86 virtualization software package, originally created by software company innotek GmbH, purchased by Sun Microsystems, and now developed by Oracle Corporation as part of its family of virtualization products. It is installed on an existing host operating system; within this application, additional guest operating systems, each known as a Guest OS, can be loaded and run, each with its own virtual environment.
  Supported host operating systems include Linux, Mac OS X, Windows XP, Windows Vista, Windows 7, Solaris, and OpenSolaris; there is also a port to FreeBSD (only OSE version). Supported guest operating systems include a small number NetBSD versions and various versions of Windows, Linux, DragonFlyBSD, FreeBSD, OpenBSD, OS/2 Warp, Solaris, OpenSolaris, Haiku, Syllable, ReactOS, and SkyOS.

  From this, we may know that it is a powerful and useful tool, for those trying to test new Operating Systems, or try new configurations on Known Operating Systems. I use it a lot to test new Linux distribution, without the need to install them on my Hard Disk.
  Another great use for it, is to have separated servers on the same hardware just to improve security, I mean: Why to have DNS server, FTP server, Web server and all others on the same environment, where an attack to one of these server may compromise all the others, you can install Linux on a good Hardware, and VirtualBox on it, and three or four different virtual machines running Linux to have all those functions mentioned before on different Virtual Machines, thus increasing the security of your configuration.
  But, enough talking about this, this will be material of another article, let’s focus on how to manage VirtualBox from the command line, as you usually will do it from the GUI.

List virtual machines from command line
  The command we will use for this is VBoxManage and different sub-commands it has, to list the virtual machines installed run:

VBoxManage list vms

  This will list all virtual machines on the server, with an output like this:

Oracle VM VirtualBox Command Line Management Interface Version 3.2.12
(C) 2005-2010 Oracle Corporation
All rights reserved.
"win7" {3f157880-c642-4be2-b641-85d7aedb5090}
"msn" {acc458d0-435b-44c7-806d-41c4948bb490}
"itunes" {41238c30-5f05-4fda-b008-5169d69505f6}
"Linux-Mint" {c25e1257-dfed-4789-a22b-8489c4d4df05}
"ubuntu" {fee70808-ab0e-473a-8991-d9b711773672}
"xp" {c75ec9b7-90b2-4f97-9e07-1267a3a03cb1}
"ubuntu-netop" {3d216ab8-3b44-46fd-8738-8c631801176e}
"slackware" {f65d5b26-6491-4523-8c06-970cbe6844d5}
"peppermint" {32b1845f-dd72-4c8a-bfe7-8cc3e83d0109}

  If you specify -l then, you will get a detailed information about each one of those.

VBoxManage list vms -l

How to start virtual machines from command line
  Now that you know which virtual machines are already installed, let’s see how to start them.

VBoxManage startvm "slackware"

  or

VBoxManage startvm f65d5b26-6491-4523-8c06-970cbe6844d5

  You can add those commands to your startup scripts, so virtual machines are started when you to boot your primary Linux server.

How to stop a virtual machine from command line
  Now we know how to start virtual machines, we need to know how to stop them, there are some options.
  Pause the virtual machine
  This will just put the virtual machine on hold, until un-paused.

VBoxManage controlvm "slackware" pause

  Resume the paused virtual machine

VBoxManage controlvm "slackware" resume

  Reset -restart- the virtual machien

VBoxManage controlvm "slackware" reset

  This will close the virtual machine, and restart immediately, you unsaved data on the virtual machine will not be saved, and will be lost! you have been warned.
  Poweroff or shut down the virtual machine

VBoxManage controlvm "slackware" poweroff

  This will poweroff the virtual machine, and once again any unsaved data will be lost.
  Stop virtual machine, and save data

VBoxManage controlvm "slackware" savestate

  This will save current state of the virtual machine and stop it, I think of this more or less, like hibernate the virtual machine.

Create a new virtual machine
  You can also create new virtual machines from command line:

VBoxManage createvm -name "LinuxMint" -register

  This create a new virtual machine, with default options.

Change Settings on the virtual machine from command line
  Now we have a new virtual machine created, let’s change some of its default settings, like the allocated RAM:

VBoxManage modifyvm "LinuxMint -memory "1024MB"

  Check the complete set of parameters.

Conclusion
  As you can see, VirtualBox is very flexible and fully managed from the command line, so it can be used on a Dedicated server, in a remote data center, and you may have all your virtual machines under control.
  I’m not saying this is the best option to go for professional virtualization, but it is certainly a good one, and an easy one too.


  If you liked this article please share it.
  from: http://go2linux.garron.me/linux/2011/01/vboxmanage-control-and-manage-virtualbox-command-line-890
  --------------------------------------------------------------------------------------------------------
  Create VirtualBox VM from the command line
  As something of a follow-up post to the previous entry, here’s a quick recipe for creating a Virtual Machine using the VirtualBox command line tools:
  We’re using Windows Server 2008 64bit as an example, modify to taste.



$ VM='Windows-2008-64bit'

  Create a 32GB “dynamic” disk.



$ VBoxManage createhd --filename $VM.vdi --size 32768

  You can get a list of the OS types VirtualBox recognises using:



$ VBoxManage list ostypes

  Then copy the most appropriate one into here.



$ VBoxManage createvm --name $VM --ostype "Windows2008_64" --register

  Add a SATA controller with the dynamic disk attached.



$ VBoxManage storagectl $VM --name "SATA Controller" --add sata \
>  --controller IntelAHCI
$ VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 \
>  --device 0 --type hdd --medium $VM.vdi

  Add an IDE controller with a DVD drive attached, and the install ISO inserted into the drive:



$ VBoxManage storagectl $VM --name "IDE Controller" --add ide
$ VBoxManage storageattach $VM --storagectl "IDE Controller" --port 0 \
>  --device 0 --type dvddrive --medium /path/to/windows_server_2008.iso

  Misc system settings.



$ VBoxManage modifyvm $VM --ioapic on
$ VBoxManage modifyvm $VM --boot1 dvd --boot2 disk --boot3 none --boot4 none
$ VBoxManage modifyvm $VM --memory 1024 --vram 128
$ VBoxManage modifyvm $VM --nic1 bridged --bridgeadapter1 e1000g0

  Configuration is all done, boot it up! If you’ve done this one a remote machine, you can RDP to the console via vboxhost:3389.



$ VBoxHeadless -s $VM

  Once you have configured the operating system, you can shutdown and eject the DVD.



$ VBoxManage storageattach $VM --storagectl "IDE Controller" --port 0 \
>  --device 0 --type dvddrive --medium none

  Finally, it’s a good idea to take regular snapshots so that you can always revert back to a known-good state rather than having to completely re-install.



$ VBoxManage snapshot $VM take

  And, if you need to revert back to a particular snapshot:



$ VBoxManage snapshot $VM restore

  Enjoy!
  from: http://www.perkin.org.uk/posts/create-virtualbox-vm-from-the-command-line.html
  ------------------------------------------------------------------------------------------------------

资料:
  http://www.howtoforge.com/vboxheadless-running-virtual-machines-with-virtualbox-4.1-on-a-headless-ubuntu-12.04-server
  http://www.pclinuxos.com/forum/index.php?topic=103651.0

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-56962-1-1.html 上篇帖子: VirtualBox 共享文件夹设置(windows7主机,linux客户机) 下篇帖子: windows主机与virtualbox虚拟机下的Linux共享网络
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表