VirtualBox 使用物理硬盘作为虚拟机硬盘
2013-09-07 13:14
357 查看
VirtualBox 使用物理硬盘作为虚拟机硬盘
前言
有的时候需要将一整个物理硬盘都当作虚拟的硬盘,其实这样做的用途很广的。比如你安装了双系统,Windows在第一分区上,Linux在第4分区,那么你可以在启动Windows之后创建一个虚拟机,并把整块硬盘作为虚拟机的硬盘。虚拟机启动之后进入到你的Linux系统,这样就可以同时运行你同一块硬盘的两个分区上的系统了。或者你也可以进入Linux之后创建虚拟机来启动你的Windows,这样一来你的两个系统就互通。当然,有点不足之处就是,你在Linux下不能挂载你的Windows系统分区,因为如果你挂载的话那么虚拟机就没法用这个分区了,也就没法启动那个分区的系统了。
创建VMDK文件
VMDK文件其实是一硬盘描述文件(如果你有兴趣可以用记事本打开),VBox的虚拟机可以直接使用该文件作为它的硬盘。 VBox的帮助文档这么描述VMDK的:While this variant is the simplest to set up, you must be aware that this will give a guest operating system direct and full access to an entire physical disk. If your host operating system is also booted from this
disk, please take special care to not access the partition from the guest at all. On the positive side, the physical disk can be repartitioned in arbitrary ways without having to recreate the image file that gives access to the raw disk.
在Linux下的话你可以使用下面的命令来创建VMDK:
VBoxManage internalcommands createrawvmdk -filename ~/mydisk.vmdk -rawdisk /dev/sda
这样就创建了一个和/dev/sda硬盘对应的虚拟硬盘文件mydisk.vmdk。 如果是在Windows下的话需要用下面的命令,记得先把VBox的安装路径添加到PATH环境变量里面,或者切换到VBox的安装目录下:
VBoxManage internalcommands createrawvmdk -filename mydisk.vmdk -rawdisk \.\PhysicalDrive0
其中
\.\PhysicalDrive0是第一个物理硬盘,如果你不确定是不是这个硬盘的话你可以用下面的命令检查一下分区情况:
Linux:
VBoxManage internalcommands listpartitions -rawdisk /dev/sda
Windows:
VBoxManage internalcommands listpartitions -rawdisk \.\PhysicalDrive0
通过修改最后的编号就可以看到不同硬盘的分区情况了。
创建了VMDK之后就可以新建一个虚拟机把这个vmdk文件指定为它的硬盘了。
建议阅读VirtualBox手册上的 Advanced storage configuration 部分内容获取更多信息。
原文来自 https://github.com/sintrb/techblog/blob/master/tools/virtualbox-using-a-raw-host-harddisk.md
相关文章推荐
- VirtualBox使用物理硬盘分区作虚拟机磁盘
- VirtualBox直接使用物理硬盘作虚拟机磁盘
- 让VirtualBox使用物理硬盘作为虚拟硬盘镜像
- VirtualBox使用物理硬盘建立磁盘
- VirtualBox 使用 img 作为启动硬盘
- VirtualBox 复制虚拟机 使用nat网络 虚拟机间互相访问 物理主机ssh访问
- 在虚拟机中使用物理硬盘的两个用法及注意事项
- 用Virtualbox 在linux和windows下 双系统互启 直接写物理硬盘 不使用硬盘镜像的方法
- virtualbox 使用物理硬盘
- VirtualBox扩展虚拟机硬盘
- Ubantu安装虚拟机VirtualBox使用Windows XP |设置文件夹共享| USB2.0虚实共用
- 虚拟机virtualbox中挂载新硬盘
- linux fedora 24 virtualbox 5.1 不使用 快照 启动 虚拟机
- 如何手工移动virtualbox的虚拟机硬盘
- 在vmware中使用实际物理硬盘分区,那么在虚拟系统启动后,该分区将被锁定,直到虚拟系统关机。
- 使用虚拟机不如买多一个硬盘?
- Win7下虚拟机个人使用小结:Virtual PC,VMware和VirtualBox
- [转]VirtualBox下RedHat 5.4 使用DVD光盘作为yum源
- VirtualBox安装及使用说明和虚拟机安装XP系统图文教程
- IOCTL_DISK_GET_LENGTH_INFO查询硬盘物理容量居然会导致 使用驱动器X:中的光盘之前需要将其格式化