这篇文章主要针对linux纯命令行环境下安装windows的需求。
- 安装Virtualbox
- 下载
- rpm
- 安装扩展工具包
vboxmanage extpack install Oracle_VM_VirtualBox_Extension_Pack-5.1.22-115126.vbox-extpack
- 创建虚拟机
VBoxManage createvm --name "Windows XP" --ostype WindowsXP --register
- 配置虚拟机,以下命令也可以合并到一行完成
vboxmanage modifyvm win2003 --ostype Windows10配置系统类型,如果不是win10 32位可以通过vboxmanage list ostypes查找下vboxmanage modifyvm win10 --memory 2048配置内存2Gvboxmanage modifyvm win10 --acpi on配置电源管理vboxmanage modifyvm win10 --nic1 nat配置网卡工作模式vboxmanage modifyvm win10 --cpus 2配置CPU数量
- 创建虚拟硬盘
vboxmanage createhd --filename win10.vdi --size 102400新建一个100G的硬盘,注意这里会在当前目录下创建,如果需要管理的话记得换个目录。vboxmanage storagectl win10 --name win10HDD --add ide --bootable on新建硬盘控制器vboxmanage storageattach win10 --storagectl win10HDD --port 0 --device 0 --type hdd --medium win10.vdi绑定硬盘
- 安装系统
vboxmanage storageattach win10--storagectl win10HDD --port 0 --device 1 --type dvddrive --medium win10.iso挂载镜像VBoxManage modifyvm win10 --vrde on打开VirtualBox remote desktop extension(不然无法远程装系统)VBoxHeadless --startvm win10打开虚拟机并开始安装程序
- 后续工作(在刚才的远程桌面中配置并打开运行远程连接后)
vboxmanage modifyvm win10 --natpf1 "remote desktop,tcp,,3390,,3389"增加名称为“remote desktop”的端口转发,可以通过VBoxManage modifyvm win10 --natpf1 delete "remote desktop"删除firewalld-cmd --add-port=3390/tcp --permanent打开防火墙3390端口(如用iptables自行修改)VBoxManage modifyvm win10 --vrde off关掉virtualbox的远程桌面vboxmanage startvm win2003 --type headless从后台启动虚拟机(不然命令行窗口关了虚拟机就停了)
TIPS:
- 备份虚拟机
vboxmanage clonevm win10-Base --name win10-Test --register
- 取消注册虚拟机
vboxmanage unregistervm win10-Base