How to connect a physical disk in VirtualBox

Usually for hosting virtual machines use virtual hard disks. They represent a file on a normal hard drive, which has its own partition table and the data partitions. But in some situations it may be necessary to access real hard disk from virtual machine.

It may be useful to install an additional operating system while you are working in the main or for sharing data between the virtual machine and the real world. In this article we will look how to connect a physical disk in VirtualBox.

For this you should know the file the hard disk in the /dev directory of the Linux operating system. You can watch it using a utility Gparted:

In this example we will connect to the virtual machine NVMe drive identifier /dev/nvme0p1. To create on the basis of the identifier of the disk file to VirtualBox, run the following command in the terminal:

sudo VBoxManage internalcommands createrawvmdk -filename ~/nvme0p1.vmdk-rawdisk /dev/nvme0p1

File for VirtualBox stored in our home folder. The command should be run as root. To be able to use the disk in VirtualBox, you need to run a virtual machine, as root:

sudo VirtualBox

You can now select this disk when creating a new machine or connect to an existing machine in the settings. In Windows the command would look similar, only it is necessary to add the extension .exe and the drive ID will be different. It can be viewed with the utility disk Management, which you can open from menu Control the icon My computer. Now that you know how you connect the physical drive to virtualbox.

Source: losst.ru

(Visited 12 times, 1 visits today)