/*******************************************************************************
* VirtualBox 使用物理硬盘
* 说明:
* 之前一般都是将数据存储在虚拟硬盘中,每个虚拟机的资源使用感觉比较臃肿,
* 不方便管理,所以打算除了基本编译系统以外,其他源代码存在共享的物理硬盘中,
* 这样对数据统一管理方便一点。
*
* 2018-12-17 深圳 宝安西乡 曾剑锋
******************************************************************************/
一、参考文档:
. Virtualbox直接运行物理分区的系统
https://callmewing.com/2016/03/29/Virtualbox%E7%9B%B4%E6%8E%A5%E8%BF%90%E8%A1%8C%E7%89%A9%E7%90%86%E5%88%86%E5%8C%BA%E7%9A%84%E7%B3%BB%E7%BB%9F/
. 让VirtualBox使用物理硬盘作为虚拟硬盘镜像
http://www.voidcn.com/article/p-zkqkeoid-bce.html
二、处理方法:
. 查看当前Windows物理硬盘信息,在Windows cmd中运行:wmic diskdrive list brief
C:\WINDOWS\system32>wmic diskdrive list brief
Caption DeviceID Model Partitions Size
LITEON CV8-8E256 \\.\PHYSICALDRIVE0 LITEON CV8-8E256
. 把Virtual Box的安装路径添加到PATH环境变量里面,为了能够使用VBoxManage创建物理硬盘映射出来的虚拟硬盘;
. 查看指定物理硬盘分区信息:
C:\WINDOWS\system32>VBoxManage internalcommands listpartitions -rawdisk \\.\PhysicalDrive0
Number Type StartCHS EndCHS Size (MiB) Start (Sect)
0x00 / / / /
0x00 / / / /
0x00 / / / /
0x00 / / / /
0x00 / / / /
0x00 / / / /
0x00 / / / /
. 创建物理硬盘映射出的虚拟硬盘: VBoxManage internalcommands createrawvmdk -filename "</path/to/your/virtual/disk/file>" -rawdisk "<DeviceID>"
. VBoxManage internalcommands createrawvmdk -filename "zengjf.vmdk" -rawdisk "\\.\PhysicalDrive0"
. zengjf.vmdk内容:
# Disk DescriptorFile
version=
CID=cf9fb569
parentCID=ffffffff
createType="fullDevice"
# Extent description
RW FLAT "\\.\PhysicalDrive0"
# The disk Data Base
#DDB
ddb.virtualHWVersion = ""
ddb.adapterType="ide"
ddb.geometry.cylinders=""
ddb.geometry.heads=""
ddb.geometry.sectors=""
ddb.uuid.image="76610083-f7ca-458a-be76-abc5a064906f"
ddb.uuid.parent="00000000-0000-0000-0000-000000000000"
ddb.uuid.modification="00000000-0000-0000-0000-000000000000"
ddb.uuid.parentmodification="00000000-0000-0000-0000-000000000000"
. 创建指定分区物理硬盘映射出的虚拟硬盘: VBoxManage internalcommands createrawvmdk -filename "</path/to/your/virtual/disk/file>" -rawdisk "<DeviceID>" -partitions ,,,
. VBoxManage internalcommands createrawvmdk -filename "zengjf.vmdk" -rawdisk "\\.\PhysicalDrive0" -partitions ,
. zengjf.vmdk内容:
# Disk DescriptorFile
version=
CID=738ed84b
parentCID=ffffffff
createType="partitionedDevice"
# Extent description
RW FLAT "zengjf-pt.vmdk"
RW ZERO
RW FLAT "\\.\PhysicalDrive0"
RW FLAT "\\.\PhysicalDrive0"
RW ZERO
RW ZERO
RW ZERO
RW ZERO
RW ZERO
RW ZERO
RW FLAT "zengjf-pt.vmdk"
# The disk Data Base
#DDB
ddb.virtualHWVersion = ""
ddb.adapterType="ide"
ddb.geometry.cylinders=""
ddb.geometry.heads=""
ddb.geometry.sectors=""
ddb.uuid.image="2a0e378d-073c-48a3-9f82-4803dbb5d6b8"
ddb.uuid.parent="00000000-0000-0000-0000-000000000000"
ddb.uuid.modification="00000000-0000-0000-0000-000000000000"
ddb.uuid.parentmodification="00000000-0000-0000-0000-000000000000"
. zengjf-pt.vmdk是二进制文件,这里不列出来;
. 将虚拟硬盘加入虚拟机系统就可以使用了。