How to: create a Virtual Machine from a Hard disk in Linux

edited December 2016 in Software
Hello every one, I got this idea from a professor of mine and thought maybe it's worth sharing.
So you maybe thinking, why do I want to do this way when I could just do this by using hd2vdi tool from Microsoft. Well, lets say that we didn't have a computer that is Windows XP and newer. Let say that we had a Windows 98-ME computer that we wanted to revive for the hell of it.

For this I will be using Debian 8.6 (Linux). First thing that you want to do is locate your old computer. Depending on how old it is, I would recommend using DSL (damn Small Linux), as this will run on most old hardware with 50mb of ram. Once you get your Linux choice up and running on the computer. You should log on as root and take a look and type this command.
fdisk -l

This command will show all attached hard disk/ floppy devices on the computer that hasn't been mounted, The output should look like this:
Disk /dev/sdb: 19 GiB, 20416757760 bytes, 39876480 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device     Boot Start      End  Sectors     Size Id Type
/dev/sdb1  *       63 39873329 39873267  19G  c W95 FAT32 (LBA)
For me, my disk is /dev/sdb1/, which matches the know hard drive size of 19GB. Next depending on your setup and drive space, we need to copy the disk entirely and save it as a .raw file. To do that we would use this:
dd if=/dev/sdb of=winme.raw bs=1M
Note that I'm copying the whole disk /dev/sdb, we do not want to copy the partition /dev/sdb1.
If you are low on disk space, you would want to run this command from your local computer to the old computer:
run from local computer
ssh user@remote "dd if=/dev/sda of=image.gz bs=1M”
I found this command here.

After the data has transfered, you will need to install virtual box. Once that has completed installing, run this command to convert your raw data into a vdi disk:
vboxmanage convertdd sdb.raw sdb.vdi --format VDI
or
VBoxManage convertdd sdb.raw sdb.vmdk --format VMDK

Now that we have converted the raw disk into a virtual machine, we are now able to run it! Although I want to note that there maybe problems with your new VM. As the hardware emulated will be fairly different than what your machine was running on.

For Windows 9x based systems, all you need to do is change the VM settings to compatible hardware of that time period. For reference here is a website that helped me, along with another website for help with the graphics driver.
Sign In or Register to comment.