Use Physical Drive with VirtualBox under Mac OS X

Mac下VirtualBox使用物理磁盘启动操作系统

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.

几个月之前我不得不使用渣果了,因为需要使用Xcode和Swift。然而VMware不提供渣果系统的版本,这就让我只能选择VirtualBox来替补了。

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.

但VirtualBox使用物理磁盘就不像VMware那么方便了。所以我把整个过程列出来,以免自己忘掉了,也可供他人参考。

  • 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
dev$ls
  • 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
Category
Tagcloud
Telescope Life FuckChunWan Server Geology RTL-SDR Hack RaspberryPi Python Pyenv macOS GeoPython Communicate IDE Lesson Story Mount&Blade Visualization ChromeBook GIS VTK Camera VirtualBox Translation Junck Disease Raspbian QEMU Science MayaVi NAS Kivy University Software Poem Scholar FckZhiHu Game Learning Xcode Hadoop DIY Hardware Video Linux Book Photo Shit Memory Microscope Hackintosh Chat Programming Radio Virtualization Hate Photography PHD Mac CUDA GlumPy Translate PyOpenCL Moon QGIS Lens Discuss HBase FuckZhihu Download Library OpenCL Data Conda QT VisPy