0

So, i cat'ed my windows partition into a file (plain cat /dev/sdx > win7.bin). mount -o loop -t ntfs mounts the image correctly and lets me read/write everything.

Now the question is: could i run this OS image straight within Virtualbox? If yes, how?

1 Answer 1

1

Please see:

Convert physical disk to vm

VirtualBox can mount entire physical hard disks as well as only selected partitions of a drive. In today’s tutorial, we will only discuss mounting entire VirtualBox physical hard disks.

VirtualBox Raw Hard Disk Access This method is called VirtualBox “raw hard disk access.” This allows you to mount or boot a secondary hard drive or external USB, for example. We’ll show how to do this when running VirtualBox on a Windows, Linux or Mac OS X host machine.

You’ll first want to create a virtual machine within the VirtualBox GUI. Choose all options like normal, but when asked about the virtual hard drive, select Do not add a virtual hard drive.

Next, you’ll need to find the path and drive number of the physical drive you’d like to mount:

In Windows, open Disk Management. You’ll see the associated drive numbers on the left and will identify them later as PhysicalDrive0, PhysicalDrive1, etc.

In Linux, run the following command: sudo fdisk -l. You’ll see a listing of the partitions. Make note of the desired drive in the format of dev/sda0, dev/sda1, etc.

In Max OS X, use the following command: diskutil list. You’ll see a listing of the partitions. Make note of the desired drive in the format of /dev/disk0, /dev/disk1, etc.

Now open the CLI of your OS. If you’re using Windows as the host OS you will also need to go to the root directory of VirtualBox using the following command: cd C:Program FilesOracleVirtualBox

Now you can run the command to create the virtual hard drive file that points to your desired physical drive. For each of the following examples ensure that you input the desired names between the arrows and replace the number or pound sign with your desired drive number.

For Windows:

VBoxManage internalcommands createrawvmdk -filename "C:Users<user_name>VirtualBox VMs<VM_folder_name><file_name>.vmdk" -rawdisk .PhysicalDrive#

It may be easier just to convert the machine to a virtual machine and use the virtual machine. That will last longer as well. Your physical disk will eventually die. Virtual machines can last almost forever. Some of mine are a couple of decades old and continue to work.

3
  • Thanks for the pointer, i managed to convert the raw image into a vmdk! However, that ppartition was not the one with a bootloader on. Any suggestion for how to boot it?
    – Pa_
    Nov 30, 2022 at 23:43
  • I am not entirely certain . You might be able to start with a Windows 7 repair USB. See if you can start with that. I am not sure .
    – John
    Nov 30, 2022 at 23:53
  • I tried with the installation media disc iso -> repair bootloader, but it doesn't even find the OS.. Maybe adding a second disc, and installing a grub in there or something?
    – Pa_
    Dec 1, 2022 at 0:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.