With the growing popularity of cloud technologies, it is increasingly required to migrate a server to a virtual machine like at dedicated server hosting. If you`re using Virtual Server Hosting based on VDI desktop as a service then it`s a complex task to migrate your server data to VM`s and it needs experts to take care of it. Moreover, this task is performed not only by system administrators, but also by ordinary users of Internet services.
In this article, we will consider what a virtual machine is, how system files are converted, in which formats you need to record a hard disk image, and with which utilities you can migrate the server to the cloud.
What is a Virtual Machine?
At a minimum, these are just two regular files. One contains a description of the “hardware” part of the machine, its “iron” configuration. And the second is the disk of this machine, designed primarily to house the operating system.
Which of them is more important is hard to say.
Infrastructure, of course, the configuration file is more important. But there is nothing unique about it. It is easy to reproduce if the original has been lost.
In practical terms, much more important is the file that contains the virtual disk. It is on it that all the system and application software of the virtual machine is located. There are diskless computers, but as a rule, they are very specialized, and we will not discuss them now.
A virtual disk can be viewed as a byte-by-byte copy of its usual file-based image.
Just like a regular “iron” disk can be disconnected from one computer and connected to another, so a virtual one can be transferred from one computer to another.
When trying to run an operating system or some commercial products from a transferred disk on another computer, there may be difficulties associated with licensing, but they are surmountable.
An idea arises: is it possible to convert the “iron” disk into an image file, and then connect it to a virtual machine. – The short answer is yes, you can. But nuances will arise.
Someone may be interested in the reverse transfer: from a virtual state to an iron state, but probably no one has yet met such a transition. – Too good in the cloud!
But moving a disk from one virtual machine to another is not an uncommon task.
It consists in moving the entire contents of the disk into the corresponding image file. When solving the problem of obtaining this file, you can encounter different disk states:
- Disconnected from the computer
- Is in the computer and is not a system one
- Is in the computer and is system
- Is in a computer that cannot be turned off and is a system computer
The first case can be considered the second, therefore, to obtain an image, you will still need to connect a disk device to some computer.
The second one is the most typical and relatively simple.
In the third, it is fundamentally important that you can turn off and restart your computer, including from another system media (CD or flash drive).
In the latter case, you need to shoe a galloping horse. And in all cases, special utilities will be required.
Programs for analyzing the contents of disks appeared and became widespread for a long time, even at the dawn of personal computers, hard disks and floppy disks. They easily read discs sector by sector or page by page and write what they read where needed.
Difficulties may arise when reading the system disk, since, firstly, during its operation, some files and areas may be locked; and secondly, some of the data on system disks changes very often, which can lead to a violation of the integrity of the recorded image. However, there are programs for creating images of system disks. Get cloud VPS expert help at vpsmalaysia.
The question is in what format to record the image.
A disk image is a sector-by-sector and even byte-by-byte copy. In the general case, it will be informationally redundant. If only because empty areas not occupied by files will be written to it.
Different virtualization platforms use different methods to optimize the work with virtual disks, including reducing their size. As a result, virtual disk image files for different platforms can have different formats.
With the growing popularity of cloud technologies, it is increasingly required to migrate a server to a virtual machine. Moreover, this task is performed not only by system administrators, but also by ordinary users of Internet services.
Now, if we consider what a virtual machine is, how system files are converted, in which formats you need to record a hard disk image, and with which utilities you can migrate the server to the cloud.
Migrating from One Physical Server to Another
A typical situation, a project starts, a very simple server is taken for it, which works for six months, the project grows and asks for a large and evil server.
Usually they put a new OS on a new piece of hardware, raise the software, configure, transfer content, databases, etc., change DNS and turn off the old server after two days. It would seem a simple procedure, any system administrator has done it hundreds of times. BUT, in the process, as practice shows, something is forgotten and already on the production server you need to make edits and settings, drag old crutches and adapt them in a new place.
This option is sometimes unavoidable, for example, when servers are located in different datacenters. But if the servers (new and old) are in adjacent racks, then you can simply transfer the OS to a new piece of hardware and turn off the old one immediately. I will write a short article-checklist on how to do this. So let’s go!
- Servers in the same datacenter from one colocator/dedicator
- You agreed with the bell / dedicator to re-link the ip addresses from the old server to the new one. If this is not done, there may be jambs if the servers are in different VLANs.
- You are given IP-KVM for at least a new server, ideally you may also need an old one if you suddenly want to keep it available.
- Your server provider has a pxe server with an emergency (so-called rescue) image and your platform.
- You know the root password from the source server.
- You copied, on a blank sheet of paper, from the old server network settings and disk layout.
So, all the conditions are met, let’s get started!
Load the new server over the network, for this Super micro, for example, need to enable pxe boot for the first network adapter in the BIOS, restart the server and press F12. If STP is enabled on the network switch on access ports, when a message appears about an attempt to get ip via dhcp, press the pause button and wait 30 seconds. Then press the spacebar and boot into CentOS 5.x 64 rescue.
fdisk- l see if the disks are hooked, if not, then install the RAID controller driver using insmod. If the disks are visible, we mark them as on the old server, if there is no controller and there are disks, we collect them using mdadm software RAID. Oh, and don’t forget about swap.