Virtualbox 命令行基本使用

1,创建虚拟机

使用Vagrant模板创建虚拟机:https://blog.csdn.net/eyeofeagle/article/details/98739727

2,启动/停止虚拟机

#2,启动/关闭,暂停/保存状态并休眠
VBoxManage startvm          <uuid|vmname>...
                            [--type gui|sdl|headless|separate]
                            [-E|--putenv <NAME>[=<VALUE>]]

VBoxManage controlvm        <uuid|vmname>
                            pause|resume|reset|poweroff|savestate|
                                                           
λ VBoxManage.exe  controlvm c7-docker_default_1591959253653_46344 pause      
                                                                                                                                       
λ VBoxManage.exe  controlvm c7-docker_default_1591959253653_46344 resume                                                                                  

3,查看虚拟机

VBoxManage list [--long|-l] [--sorted|-s] vms|runningvms|ostypes|hostdvds|hostfloppies|
                            intnets|bridgedifs|hostonlyifs|natnets|dhcpservers|
                            hostinfo|hostcpuids|hddbackends|hdds|dvds|floppies|
                            usbhost|usbfilters|systemproperties|extpacks|
                            groups|webcams|screenshotformats|cloudproviders|
                            cloudprofiles
#=============list vms   =================		                                                                
λ VBoxManage.exe  list vms                                                           
"test-c7_default_1589439500366_74357" {cef17aa3-8c5f-44b6-a989-04247a14fdd9}            
"c6_default_1590198803624_43446" {a38d3bb0-e49d-4996-956f-895f1688fc3a}           
"w10" {ab90e1b9-3f02-4ca0-ba09-02227ba71700}                                      
"c7-docker_default_1591959253653_46344" {480c1b45-46bf-444d-a01b-667c76db4a83}    
                                                                                                                                             
λ VBoxManage.exe  list runningvms                                                 
"test-c7_default_1589439500366_74357" {cef17aa3-8c5f-44b6-a989-04247a14fdd9}      
"c7-docker_default_1591959253653_46344" {480c1b45-46bf-444d-a01b-667c76db4a83}    
 
#=============showvminfo =================													  
λ VBoxManage.exe showvminfo c7-docker_default_1591959253653_46344 |grep stat -i
State:                       paused (since 2020-08-06T02:50:07.074000000)

λ VBoxManage.exe showvminfo c7-docker_default_1591959253653_46344 |grep mem -i
Memory size                  3000MB
Configured memory balloon size: 0MB

λ VBoxManage.exe showvminfo c7-docker_default_1591959253653_46344 |grep cpu -i
CPU exec cap:                100%
CPUProfile:                  host
Number of CPUs:              1
CPUID Portability Level:     0
CPUID overrides:             None

4,修改虚拟机:磁盘,内存,cpu

在这里插入图片描述

VBoxManage modifyvm         <uuid|vmname>
                            [--name <name>]    
                            [--memory <memorysize in MB>]
                            [--cpus <number>]
                            [--autostart-enabled on|off]
                            [--autostart-delay <seconds>]
#============modifyvm xx --name ==================	
λ VBoxManage.exe  list vms
"c7_default_1589441620512_61309" {bda3c131-9d17-4fd6-8b17-e1d70651e12b}

λ VBoxManage.exe  modifyvm c7_default_1589441620512_61309 --name c7-docker

λ VBoxManage.exe  list vms
"c7-docker" {bda3c131-9d17-4fd6-8b17-e1d70651e12b}

#============modifyvm xx --memory ==================	                                                          
λ VBoxManage.exe showvminfo c7-docker |grep -i mem                                
Memory size                  2120MB                                               
Configured memory balloon size: 0MB                                                                                                                                              
                                                                                                                                               
λ VBoxManage.exe modifyvm c7-docker --memory 3072                                 
                                                                                                                                             
λ VBoxManage.exe showvminfo c7-docker |grep -i mem                                
Memory size                  3072MB                                               
Configured memory balloon size: 0MB     

#===============createmedium 添加磁盘 ===============	
createmedium              [disk|dvd|floppy] --filename <filename>
                            [--size <megabytes>|--sizebyte <bytes>]
                            [--diffparent <uuid>|<filename>
                            [--format VDI|VMDK|VHD] (default: VDI)
                            [--variant Standard,Fixed,Split2G,Stream,ESX,
                                       Formatted]
                                                                                  
λ VBoxManage.exe createmedium  disk   --filename D:/a.vmdk --size 512
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Medium created. UUID: 823698d5-b82c-46e4-8da6-49d732ce13b2


=========
 storageattach             <uuid|vmname>
                            --storagectl <name>
                            [--port <number>]   0:第一控制器,1:第二控制器
                            [--device <number>] 0:主通道,   1:从通道
                            [--type dvddrive|hdd|fdd]
                            [--medium none|emptydrive|additions|
                                                                                                                                                            
λ VBoxManage.exe storageattach test-c65_default_1589782366908_91217 --storagectl IDE --type hdd --medium D:/a.vmdk  --port 2 --device 2                                          
VBoxManage.exe: error: The port and/or device parameter are out of range: port=2 (must be in range [0, 1]), device=2 (must be in range [0, 1])                                   
VBoxManage.exe: error: Details: code E_INVALIDARG (0x80070057), component StorageControllerWrap, interface IStorageController, callee IUnknown                                   
VBoxManage.exe: error: Context: "AttachDevice(Bstr(pszCtl).raw(), port, device, DeviceType_HardDisk, pMedium2Mount)" at line 776 of file VBoxManageStorageController.cpp         
                                                                                                                                                                                                                                                                                                                    
λ VBoxManage.exe storageattach test-c65_default_1589782366908_91217 --storagectl IDE --type hdd --medium D:/a.vmdk  --port 1 --device 1                                          
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
VirtualBox 是一款开源虚拟机软件。VirtualBox 是由德国 Innotek 公司开发,由Sun Microsystems公司出品的软件,使用Qt编写,在 Sun 被 Oracle 收购后正式更名成 Oracle VM VirtualBox。Innotek 以 GNU General Public License (GPL) 释出 VirtualBox,并提供二进制版本及 OSE 版本的代码。使用者可以在VirtualBox上安装并且执行Solaris、Windows、DOS、Linux、OS/2 Warp、BSD等系统作为客户Duan操作系统。现在则由甲骨文公司进行开发,是甲骨文公司xVM虚拟化平台技术的一部份。 VirtualBox号称是最强的免费虚拟机软件,它不仅具有丰富的特色,而且性能也很优异!它简单易用,可虚拟的系统包括Windows(从Windows 3.1到Windows10、Windows Server 2012,所有的Windows系统都支持)、Mac OS X、Linux、OpenBSD、Solaris、IBM OS2甚至Android等操作系统!使用者可以在VirtualBox上安装并且运行上述的这些操作系统! 与同性质的VMware及Virtual PC比较下,VirtualBox独到之处包括远端桌面协定(RDP)、iSCSI及USB的支持,VirtualBox在客户Duan操作系统上已可以支持USB 2.0的硬件装置,不过要安装 VirtualBox Extension Pack。 本模块可后台对VBox进行开机关机等操作,中文命名,实现原理很简单,网络上也有很多文章来介绍,因为VBox为我们提供了一系列的命令行,但目前为止还没有人制作出程序来控制,论坛早期有一个模块,但是那位朋友没有开源. 模块使用了匿名管道技术,其余的部分则是在调用VBox提供的命令.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

根哥的博客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值