How to Mount Internal ext4 Drive as Storage for Linux VirtualBox on Windows 10

hard drivelinuxUbuntuvirtual machinevirtualbox

I have a Windows 10 host PC and a Linux Mint 18.2 virtual machine under Oracle VM VirtualBox (V 5.1.26r). The Windows OS and VirtualBox run from the same hard drive, and I would like to extend the ext4 storage of my virtual machine by enabling it use an additional ext4 formatted internal hard drive as storage. I was able to format the drive as ext4 under Windows using PartitionGuru, but how can I make this drive available as storage to my virtual machine? Note that I do not have space on the NTFS boot drive to add the ext4 drive as a Virtual Drive.

EDIT: Using Ext2Read in Windows I was able assign the ext4 drive a letter name. I was then able to use this drive as a shared folder in my Linux VirtualBox, but the problem here is that this changes all of the default Linux permissions, e.g., all text files become executable. How can I mount AND keep permission?

Best Answer

Direct disk access isn't for the faint of heart. See here, section 9.9.

Warning

Raw hard disk access is for expert users only. Incorrect use or use of an outdated configuration can lead to total loss of data on the physical disk. Most importantly, do not attempt to boot the partition with the currently running host operating system in a guest. This will lead to severe data corruption.

My advice is to format the internal hard disk in Windows as NTFS with the largest cluster size you can manage and assign to it a drive letter, say, G:.

Then, in VirtualBox, add a new hard disk file located on G:, with size equal to the free space available on it (or use a dynamic disk; performance impact isn't all that great, or so I found. Your mileage may vary).

Add the disk to the SATA controller of the Linux guest, and in Linux you'll find a new /dev/sdb disk ready to be fdisk'ed and made ready.

Related Question