阅读 109

VirtualBox命令行VBoxManage创建与管理虚拟机教程(一)

前言

本文要操作的虚拟机信息如下: 名称: UbuntuRDHome 镜像名称: ubuntu-16.04.3-server-amd64.iso 网络连接: 桥接

主机环境: $ uname -a命令输出: Linux UbuntuServer 4.10.0-37-generic #41-Ubuntu SMP Fri Oct 6 20:20:37 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -a命令输出:
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 17.04
    Release:        17.04
    Codename:       zesty

$ ifconfig命令输出:
    enp5s0f0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 172.16.8.3  netmask 255.255.255.0  broadcast 172.16.8.255
            inet6 fe80::dad3:85ff:fee3:8a56  prefixlen 64  scopeid 0x20<link>
            ether d8:d3:85:e3:8a:56  txqueuelen 1000  (Ethernet)
            RX packets 12193671  bytes 5948053357 (5.9 GB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 19703213  bytes 21537731944 (21.5 GB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
            device memory 0xc0400000-c041ffff  

    lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
            inet 127.0.0.1  netmask 255.0.0.0
            inet6 ::1  prefixlen 128  scopeid 0x10<host>
            loop  txqueuelen 1000  (Local Loopback)
            RX packets 12358  bytes 750596 (750.5 KB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 12358  bytes 750596 (750.5 KB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0复制代码

创建UbuntuRDHome虚拟机

创建虚拟机(同时注册)

VBoxManage createvm --name UbuntuRDHome --register

注册虚拟机

VBoxManage registervm <Absolute Full Path>/UbuntuRDHome.vbox复制代码

仅注销虚拟机

VBoxManage unregistervm UbuntuRDHome复制代码

删除虚拟机(!!!会删除所有虚拟硬盘,谨慎操作!!!)

VBoxManage unregistervm --delete UbuntuRDHome复制代码

设置系统类型Ubuntu_64

VBoxManage modifyvm UbuntuRDHome --ostype Ubuntu_64复制代码

设置内存大小4G

VBoxManage modifyvm UbuntuRDHome --memory 4096复制代码

建立虚拟磁盘:系统盘100G

VBoxManage createmedium --filename UbuntuRDHome_HDD_SYS_100G.vdi --size 100000复制代码

建立虚拟磁盘:HOME盘100G

VBoxManage createmedium --filename UbuntuRDHome_HDD_HOME_100G.vdi --size 100000复制代码

创建存储控制器IDE、SATA

VBoxManage storagectl UbuntuRDHome --name IDE --add ide --controller PIIX4 --bootable on
VBoxManage storagectl UbuntuRDHome --name SATA --add sata --controller IntelAhci --bootable on

移除控制器:
    VBoxManage storagectl UbuntuRDHome --name IDE --remove
    VBoxManage storagectl UbuntuRDHome --name SATA --remove复制代码

关联虚拟机磁盘

VBoxManage storageattach UbuntuRDHome --storagectl SATA --port 0 --device 0 --type hdd --medium UbuntuRDHome_HDD_SYS_100G.vdi
VBoxManage storageattach UbuntuRDHome --storagectl SATA --port 1 --device 0 --type hdd --medium UbuntuRDHome_HDD_HOME_100G.vdi

解除关联:
    VBoxManage storageattach UbuntuRDHome --storagectl SATA --port 0 --device 0 --type hdd --medium none
    VBoxManage storageattach UbuntuRDHome --storagectl SATA --port 1 --device 0 --type hdd --medium none复制代码

关联镜像文件

VBoxManage storageattach UbuntuRDHome --storagectl IDE --port 0 --device 0 --type dvddrive --medium ubuntu-16.04.3-server-amd64.iso

VBoxManage storageattach UbuntuRDHome --storagectl IDE --port 1 --device 0 --type dvddrive --medium VBoxGuestAdditions_5.1.22.iso

解除关联:
    VBoxManage storageattach UbuntuRDHome --storagectl IDE --port 0 --device 0 --type dvddrive --medium none
    VBoxManage storageattach UbuntuRDHome --storagectl IDE --port 1 --device 0 --type dvddrive --medium none复制代码

设置网络为桥接(nictype和bridgeadapter要根据主机的实际情况选择)

VBoxManage modifyvm UbuntuRDHome --nic1 bridged --nictype1 82545EM --cableconnected1 on --bridgeadapter1 enp5s0f0 
复制代码

设置远程桌面(可以使用VNC通过5540端口访问虚拟机桌面)

VBoxManage modifyvm UbuntuRDHome --vrdeport 5540 --vrdeaddress ""复制代码

打开远程桌面

VBoxManage modifyvm UbuntuRDHome --vrde on复制代码

关闭远程桌面

VBoxManage modifyvm UbuntuRDHome --vrde off


作者:RayPick
链接:https://juejin.cn/post/7027009565510090788


文章分类
代码人生
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐