Access secondary hard disk from Virtual Machine

I have a fairly specific question.

I had Ubuntu on my Laptop (for years). For a variety of reasons, I've had to switch to Windows but the computer has two hard drives. The main drive was reformatted and I've installed windows. The second hard drive still has the Linux system disk format (not sure on type). Obviously, windows can't access it but can I access it from a Virtual machine (VirtualBox) or will I need to load up a Live-Session to access / move the contents?

Edit: If this is possible, how would one proceed to mount the disk?


Solution 1:

Yes, of course it is possible to set up Virtual Box to have raw access to an attached hard drive.

This is dangerous because data can get lost

We do have to make sure that we never ever access this drive from both, the host OS, and the guest OS at any time.

There is a nice tutorial found in the Virtual Box Manual on how to achieve this.

In short summary (do take the time to read the manual) we need to create a .vmdk file pointing to our hard drive:

VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk -rawdisk /dev/sda

We than may attach this file to our virtual machine

VBoxManage storageattach <NameofVM> --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium /path/to/file.vmdk