Virtualbox使用物理硬盘作为虚拟机硬盘

Posted by wsxq2 on 2019-03-19
TAGS:  VirtualBox

VirtualBox 使用物理硬盘作为虚拟机硬盘

官方相关文档:VirtualBox手册第9章第9节第1小节

参考CSDN: 让VirtualBox使用物理硬盘作为虚拟硬盘镜像GitHub: VirtualBox 使用物理硬盘作为虚拟机硬盘

Linux

1
2
3
fdisk -l
VBoxManage internalcommands listpartitions -rawdisk /dev/sda
VBoxManage internalcommands createrawvmdk -filename ~/mydisk.vmdk -rawdisk /dev/sda

Windows

1
2
3
4
wmic diskdrive list brief
cd "C:\Program Files\Oracle\VirtualBox"
.\VBoxManage internalcommands listpartitions -rawdisk \\.\PhysicalDrive0 
.\VBoxManage internalcommands createrawvmdk -filename mydisk.vmdk -rawdisk \\.\PhysicalDrive0

遇到的问题

VERR_SHARING_VIOLATION?

  1. 问题:
    1
    2
    
     Admin>VBoxManage internalcommands listpartitions -rawdisk \\.\PhysicalDrive0
     VBoxManage.exe: error: Cannot open the raw disk: VERR_SHARING_VIOLATION
    
  2. 原因:磁盘被其它进程占用
  3. 解决思路:找到占用该磁盘的进程,关闭它
  4. 具体步骤:

    The VERR_SHARING_VIOLATION comes up because a running process in the host is using the hard disk. You’ll need to “release” it. Use the “Process Explorer” from SysInternals to see who’s responsible for that. You could actually download the whole “SysInternals Suite”, invaluable set of tools.

    In my case, I enabled the Admin mode (menu “File” » “Show Details for All Processes”) and I used the menu “Find” » “Find Handle or DLL…” » “HardDisk0”

详情参考VMDK: VERR_SHARING_VIOLATION(末尾)

VERR_ACCESS_DENIED?

问题;

1
2
SimpleUser>VBoxManage internalcommands listpartitions -rawdisk \\.\PhysicalDrive0
VBoxManage.exe: error: Cannot open the raw disk: VERR_ACCESS_DENIED

原因:权限不够 解决思路:以管理员身份运行即可

链接

下面总结了本文中使用的所有链接: