虚拟机中Linux分区扩容
打开Virtualbox所在的安装目录,执行以下命令,命令中的虚拟有磁盘路径改成自己的:
调整容量前,先关闭虚拟机。接着,打开CMD,进入VirtualBox的安装目录,执行VBoxManage list hdds
命令,查看目前挂载的虚拟机硬盘信息,找到第一行UUID数据:
cd C:\Program Files\Oracle\VirtualBox
VBoxManage list hdds
VBoxManage modifyhd your_UUID --resize your_Expansion_size
//扩容50G
VBoxManage modifyhd 4d0dcc28-a39b-414f-b401-4984cb4fc3e3 --resize 51200
1//进入系统,安装 Gparted 软件
2sudo apt install gparted




3.1. 虚拟机扩容失败
提示 VBoxManage.exe: error: Failed to resize medium
这需要新建一个.vid,并且把原来的.vid克隆到新的.vid,再对新.vid进行扩容。
1VBoxManage.exe createhd -filename "D:\vx\docker1\yourdesk" -size 151920 -format VDI -variant Standard
1VBoxManage.exe clonehd "D:\vx\docker1\docker1.vdi" "D:\vx\docker1\yourde
或者:

列出所有的虚拟机
VBoxManage list vms
显示所有虚拟机的配置信息
VBoxManage list vms --long
列出所有正在运行的虚拟机
VBoxManage list runningvms
列出VirtualBox所能识别的所有客户机操作系统
VBoxManage list ostypes
显示主机的Hardware time、CPU、内存、操作系统及系统版本信息
VBoxManage list hostinfo
//输出中的"Processor count"指的是CPU的线程数
列出所有VirtualBox支持的虚拟磁盘后端
VBoxManage list hddbackends
列出VirtualBox当前正在使用的虚拟磁盘的信息
VBoxManage list hdds
列出虚拟机配置文件中加载的虚拟磁盘镜像的信息
VBoxManage list dvds
显示VirtualBox的一些全局设置信息,包括Guest Additions文件的路径
VBoxManage list systemproperties
显示虚拟机的配置信息
VBoxManage showvminfo |
详细显示虚拟机的配置信息
VBoxManage showvminfo | [--details]
创建并注册一个虚拟机
VBoxManage createvm --name "Win 2008" --register
将虚拟机Win 2008重命名为win2008
VBoxManage modifyvm "Win 2008" --name win2008
将虚拟机win2008的操作系统类型改为Windows 2008(32位)
VBoxManage modifyvm win2008 --ostype Windows2008
修改虚拟机的内存大小
VBoxManage modifyvm <uuid|name> [--memory ]
将虚拟机win2008的CPU个数设为2个
VBoxManage modifyvm win2008 --cpus 2
将虚拟机的第一启动设备设为硬盘
VBoxManage modifyvm win2008 --boot1 disk
将虚拟机win2008的第一个网卡的网络连接方式设为桥接
VBoxManage modifyvm win2008 --nic1 bridged
将虚拟机win2008的第一个网卡的网卡芯片类型设为82540EM
VBoxManage modifyvm win2008 --nictype1 82540EM
将虚拟机win2008的第一个网卡桥接到host的eth0网卡上
VBoxManage modifyvm win2008 --bridgeadapter1 eth0
//前提是虚拟网卡1使用的网络连接方式是桥接
开启VirtualBox remote desktop extension (VRDE) server
VBoxManage modifyvm win2008 --vrde on
//VRDE server的默认监听地址为0.0.0.0,默认监听端口为3389
以VBoxHeadless作为前端来启动虚拟机win2008
VBoxManage startvm win2008 --type headless
创建一个大小为100G的虚拟硬盘
VBoxManage createhd --filename win2008.vdi --size 102400
给虚拟机win2008添加一个IDE控制器
VBoxManage storagectl win2008 --name "IDE Controller" --add ide --controller PIIX4
将win2008.vdi文件作为虚拟机win2008的第一块IDE硬盘
VBoxManage storageattach win2008 --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium win2008.vdi
配置第一个IDE光驱,并挂载安装光盘
VBoxManage storageattach win2008 --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium server_2008_64.iso
将主机的/home/vbox目录共享给Guest虚拟机win2008,且共享名为share
VBoxManage sharedfolder add win2008 --name share --hostpath /home/vbox
//该命令必须在关闭虚拟机之后才能执行
将主机的/home/vbox目录瞬间共享给Guest虚拟机win2008,且共享名为share
VBoxManage sharedfolder add win2008 --name share --hostpath /home/vbox --transient
//该命令在虚拟机运行时就可以执行,但当虚拟机关闭(指虚拟机的状态为poweroff)后该共享文件夹不会保留
中科大镜像源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
deb https: //mirrors .ustc.edu.cn /ubuntu/ focal main restricted universe multiverse deb-src https: //mirrors .ustc.edu.cn /ubuntu/ focal main restricted universe multiverse deb https: //mirrors .ustc.edu.cn /ubuntu/ focal-updates main restricted universe multiverse deb-src https: //mirrors .ustc.edu.cn /ubuntu/ focal-updates main restricted universe multiverse deb https: //mirrors .ustc.edu.cn /ubuntu/ focal-backports main restricted universe multiverse deb-src https: //mirrors .ustc.edu.cn /ubuntu/ focal-backports main restricted universe multiverse deb https: //mirrors .ustc.edu.cn /ubuntu/ focal-security main restricted universe multiverse deb-src https: //mirrors .ustc.edu.cn /ubuntu/ focal-security main restricted universe multiverse deb https: //mirrors .ustc.edu.cn /ubuntu/ focal-proposed main restricted universe multiverse deb-src https: //mirrors .ustc.edu.cn /ubuntu/ focal-proposed main restricted universe multiverse |