You are not logged in.

#1 2017-04-02 19:55

Dai_trying
Member
From: UK
Registered: 2015-12-14
Posts: 1,726
Website

Create Virtual Machine from existing installation

I had to shut down and pack away some of my machines due to some major works on the house, and wanted to have my development machine available. I thought this would be a chance to test out a theory and create a VM from my HDD installation and was quite surprised at how easy it actually was!

I started by booting a live-cd and used gparted to clone my dev partition to my external HDD which took a little while but no more than I expected, next I copied my Data over to another newly created partition on my external HDD (I keep all documents etc on separate partition) and then shut down the machine and took my external HDD to the laptop.

I booted my main installation and created a new virtual machine (I used a saved appliance of q4os 1.8 for speed, but you can just use the iso and do a fresh install and install gparted afterwards) I resized the VM HDD to give enough free space to place my installation.

Once booted into the VM I connected my external unit and loaded gparted to clone the partition to the free space in the VM HDD. This takes a little time but I was doing other stuff too so it didn't seem very long. Once the partition was successfully copied I disconnected the external unit and mounted the new partition to edit the line in fstab that loads swap and entered the VM swap UUID in place of the old one and commented out the loading of my data partition.

Next I edited /etc/default/grub to ensure grub is displayed at boot time (you can just press escape when booting and bypass that bit) and performed a grub update to register the new partition. All went well and the new partition is shown in the grub output, feeling quite pleased with the result I then rebooted to my new partition by selecting the second (technically it's the third) entry in grub and arrived at my desktop, which, although missing a few things like background and data files, is looking very similar to the original.

From here I removed the original VM installation (using gparted) and installed grub from my dev partition and everything was reported as correct. It was now time to move my partition so I booted the VM with a live-cd to allow me to move the main partition (again using gparted) to the beginning of the partition (where the original install was) and created a second DATA partition for my files. I didn't copy the files across yet as I want to retain correct user (and not use adminq).

Another reboot and I'm back into my dev system and can check fstab and uncomment the loading of my DATA partition (after correcting the UUID) and another quick reboot to ensure it works ok. Now I plug in my external HDD to copy my files across to the new DATA partition and once complete another reboot and I have everything exactly the same as my desktop machine but in a virtual environment on my laptop!!

It does seem strange to be able to start virtualbox up in a virtual machine but I'm pretty sure I will run into problems if i try using it there so I'll leave that one alone (for now...) smile

Just thought i would post this as I have seen posts on other forums and people asking if they can do this but have been told it's not possible without a lot of messing about, and this way seems pretty easy!

If you know an even easier way to do it I would love to hear it.

Dai

Offline

#2 2017-04-02 21:44

JimW
Member
Registered: 2015-12-08
Posts: 210

Re: Create Virtual Machine from existing installation

I tried running a vm guest inside a vm guest once. Because you are using memory from the host for the first vm, and have to use part of that memory for the guest in the guest, things start getting rather bogged down! smile
It does work, but rather slowly! interesting experiment and fun to see three different operating systems running on the same machine at the same time.

Offline

#3 2017-04-02 21:59

Dai_trying
Member
From: UK
Registered: 2015-12-14
Posts: 1,726
Website

Re: Create Virtual Machine from existing installation

It's definitely an interesting concept, but I thought it might have issues running. I will no doubt try it at some stage to see how far I can push it, although I might need to invest in more ram first. smile

Offline

Board footer

Powered by FluxBB