Windows Users: Virtualize Your Linux Partition
If you're primarily a Windows user but want occasional access to your Linux partition, you can do so using some of VirtualBox's built-in tools.
BUT FIRST, A WARNING: These tools are very advanced and are considered "expert" tools in VirtualBox. You'll need to do some command line work to make it happen, and there's a reason: without the proper precautions, you could cause serious data corruption on your Windows partition. Use these instructions at your own risk and for God's sake, back up all your data before you try this and keep your data backed up regularly! We also highly suggest you read the corresponding chapter in VirtualBox's manual before you continue.
We're going to use Ubuntu for this tutorial, but you should be able to reproduce the steps with other Linux distributions. Also, if you have proprietary graphics drivers, you may encounter problems—VirtualBox has trouble with 3D acceleration in this setup. For now, it's best to use the default open source graphic drivers. Check out the video below for an overview of the process, then read on for the individual steps.
Step One: Create Your New Virtual Machine
Assuming you already have both partitions set up, boot into Windows and perform the following steps:
- Back up everything before you begin. No, I'm serious. Don't skip this step. Don't!
- Open up a Command Prompt as an administrator and run the following command:
wmic diskdrive list brief /format:list
Find the drive on which your Linux partition resides and note its number (in my case, it was Disk 0) - Use the CD command to change to the directory in which VirtualBox is installed. For me, this was:
CD "C:\Program Files\Oracle\VirtualBox"
- Run this next command, replcaing the variables with the correct ones for your system:
VBoxManage internalcommands createrawvmdk -filename "C:\Users\Whitson\Desktop\Ubuntu.vmdk" -rawdisk \\.\PhysicalDrive0
Replace the file path with wherever you want to put your VMDK file. Replace the 0 in \\.\PhysicalDrive0 with your disk number. - You should get a message saying the VMDK was created successfully. If not, make sure you followed these steps exactly, and if you're still having problems read through that manual chapter. You may have special needs that we didn't discuss here.
Step Two: Create a GRUB ISO
Now, boot into Linux. We're going to use Ubuntu for this example. Before we set up our virtual machine, we'll need to put the GRUB bootloader on an ISO, since not all computers will load your existing version of GRUB properly. Once you're inside Linux, perform the following steps:
- Create a new folder on your desktop and call it "iso." Inside that folder, create one called "boot," and inside the boot folder, create a folder called "grub."
- Open a terminal and run the following command:
cp /usr/lib/grub/i386-pc/* /home/yourusername/Desktop/iso/boot/grub
Obviously, replace "yourusername" with your user name. - Next, run:
cp /boot/grub/grub.cfg /home/yourusername/Desktop/iso/boot/grub
- Run the following command:
sudo nano /home/yourusername/Desktop/iso/boot/grub/grub.cfg
Scroll down to the section that says "menuentry 'Windows'" or something similar, and delete everything from "menuentry" to the "}" at the end of that section. - Lastly, run:
grub-mkrescue -o boot.iso /home/yourusername/Desktop/iso/
If you get an error saying "xorriso: not found," you may have to install the xorriso package with:sudo apt-get install xorriso
When you're done, you should have a file called boot.iso in your home directory. Copy this to a flash drive or to your Windows partition.
Step Three: Boot Into Your New Virtual Machine
Now, it's time to boot back into Windows and get this sucker up and running. Once you've returned to Windows:
- Run VirtualBox as an administrator. Click the New button and name your virtual machine. Choose the amount of RAM to allocate to the virtual machine as normal.
- At the next step, choose "Use an existing virtual hard drive file." Click the browse button on the right, and browse to the VMDK file we made earlier. Click the Create button. If all goes well, you should see it show up in VirtualBox's sidebar.
- Select your new virtual machine in the sidebar and click the Settings button. Under Storage, select "Controller: IDE" and click the plus sign next to it. Press "Choose Disk" and navigate to the boot.iso file we created earlier. Click OK and return to the main VirtualBox screen.
- Select your new virtual machine and click the Start button. Choose Linux from the GRUB menu that pops up.
- If all goes well, you should see your Linux installation's login screen. You can log in, install VirtualBox's Guest Additions, and use your Linux partition without shutting down Windows!
IMPORTANT NOTE: Never try to mount or read from your Windows partition while you're running Linux in VirtualBox. This is where the danger of this method comes in. If you try to read your Windows partition, your machine will crash and you could cause data corruption (since your host OS is already using that partition). In fact, I recommend removing it from your fstab file so it never pops up in Linux, thus keeping you much safer.
full article on :https://lifehacker.com/how-to-dual-boot-and-virtualize-the-same-partition-on-y-493223329
full article on :https://lifehacker.com/how-to-dual-boot-and-virtualize-the-same-partition-on-y-493223329
Comments
Post a Comment