Use Physical Drive with VirtualBox under Mac OS X


I used to work with a Linux or Windows PC a lot. I always use VMware Player on both of them.

我一般都用Linux或者Windows。在用这两个系统的时候我总选择VMware Player作为虚拟机软件。

I choose VMware because the Player is free for personal use and the functions of it are powerful. I can use it to install any operating system into both a virtual hard disk file and a physical hard drive. The second kind installation is very useful that I can boot the target OS installed both in the VMware Player and on the real machine. Booting it in the Player makes it easy for me to make adjustment at the same time with other work under the host OS. And booting the target OS on the real machine changes it into a whole real operating system and could archive the best performance of the hardware.

我用VMware主要因为Player对个人应用是免费的,而且功能也非常强大。通过VMware Player,我可以随意在虚拟磁盘文件或者物理硬盘上面安装一个操作系统。第二种安装功能非常有用处,通过这样方式安装的系统即可以在虚拟机里面启动,也可以用来启动物理机。在虚拟机里面启动很方便,我可以随时对系统进行调整,随时用外面的宿主系统做其他的事情。而用这个系统来启动物理机就能把虚拟机系统变成真正的操作系统来使用,发挥和直接物理安装一样的高性能。

Then some months ago I had to begin working with a Mac, because I've been learning to code with Xcode and Swift. But VMware doesn't provide a version of VMware Player for Mac OS X, that makes me no choice but to take VirtualBox as an alternative one.


The use of physical hard drive with VirtualBox is not that easy as the VMware Player. So I list the process here in case that I forgot or some other friends met similar situation.


  • The first step is finding the right disk number. You need to enter the dir of /dev, and then use the command ls to show the list of your devices.
    • 第一步就是找到你要用的磁盘序号。你需要进入根目录下的dev文件夹,在里面使用ls来列出所有设备信息。
$cd /dev
  • I find my target drive is /dev/disk0. In my case, I am using two hard disks in the Mac boot. One is /dev/disk0 installed with both Linux and Windows already, and the other one is /dev/disk1 with Mac OS X. I am planing to use the /dev/disk0 in the VirtualBox.

    • 我的目标磁盘就是disk0。我用的渣果机器有两块硬盘。一个是disk0,已经装了Linux和Windows。另一个是disk1,安装的是渣果系统。我准备在VirtualBox里面用disk0.
  • After finding your target drive, you need to eject all the mounted volumes of the disk, and then get access to it by using the commands below (remember that you need to change the /dev/disk0 to your disk path):

    • 找到目标之后,你要推出该磁盘所有已挂载的分区,然后使用下面的命令来获取权限(机主你要把这里的disk0改成你自己的那个硬盘编号):
$sudo chmod 777 /dev/disk0
  • Then you can use the command below. Here it is only an example. You need to change DISK_NAME into your favorite name and change ~/(meaning the user's home) into your own dir.
    • 接下来你要运行下面的命令来创建虚拟磁盘文件了。这里只是一个例子。你需要把DISK_NAME改成你喜欢的名字,另外~/这个目录(就是当前用户的主目录)也改成你要用的目录。
$sudo VBoxManage internalcommands createrawvmdk -filename ~/DISK_NAME.vmdk -rawdisk /dev/disk0
  • You can not use the vmdk file created unless you change the ownership of it and chmod it to 777.
    • 现在你还不能使用这个vmdk文件,你还得获取所有权,然后更改其权限为777。
$sudo chown YOUR_USER_NAME DISK_NAME.vmdk
$sudo chmod 777 DISK_NAME.vmdk
  • After that you can use you physical hard drive in the VirtualBox under Mac OS X.
    • 这一步做完之后,你就可以在渣果系统中,让VirtualBox使用这个镜像文件所链接的物理硬盘了。
Category: Mac
IDE Server Raspbian Discuss MayaVi Poem Translation Hackintosh Library GlumPy Data Moon Kivy University Disease NAS Pyenv Life ChromeBook QT Download Photo RTL-SDR Microscope Scholar VisPy Game PyOpenCL Mount&Blade CUDA Chat Hardware VTK Programming OpenCL Conda RaspberryPi VirtualBox Hate Software Video Story Book Mac Science DIY Lesson Memory GeoPython Geology Camera Junck Visualization Hack Python Lens Telescope Radio Communicate Linux Xcode