[英]Boot a native OS on a hard disk as a virtual machine
I'm searching for a solution to boot a native OS on a hard disk as a virtual machine.我正在寻找一种在硬盘上将本机操作系统作为虚拟机启动的解决方案。
It's like what VMware Fusion did on a Mac which boots Windows in Boot Camp as a virtual machine.这就像 VMware Fusion 在 Mac 上所做的那样,它将 Boot Camp 中的 Windows 作为虚拟机启动。
In detail, I have Windows installed on /dev/sda2 and Ubuntu 11.10 on /dev/sda5.详细地说,我在 /dev/sda2 上安装了 Windows,在 /dev/sda5 上安装了 Ubuntu 11.10。
Is there anyway to use a virtual machine software to boot the Windows on /dev/sda2 as a virtual machine while I'm using Ubuntu?无论如何,在我使用 Ubuntu 时,是否可以使用虚拟机软件将 /dev/sda2 上的 Windows 作为虚拟机启动?
You can do this via VirtualBox raw disk access.您可以通过 VirtualBox 原始磁盘访问来执行此操作。 ( http://www.virtualbox.org/manual/ch09.html ) It basically creates a "virtual" disk file that points to the actual partition and loads it as a disk drive in the VM.
( http://www.virtualbox.org/manual/ch09.html ) 它基本上创建了一个指向实际分区的“虚拟”磁盘文件,并将其作为磁盘驱动器加载到 VM 中。 I've installed Linux guest in VB on Windows host in such a way, and the installation can boot from the VM or by itself.
我已经以这种方式在 Windows 主机上的 VB 中安装了 Linux 来宾,并且安装可以从 VM 或自行启动。
Yes, I did this long ago following this guide:是的,我很久以前就按照本指南这样做了:
https://lists.ubuntu.com/archives/ubuntu-us-nm/2008-February/000521.html https://lists.ubuntu.com/archives/ubuntu-us-nm/2008-February/000521.html
of course, always backup and be careful!当然,总是备份并小心!
Essentially:本质上:
Used a USB 3.5 HD enclosure and connect the XP drive to it.使用 USB 3.5 HD 外壳并将 XP 驱动器连接到它。
If the drive was shutdown uncleanly you may need to manually
mount it with the following command.使用以下命令挂载它。
sudo mount ntfs-3g /dev/whereyourdriveis /mount/somemountpoint -o
force力量
Once the drive is mounted under linux contiunue to step 2.
More Info : I should add, I have successfully done this, but I also had success using this method years even years before.更多信息:我应该补充一点,我已经成功地做到了这一点,但我在几年前甚至几年前也成功地使用了这种方法。 So there are at least two known and tested ways for accomplishing this that I can tell you.
因此,我可以告诉您至少有两种已知且经过测试的方法可以实现这一点。
As answered, this also can be done in VirtualBox, this is the way that works for me正如回答的那样,这也可以在 VirtualBox 中完成,这是对我有用的方式
Always, make sure that you are running as Administrator(Windows) or Sudo(Linux) , any changes that you do will write to the REAL disk, so be carefull始终确保您以管理员身份运行(Windows)或Sudo(Linux) ,您所做的任何更改都会写入真实磁盘,因此请小心
In Windows在 Windows 中
C:\Program Files\Oracle\VirtualBox>VBoxManage.exe internalcommands createrawvmdk -filename "E:\virtualbox\linuxhd.vmdk" -rawdisk "\\.\PhysicalDrive1"
RAW host disk access VMDK file E:\virtualbox\linuxhd.vmdk created successfully.
In Linux在 Linux 中
$ VBoxManage internalcommands createrawvmdk -filename "~/linuxhd.vmdk" -rawdisk "/dev/sda"
It will create a file with something around 1kb
that is a link to the physical hard drive.它将创建一个大约
1kb
的文件,该文件是物理硬盘驱动器的链接。
Then create a Virtual Machine as ever you do.然后像往常一样创建一个虚拟机。
If you want to map only a partition如果只想映射一个分区
At Windows在 Windows
\\.\Physicaldrive1 -partitions 1
(Disk start with 0, partitions with 1) (磁盘以 0 开头,分区以 1 开头)
At Linux (Much more intuitive)在 Linux 上(更直观)
/dev/sda1
/dev/sda2
etc.
Eventually you can get resolution issues even after install vboxadditions
, in my experience the problem is your /etc/X11/xorg.conf
it is configured to your specific real hardware specs(I have a offboard GPU for example), least in my case I solve it simply removing this file (xorg auto configure at boot, only will not work if you set some specific setting), so run:最终,即使在安装
vboxadditions
,您vboxadditions
遇到解决问题,根据我的经验,问题是您的/etc/X11/xorg.conf
它被配置为您特定的真实硬件规格(例如,我有一个板外 GPU),至少在我的情况下我只需删除此文件即可解决它(xorg 在启动时自动配置,只有在您设置某些特定设置时才会工作),因此运行:
sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.original && sudo rm /etc/X11/xorg.conf
Reference参考
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.