Using linked clone of virtual machines

Virtual machines are so common today. We can use them for different purposes, from a test facilities to the production environment. Main advantages are faster deployment, resistance to hardware failures and easier reverting to previous known good state.

Today we have wide choice of virtualization systems. We can choose virtualization software that needs regular operating system, like Windows or Linux, or a stand-alone virtualization solutions, that we can install on the bare metal chassis.

I will show you how to use Oracle Virtual Box version 5.x to build your own virtual lab. You can perform all those tasks on similar way in many other solutions. However, not all solutions can offer all options mentioned in this article.

We can speed up deployment and save precious resources in same time, if we’re using a virtual machine clones. Process is very easy. We should install bare operating system and all necessary drivers on machine with minimal requirements for a normal work. That’s all in first step.

Then we will use that virtual machine (VM) as a foundation for all other VMs. We’re saving time on new installation and basic configuration for every new machine. Therefore, this machine will be considered as template for all new similar VMs.

Build your repository

We should build our repository of virtual machines. It should cover all operating systems and versions which we can use. Then we will clone appropriate template as many time as we need.

If you have a need for the testing environment, just like me, this is the right solution for you. Having 5-6 routers, couple of a workstation and few servers on the table requires lot of space, wiring, power sources. Plus all that noise and heat. In short, big mess. With my repository of a VM templates, I can simulate whole scenario inside my laptop.

2016-02-01 09_19_24-Oracle VM VirtualBox Manager

However, to have a really fast lab in your laptop you will need SSD hard disk. As they are more expensive then classic hard disks and with smaller capacities, disk space is precious. We need to conserve it as much as it’s possible. We should consider also that SSD drives have the memory cells, that after some time loosing their capability to remember written data. In short, we should write as less data to SSD as possible to extend it’s lifetime.

If you can’t afford SSD disk, you should consider to obtain fastest possible hard disk. In many laptops and desktops you can attach SATA disks. Instead of standard and cheaper disks on 5400 rpm you should use faster disks on 7200 rpm. Also, disks should be in AHCI mode, not IDE mode and with SATA speed of 6 Gbps.

Second important thing is RAM. You should install maximal amount of RAM supported by a motherboard in your computer. For better performances, close all unnecessary applications on your computer (like e-mail, Internet browser and similar applications) during usage of the virtual machines. That will free more RAM and release more CPU time for a virtual machines.

 

Full or linked clone

Easiest way to fulfill both requirements, fast deployment and minimal occupation of precious disk space, is to making linked clone of a virtual machine. Difference between full and linked clone is in connection between the template and a newly created VM.

If we’re using linked clone, then we will use virtual hard disk from template machine and then just add differences to disk of our new virtual machine. For example, templates for Windows Servers can be around 20 GB, that means that we can save every time such amount of the disk space. On the end of the day we can have 5 servers configured for work and total occupation of maybe 40 GB, instead of 100 GB. And all this in less than hour, instead to spend almost whole day. Of course, real numbers in your scenario can vary. That depends of what you need to do.

Also, we will have basic VM configuration like in our template. Then we can just change RAM size, vCPU (virtual CPU) count, network adapters and other properties. Therefore, best way is to have a basic configuration on the hardware minimum for a chosen operating system (OS). Then you can expand capabilities of new machine to fit project purpose and needs.

 

Linked clone of our template

I have all my templates grouped together in group named Sabloni (Templates in Serbian). I will expand that group and find machine that I need. In this particular scenario I need Windows Server 2012 R2 for some software deployment test. As basic VM already occupies a lot of disk space on my SSD, I will minimize further usage with linked clone. That will make copy of VM settings and differential hard disk.

2016-02-01 09_24_23-Oracle VM VirtualBox Manager

As you can see from my screenshot, I already have one linking on this machine. That’s not obstacle for me to make new one.

Word of caution here. You shouldn’t start basic VM nor change the disk content when you have linked VMs. Template should stay as it is, as far as it’s used in the scenario of a foundation for other working VMs.

We will right click on this machine and from context menu we will choose option Clone… .

2016-02-01 09_25_33-Oracle VM VirtualBox Manager

New window will appear and we’re starting process of virtual machine cloning. First step is to choose name of new machine. That will be also a name of folder where machine resides.

2016-02-01 09_30_51-Clone Virtual Machine

MAC address must be unique for every network adapter. It’s wise to reinitialize MAC addresses on every new machine. That will prevent situation that two VMs appear on same network segment with same  MAC address. If that happens, both machines will lost network connectivity.

Our next step is to choose Full or Linked clone. We will choose Linked clone here. You can see description of both option. Our new choice will save space, but we need both a template VM and our working VM to do the job.

2016-02-01 09_31_21-Clone Virtual Machine

After we clicked on the button [ Clone ], Virtual Box will begun process. This process will be short, as program need to create new VM configuration file and minimal snapshot disk.

This new disk (or disks) will be in same format as original disk. Their files will be in the Snapshots subfolder inside folder of new machine.

 

Moving virtual machine to other folder

I don’t like to have all machines in same folder. Virtual Box allows me to use groups, and therefore folders on disk, to collect all VMs for the same project on one place. This also helping me to easily and without mistakes delete old VMs from closed projects.

2016-02-01 09_31_40-Oracle VM VirtualBox Manager

Moving machine is really simple. Our new VM is in the same group as our template. We should drag it to the group where we want to store it.

2016-02-01 09_32_01-Oracle VM VirtualBox Manager

Virtual machine is now in new group and new folder on disk. After we finished our project, this new virtual machine and all it’s content can be deleted. However, we should always delete virtual machine and associated files from application.

 

Launching new machine

We can change settings of new VM before we launch it. We can add some RAM, network adapter or even additional hard disk. When we make all necessary changes, we can start our new VM.

VirtualBox_Windows 2012 R2 NICE Test_01_02_2016_09_41_42

Boot sequence speed depends on multiple factors, like amount of RAM in our machine and amount associated with our VM, CPU speed on our hardware machine, disk speed and type, and so on. If we using more then one virtual machine in same time, then some of them can also slow down other machines.

VirtualBox_Windows 2012 R2 NICE Test_01_02_2016_09_44_12

Eventually, our new virtual machine is up and running, ready to be used in our next great project. Very nice indeed.

Advertisements

7 thoughts on “Using linked clone of virtual machines

  1. Great tips! I just started using VirtualBox. Generally i use Vmware, but i will give this a try. It works fast so far, and hopefully it will help me building a new lab 🙂

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s