How to boot an Ubuntu VM from raw partition on physical disk in VMware


This tutorial assumes a dual boot installation on a physical drive. The instructions will guide you through the steps for creating a virtual machine using Windows 10 as the host and Ubuntu 18.04 as the guest. The process should be similar for other OS combinations though.

Creating a new VM in VMware Workstation player

Creating the VM

  1. Click “Create a New Virtual Machine”.
  2. Select “I will install the operating system later”.
  3. Select “Linux” and “Ubuntu 64-bit”.
  4. Give a name to your VM. I suggest something that makes clear that this is a VM booting frm a physical drive.
  5. Set the disk capacity of the virtual disk to the minimum possible. I used 0.1 GB and “store virtual disk as a single file”.
  6. Customize the hardware according to your needs and physical resources.
  7. Click Finish.

Congratulations, at this point you should have a new VM with a tiny disk (0.1 GB) and without any OS installed. Now we are going to make it aware of the physical drive and the partitions we are interested in.

Attaching the physical partitions

  1. Select the freshly created VM and click “Edit virtual machine settings”.
  2. Click “Add…”.
  3. Select “Hard Disk”.
  4. Select “SATA” as the Virtual disk type.
  5. Select “Use a physical disk (for advanced users)”.
  6. Allow administrative access to VMware (needed to access the physical drive)
  7. Select the Physical drive containing the OS you want to boot and select “Use individual partitions” if this physical drive contains any partitions used by the host OS (which is always the case on dual boot systems with a single hard disk drive).
  8. Now select the partitions of the host OS. Depending on your installation they can be more than one. In my case I have a partition for the root file systam (mounted at /), a partition for my users home directories (mounted at /home), and a swap partition. So I selected all three. The first two are labeled as Linux FS and the swap partition is labeled Linux Swap.
  9. Click “Next” and “Finish” to complete the procedure.

Unfortunately we are still not ready. If you try to boot this VM, you will observe that it fails to detect a bootable disk. This happens because we don’t have access to the EFI partition or the MBR (because they are already being used by the Host OS). To overcome this you can either create an MBR or EFI partition in a virtual disk or just boot using superGrub2. In this tutorial we are going to use the latter, as it is simpler and does not break with kernel upgrades.

Getting a bootloader

  1. Visit the download page of superGrub2 and download the ISO image.
  2. Select the VM and click “Edit virtual machine settings”.
  3. Select the “CD/DVD (SATA)” device.
  4. Check the “Connect at power on” checkbox.
  5. Select “Use ISO image file”.
  6. Click “Browse” and select the downloaded superGrub2 ISO image.
  7. Click “OK” to store the settings and exit.

Booting the VM

Now we can try booting our VM. Select the default option from supergrub’s menu. This will show you a list of the available options to boot. Select the one you want and press enter. You should now see the VM booting from the physical drive. Note however that it is highly expected to fail once more. This is most probably caused by your /etc/fstab of the guest OS. In my case, Ubuntu were trying to mount the EFI and swap partition, without success, resulting in a boot failure. To resolve this issue I booted natively in Ubuntu and commented out the corresponding lines in /etc/fstab (you should better use a live usb for this, though so that you can easily revert changes, especially when not 100% sure about what you are doing).

Have fun!!!

Next Steps

Disable hibernation in guest OS

You should probably want to disable hibernation in the guest OS to avoid the nightmare of booting natively in the guest OS, hibernating and then booting in the host OS and starting the guest OS through VMware. This will most probably corrupt your guest OS installation.

Improve VMware and guest OS compatibility through guest additions

This enables beter mouse and keyboard handling, clipboard sharing, folder sharing, etc. In the case of Ubuntu simply installing open-vm-tools though the ubuntu repositories is enough (sudo apt install oprn-vm-tools). I imagine that other popular GNU/Linux distributions include a similar package. If your operating system does not offer a similar package, you can always use the VMware tools (manually or through the VMware workstation)

Folder sharing

Now that we have the guest additions installed we can enable folder sharing between the host and the guest OS.

  1. Select the freshly created VM and click “Edit virtual machine settings”.
  2. Select the “Options” tab.
  3. Select “Shared Folders”.
  4. Select “Always enabled”.
  5. Click “Add…”.
  6. Select the folder you want to share and give it a name (we will need this name to mount the shared folder)

From now on, to mount this folder in the VM we need to issue the following command:

/usr/bin/vmhgfs-fuse .host:/ /mnt -o subtype=vmhgfs-fuse,allow_other

This will mount all shared folders under /mnt, e.g. a shared folder named foo (in step 6 above) it will be mounted under /mnt/foo.

There are more options that allow you to mount a single shared folder or even just a subfolder of a shared folder. For more details, and for older than 4.0 kernels, please see here.

Keep in mind however that the shared folder access is rather slow.