Creating a virtual copy of your computer. Import and Export of a virtual machine in VirtualBox

Perhaps I’ll start with the fact that if you want backups on VMWare, then get ready to pay. Free VMWare is free as long as we are not talking about migrations, backups and the like. At this point you can start an endless holiwar, but without my participation. My stories will only be about Hyper-V on Windows Server 2012R2. Although some of the article can be applied to VMWare, there are likely to be pitfalls.

We can backup to Hyper-V for free, or rather, using Windows tools for which we have already paid by purchasing Windows Server licenses. For the convenience of working with our backups (besides, we also paid for this), we will use WDS and deduplication (maybe group policies).

1. Backup from inside virtual machines

1.1. Backup of today

As far as we know, any Windows can make backups. Moreover, any Windows backup settings through the interface ultimately come down to the background use of the wbadmin utility. What exactly can wbadmin do? And it can make both a backup of an image with a system partition and a backup of individual folders. In this part of the article, we are only interested in the backup image (of the system partition). The rest is specific data of virtual machines and needs to be backed up separately. Hence the conclusion: Do not store any valuable information, databases, or individual applications on the system partition of virtual machines (and on regular computers too). We install MS SQL Server / MS Exchange / “1C Application Server” and others only on non-system partitions or on separate disks.

So, what is needed for the backup to work? And you only need one command:

Wbadmin.exe start backup -backupTarget:\\Backup Server\FolderForInternal Backup -allCritical -quiet
In fact, this command requires special rights, but more on them later. Now it is important to understand one thing. This command does more than just backup. She makes an incremental backup. Moreover, different backups are generated for server and desktop (client) Windows. And the difference is that for server operating systems we will get snapshots of each backup, but for desktop OSes, only the last snapshot will always remain. You may ask, what kind of incremental backup is this? But it remains “incremental”, because we are not backing up the entire image, but only the part that has changed since the last backup (which means less traffic and faster backup creation).

Those who have encountered a similar situation will notice that the backup will always be “incremental” (full). Since the backup takes place in our case to a network drive. That is, for server Windows, only the latest images remain.

Later, I discovered that there is no difference in the work of wbadmin on the server and client OS. The only difference is in the interface. wbadmin performs incremental backups (except for the first backup) if the hard drive is specified in the -backupTarget key (the command uses the default key -vssCopy). Or it produces a full backup if you add the -vssFull switch.

1.2. Backup with the history of previous images

At the moment, we have made a backup of virtual machine images. But this is just a backup of today’s photos. Tomorrow it will be completely different... But what will happen if you make backups? Yes, and truly incremental. That's what we'll do.

Wbadmin.exe start backup -backupTarget:e: -allCritical -include:d: -quiet #where drive D is backups for today, and drive E is backups with history
But this was not enough for me and I did this:

(echo select vdisk file="\\Backup Server2\FolderFor Backup2\BackupNameForThisServer2.vhdx" echo attach vdisk) | diskpart
The script connects a virtual disk from the network. After the backup, a similar script disconnects the disk. The OS remembers that the drive has the letter E defined. But God forbid you slip in someone else’s drive with the same letter E, the backup will work in full (not incrementally and to someone else’s drive). Keep this in mind and use a letter towards the end of the alphabet (X, Y, Z)…

Let me note right away that if today’s backup is carried out in parallel with the backup with history, we will end up with a backup that cannot be restored.

To get a backup of previous days, you can use the interface (GUI) of the server on which backups with history are made. Moreover, it knows and remembers all runs of the wbadmin command in the Windows console. The recovery service will allow you to select the desired archive in backups with history.

2. Backup vhdx files of virtual machines

It is done easily and naturally:

Wbadmin start backup -backupTarget:$BackupPath -hyperv:$VMList -Quiet
But with some peculiarities. This command must be executed in PowerShell and first obtain the list of virtual machines into a variable. For a detailed example, please contact Google.

Backup of virtual machines in Windows Server 2012 R2 is done using Hyper-V snapshots. I also note that virtual machines are suspended if they have a Linux kernel or are missing Hyper-V drivers. I personally refused to backup virtual machines in this way. The reason is that on Windows Server 2012 (not R2) it was necessary to stop virtual machines before backup. And even now on Windows Server 2012 R2, Linux pauses do not suit me, when there is the first good backup method. (there is a remark in the comments to this article). After the next update to Windows Server 2012 R2, backup of any virtual machines occurs without interruption. Linux OS can also be backed up “from within” using Dump (CentOS, Ubuntu), but this is a separate topic with puppets and other software in my case.

3. Restore backup and WDS

And now, in my opinion, the most useful part of this article is about backups.

WDS is Windows Deployment Services (Windows Deployment Services) and part of the functionality of Windows Server 2012R2. This service used to be called RIS, but I have not encountered it. In general, the essence of WDS is simple. We registered in DHCP (automatically for DHCP Windows Server) in the form of separate parameters and then loaded it onto the computer over the network (this is how the computer BIOS is configured to boot over the network) via the TFTP WDS bootloader. Next, the WDS loader allows you to select from the Windows “bootloader” images available on it. There are different bootloaders - these are installer bootloader images, PE, and RE images. The installer loader also requires images of Windows themselves in WDS, but this is the case if you need to install Windows over a network. We are interested in RE images that allow you to recover a machine from a backup.

I won’t explain in detail how and what works in WDS. But here are the important notes:

  1. If your RE bootloader loads on a Hyper-V virtual machine over the network, but the keyboard does not work in it. Congratulations, your RE image is for WinXP or older and does not know about the existence of Hyper-V drivers.
  2. If your system starts restoring a backup, but stops. Delete all partitions on the hard drive (on which the backup is restored) and try again. Just don’t forget that the backup may be broken and after deleting all the partitions on your hard drive, you may not have anything left of the old information.
  3. If the backup is loaded with UEFI, and you want to restore it to a computer without UEFI, then don’t waste your time. Most likely you won't be able to deploy the backup.
  4. A backup with UEFI boot and GPT partitions can be restored to machines with a different processor/motherboard, but with MBR format partitions and a regular BIOS boot, it is unlikely to be deployed on another machine. Well, I definitely didn’t succeed.
  5. If you try to deploy a backup to a disk with a smaller capacity, then this will not work. Even if the disk in the backup was almost empty. In this case, restoring to a virtual machine with a dynamic disk helps. Next, reduce this disk and create a new backup. But this is only possible with a UEFI boot loader in a backup (for why, read the previous paragraph).
  6. Before restoring a backup, you should disconnect extra disks so as not to overwrite the information on them.

4. Features of deduplication

You can deduplicate running virtual machines. You can deduplicate today's backups and you can deduplicate historical backups. All this gives a big positive plus to the volume of hard drives (both HDD and SSD). But don't forget about some things:
  1. If deduplication works on disks larger than 1 TB, the deduplication optimizer will use a lot of memory.
  2. If deduplication works with compressed data, but with more than 10 TB of compressed data, then the duration of the deduplication optimizer will be too long. This can happen if you simply copy data daily to a deduplicated disk in different folders.
  3. It is possible and even necessary to store backups on HDD, but you should not store working virtual machines on HDD in quantities greater than 5-10. This applies to deduplication only in that deduplication of such working virtual machines will reduce HDD performance to zero.

5. Group policies

Here you can implement the installation of a backup script using GPO for a long time and in different ways. But I would like to draw attention to important points:
  1. Backups should only be made on behalf of a separate user account.
  2. Do not store scripts with passwords in group policies.
  3. Run a script with special rights to read all system information.
Well, actually conclusion: Backup using wbadmin tools is possible, quite feasible and, most importantly, viable. But only if you have time and a lot of patience for all sorts of little things. For example, the article does not say anything about how to monitor successfully created backups. I managed to do monitoring on Zabbix, but I could write a couple more articles about this... I hope the article will be useful to you and save a lot of invaluable time.

Many businesses, as well as home users, are increasingly using virtual machines to perform various tasks and increase the efficiency of their activities. If previously virtual machines were used mainly by enthusiasts, now the quality of desktop and server virtualization platforms has allowed them to be used by professionals on a large scale. The ability to run multiple virtual systems on one physical computer has many advantages, including savings on hardware, simplified maintenance, and reduced energy costs in large data centers. In addition, an important advantage of virtual machines is their easy portability to another physical platform and a simple procedure for backing them up. But just like regular operating systems, virtual environments require high attention to creating backup copies of critical data. When running virtual machines in an enterprise production environment, many companies plan entire strategies for archiving and recovering virtual infrastructure after failures, which are called Disaster Recovery.

Many commercial virtualization platform providers offer enterprise users built-in virtual machine backup tools, such as VMware Consolidated Backup (VCB) for the ESX Server platform. However, in the SMB (Small and Medium Business) sector, where the number of virtual machines used is small, there are practically no backup tools provided by the platform manufacturer. As a result, small companies have to hire system administrators to write various scripts, as well as use standard operating system utilities to archive and restore files and folders with vital data.

Understanding data backup

Along with the virtual infrastructure planning process, it is also necessary to initiate the process of developing a Disaster Recovery Plan. First of all, it is necessary to highlight the most critical elements of the IT infrastructure that are potentially susceptible to damage from internal and external sources, such as power outages, hard drive failures, virus threats, and others. After this, it is necessary to consider the frequency of backup of virtual machines of various categories depending on the degree of criticality. The company's virtual production servers, which operate in full public availability mode, must be archived quite often and regularly and have the ability to be quickly restored in the event of a failure. An organization's internal servers, which do not require as much attention and rapid recovery, can be backed up less frequently, with longer recovery times. Then you need to determine which storage devices will be used for archiving (IDE or SCSI drives of other servers, SAN devices, etc.).

When choosing the frequency of archiving, it is necessary to take into account that some types of backup have the property of creating quick backups, but slower recovery. Conversely, it is possible to perform longer archiving with shorter recovery times. The following are the main types of data backup that can also be applied to virtual machines:

  • Regular (full) archiving (full backup)
    This type of archiving creates a complete copy of all stored data. The process of creating such a backup copy is quite lengthy, but does not require much recovery time, since it does not require multiple recovery tasks. Full backup resets file and folder archive markers, which are used to determine which files should be backed up. These markers are used to check file states during incremental and differential backups.
  • Incremental backup
    This type of backup involves copying files and folders that have changed since the last backup. Therefore, if you perform two incremental backups in succession and do not change the file between them, it will not be added to the recovery image.
  • Differential backup
    This backup includes all changes that have occurred in files and folders since the last full backup. Accordingly, with two consecutive differential archiving, a file that has not changed between them, but has changed since the last full archiving, will be archived both times.

In order to explain how these types of archiving differ, we will give an example of combining types of backup. When using full and incremental archiving, backup time is significantly reduced, but recovery time is increased. For example, if we did a full backup on Monday and rolled out additional backups every day, and on Friday the system was damaged, we will need to restore the full backup copy of Monday and sequentially all additional copies until Friday, which will take a very long time. Combining full and differential activation, on the contrary, requires more time for archiving, but less time for recovery, since you only need to restore the full archive copy of Monday’s data and roll Friday’s differential archive onto it.

These, of course, are not all types of archiving that can be used when backing up data, but the types listed are some of the most frequently used. Obviously, for servers with high recovery time criticality, it is more advisable to use differential archiving in combination with full archiving rather than incremental archiving. The first is suitable for external servers of the organization, the second - for internal ones, which can tolerate more downtime.

Since, basically, a virtual machine is a folder with files, you can use the built-in backup tools of the host operating system if you are using a virtualization platform on top of the host system, such as, for example, Microsoft Virtual Server or VMware Server. In Microsoft Windows, you can use the utility for these purposes ntbackup. When using bare-metal platforms such as ESX Server or Virtual Iron, you must use the virtualization system vendor's tools or third-party products.

Additionally, virtual machines can be backed up by creating guest images using software such as Acronis True Image. It is also worth noting that there are situations when it is necessary to archive not the entire virtual machine, but some data in the guest system. In this case, when writing batch archiving scripts, you can use utilities to mount virtual disks on the host system. For VMware platforms, this utility is the VMware Disk Mount application.

Backup and recovery of virtual machines on the VMware ESX Server platform

VMware's pilot product, the ESX Server platform, is a key element of virtual infrastructure in an enterprise production environment. Virtual infrastructure VI3 (Virtual Infrastructure 3) is a set of products and tools that allow a fleet of virtual machines to effectively perform their tasks and function smoothly under various conditions, including force majeure factors such as sudden load surges, power outages and equipment damage. One of the most important tools for implementing a Disaster Recovery strategy is VMware Consolidated Backup (VCB). VCB can be used to create backup copies of individual ESX servers, as well as in conjunction with the VMware Virtual Center virtual server fleet management tool. VCB provides the following capabilities:

  • creating backup copies of virtual machines with various types of archiving using a special proxy server VCB Proxy Host, which removes the burden of creating backup copies from the company’s production server where the virtual machines are running
  • does not require installation of additional agents on ESX servers
  • provides ample opportunities for integration with third-party backup products; support for various packages is already built into VCB
  • supports file-level archiving for Windows guest systems (you can create backup copies of individual files and folders within the guest system), as well as virtual machine image-level archiving for any guest OS

Backing up virtual machines using VCB takes place by creating snapshots of virtual machines without stopping their operation. VCB also supports SANs. If the virtual machines are located on a SAN storage device, the backup procedure is as follows:

Snapshots of virtual machine states created during operation using an agent located on the VCB proxy server are saved on backup media, from where they can then be restored in the event of a failure of a running guest system or equipment damage. In this case, the backup agent has direct access to the LUNs (Logical Unit Number) in the SAN devices. For SAN networks, VCB supports the Fiber Channel protocol, as well as tape media for storing backup copies. VCB closely leverages the capabilities of VMware Tools running inside the guest system to create backup copies of guest OS data.

VMware Consolidated Backup currently supports the following packages (the list includes only officially tested software with the ESX Server product):

  • Symantec Backup Exec 10.0
  • Symantec Backup Exec 10d
  • Veritas Netbackup 5.0
  • Veritas Netbackup 5.0 MP4
  • Veritas Netbackup 5.1
  • Veritas Netbackup 5.1 MP2
  • Veritas Netbackup 5.1 MP3
  • Veritas Netbackup 6.0
  • Tivoli Storage Manager v5.2.1
  • Tivoli Storage Manager v5.2.3
  • Tivoli Storage Manager v5.3
  • EMC Networker v7.0
  • EMC Networker v 7.1.x
  • EMC Networker v 7.2
  • EMC Networker v 7.3
  • CA BrightStor ARCServe r11
  • CA BrightStor ARCServe r11.1
  • CA BrightStor ARCServe r11.5
  • Commvault Galaxy v5.9
  • Commvault Galaxy v6.1

In general, the work of creating archive copies of virtual machines can be represented as follows:

  1. The backup software runs a pre-archive script that performs the following tasks:
    • makes sure that no read-write operations occur within the guest system into saved folders and files (for Windows guest OSes only)
    • switches the virtual machine to snapshot mode, creates a snapshot of the state of the virtual machine and makes it available to the application using the VCB
    • mounts a snapshot of the virtual machine from the SAN to the proxy server
  2. A backup copy of a snapshot of the virtual machine is created at the image level, or at the level of files and folders of the guest system (full, differential or incremental copy).
  3. The backup software calls a post-backup script that completes the backup (unmounts the virtual machine snapshots from the proxy server and takes the virtual machine out of snapshot mode).

During the backup process, VCB tools use the following virtual infrastructure components:

To summarize, VMware Consolidated Backup is a powerful tool for creating backup copies of virtual machines and allows you to use standard backup software used in your organization to create archival copies of your data.

Backup with Vizioncore esxRanger

Vizioncore's esxRanger product, now controlled by Quest Software, is currently one of the most popular solutions for creating backup copies of virtual machines on the ESX Server platform. esxRanger does not require installation of any additional agents on ESX servers and creates backup copies of virtual machines from a single server or group of servers through integration with the Virtual Center product. The process of creating backup copies occurs on a single Windows server, from where archived images of virtual systems can be stored on various storage devices in the organization's production environment.

esxRanger has both a GUI and a command line interface, allowing you to use the regular Windows Task Scheduler to run scheduled backup jobs, eliminating the need to write additional scripts. The main window of the esxRanger product is shown below:

By connecting to VMware Virtual Center, if you have the appropriate permissions, you can select individual virtual machines of data center servers for backup. Copied images are automatically compressed during archiving and decompressed during recovery, saving system administrators time.

esxRanger integrates with VMware Consolidated Backup when used in SANs and allows you to create full or differential copies of virtual machines, as well as individual files and folders in Windows guests. Additionally, during the backup process, esxRanger collects various information about backup metrics (such as time spent on backup and recovery), stores it in a database, and allows you to use it to trend your Disaster Recovery strategy. In addition to this, esxRanger has a policy engine that allows you to build a data archiving strategy based on templates and integrate it with other components of the organization's IT infrastructure, minimizing the workload of system administrators.

The backup procedure using esxRanger looks like this:

  1. A virtual machine savepoint is created and saved to the database.
  2. Using the VMware API, virtual disk files are “unlocked” for reading (they are locked by default) and the creation of .REDO files that will store changes to the virtual disks since the save point.
  3. Virtual disk files are compressed.
  4. The compressed files are backed up and the .REDO files are applied to the VMDK files of the virtual machines.
  5. After the changes are applied, the VMDK files are returned to their original locked state.
  6. The system administrator adds comments to the backup copies of the virtual machines, containing instructions in case the virtual machines fail.

Overall, esxRanger is a convenient, reliable, and easy-to-use virtual machine backup tool for Virtual Infrastructure 3 that integrates with VMware Consolidated Backup for use across SANs for companies of any size.

Creating backup copies of virtual machines on the Microsoft Virtual Server platform

Unfortunately, Microsoft, the owner and developer of the server virtualization product Virtual Server 2005, does not provide users with such a powerful backup and recovery tool as VMware Consolidated Backup. For now, Microsoft is focused primarily on developing hypervisor-based virtualization support built into the next version of the Windows Server platform, codenamed Viridian. However, Microsoft is constantly delaying the final release date of Windows Virtualization, and is also cutting back on its announced features, so it is now difficult to say anything definitive about the backup capabilities of the upcoming virtualization platform. With a fairly high probability we can say that there will be built-in support for “live” archiving, but it is not yet clear in what form. Today, backups of virtual machines in Virtual Server can be created “two and a half ways,” including:

  • use of standard tools for backing up operating system images, which can be created by agents running inside guest systems, for example, Symantec Backup Exec.
  • writing specialized scripts that save the state of the virtual machine, copy its data to backup media and start the virtual machine again
  • the use of Volume Shadow Service (VSS), support for which in Virtual Server appeared quite recently and is not yet supported by manufacturers of data backup systems

In order to archive running virtual machines on the Virtual Server platform, you can use its COM interface by writing a script, for example, using Visual Basic Scripting (vbs). When you back up a virtual machine, you must first put it in Saved State, then copy its files to a specified location, and then run it again. Below is an example of a vbs script that does these necessary steps to copy a single virtual machine. It can be launched on a schedule using the standard Windows task scheduler. " backupvm.vbs " author: John Savill " usage: backupvm.vbs Option Explicit On Error Resume Next Dim objFSO, objVirtualServer, objVM, objSaveTask, objVHD " Connecting to a file system object set objFSO=CreateObject("Scripting.FileSystemObject") " Connecting to Virtual Server set objVirtualServer = CreateObject("VirtualServer.Application") " Search for a virtual machine set objVM = objVirtualServer.FindVirtualMachine(WScript.Arguments(0)) " Saving virtual machine state set objSaveTask = objVM.Save " Pause to perform a save operation while not objSaveTask.isComplete WScript.Sleep 1000 wend " Copying virtual disks and UNDO disks for each objVHD in objVM.HardDiskConnections If objFSO.FileExists(objVHD.HardDisk.file) Then "Wscript.Echo objVHD.HardDisk.file & " " & WScript.Arguments(1) objFSO.CopyFile objVHD.HardDisk.file, WScript.Arguments (1) End If If objFSO.FileExists(objVHD.undoHardDisk.file) Then "Wscript.Echo objVHD.undoHardDisk.file & " " & WScript.Arguments(1) objFSO.CopyFile objVHD.undoHardDisk.file, WScript.Arguments(1 ) End If Next " Copy vsv and vmc files objFSO.CopyFile objVM.File, WScript.Arguments(1) objFSO.CopyFile objVM.SavedStateFilePath, WScript.Arguments(1) " Starting a virtual machine objVM.Startup

This script must be used as follows:

C: emp>cscript backupvm.vbs

It should be noted that Microsoft does not officially support this backup process, since the integrity of a virtual machine copied in a saved state may be compromised due to the fact that part of its memory is not saved in the vsv and vhd files in this case.

Using the Volume Shadow Service

VSS support was introduced in the recently released Virtual Server 2005 R2 SP1. Using shadow copy services in Virtual Server involves creating backup copies of running virtual machines by creating images, which should significantly simplify and speed up the backup and recovery procedure. However, it is not enough for backup software to support VSS; it also needs to support the new Virtual Server VSS Writer Service (VS Writer), which no archiving system has been able to find support for at the moment. According to Microsoft, backup tools can use VS Writer to back up and restore virtual machines in the following way: they notify Virtual Server that the backup process has begun, Virtual Server responds by creating a snapshot of the virtual machine, and then the copy process begins. At the moment, the NTBackup utility does not support this mechanism either.

Backing up Xen virtual machines

XenSource, which supports the Open-Source Xen project and also distributes the commercial virtualization platform XenEnterprise, does not offer many options for archiving virtual machines on the Xen platform. One of them is shown below using NFS (Network File System) storage devices.

Background information:

  • XenServer host (in the example backup procedure its IP is 192.168.1.10)
  • The computer used as a server for storing archive copies (in the example, its IP is 192.168.1.1)
  • XenVM virtual machine (in the example its IP is 192.168.1.12)

Backup procedure:

  1. Install the NFS server by adding the following line to the /etc/exports file:
    / *(rw,sync,no_root_squash)
  2. On the XenServer host, add the following to the /etc/xen/xmexample1 file:
    kernel /boot/xenkernel
    name = "ExampleDomain"

    Root = /dev/nfs

    Nfs_server = "192.168.1.1"
    nfs_root = "/ip=192.168.1.10:192.168.1.1:192.168.1.1:255.255.255.0:::"

  3. Save a copy of the /etc/fstab file and add the following lines to it:
    192.168.1.1:rootdevice/nfs rw,hard,intr 1 1
    192.168.1.1:swapdevice swap swap defaults 0 0
    192.168.1.1:usrpartition /usr nfs rw,hard,intr 1 1
    192.168.1.1:varpartition /var nfs rw,hard,intr 1 1
    none /dev/pts devpts gid=5,mode=620 0 0
    none /proc proc defaults 0 0
  4. Copy /lib/modules/2.6.16.29-xen from the XenServer host to the backup device
  5. Run the following command on the archive copy server:
    #scp 192.168.1.10:/lib/modules/2.2.16.29-xen /lib/modules/
  6. To activate the console using udev, run the following commands on the backup server:
    mkdir /tmp/dev
    mount --move /dev /tmp/dev
    sbin/MAKEDEV null console zero
    mount --move /tmp/dev /dev
  7. Run the following command to mount the backup device on the Xen host:
    #xm create -c xmexample1
  8. Back up the xenstore-ls file and copy the contents of the file system (except for the /proc and /sys directories) to another folder:
    #rsync -a -e ssh --exclude="/proc/*" --exclude="/sys/*" 192.168.1.10:/ /backupdir

Conclusion

Drawing up and implementing a backup and disaster recovery plan (Disaster Recover Plan) for the most important servers and workstations of an organization is a necessary component of its activities. Virtual machines, even more than physical ones, require high attention to data archiving, since usually several virtual systems are consolidated on one physical host. Leading virtualization platform vendors are striving to provide powerful and convenient backup capabilities, but so far only VMware has achieved this. The backup strategy can be carried out in two ways: one of the simplest ways is to do this as part of the standard strategy for archiving data in the company’s IT infrastructure, by installing backup agents in guest systems and creating images. Another, more convenient and faster way is to use built-in platform tools such as VMware Consolidated Backup or writing scripts by system administrators. In any case, we must never forget that equipment failure or other force majeure circumstances should not significantly affect the company's critical activities.

VirtualBox is a useful application from Oracle for creating virtual machines. In simple words, you can run multiple operating systems on your computer at the same time, such as Windows, Android, or . This is a shell that emulates the operation of a real computer with certain characteristics (processor, RAM, video memory). But if you are reading this article, then you probably know why VirtualBox is used. We will answer a question that Oracle VM users often ask – “ How to transfer files to a VirtualBox virtual machine

For example, I use Windows 10 and installed good old Windows XP on a virtual machine. How to exchange files between the real and additional OS? Very simple.

Method 1 – Shared Folders

First of all, you need to install the VirtualBox Guest Additions. Without them, you won't be able to work with shared folders. Start the virtual machine, select “Devices”, “Mount Guest OS Additions disk image” from the menu.

The installation will begin, after which you will need to reboot the machine. Installed? We can continue.

Launch VirtualBox, select the desired virtual machine and click “Configure”.

Go to the “Shared Folders” tab. Click on the add a new folder icon, specify its name and location. Also, do not forget to check the box next to “Auto-connect” so that the guest OS will automatically connect this folder.

Launch the virtual OS. A network drive has appeared in Windows XP Explorer, which is a shared folder that can be used with both the guest OS and the real one. Now you can calmly transfer the necessary files to the VirtualBox virtual machine.

Method 2 – Drag’n’Drop function

Oracle VM has a very useful feature called Drag'n'Drop. It allows you to transfer files using the mouse, dragging them to the desired location. In the virtual settings. machine, go to “General”, “Advanced” and activate this function. The mode is bidirectional.

Imagine the situation: an accountant’s computer is faulty (otherwise it cannot be otherwise with an accountant’s computer!). It (on this computer) has a bunch of programs installed that can take three days or even more to restore. But an accountant needs to work without interruptions, and it’s better for him not to touch anything for another three years, to wait for a total collapse. What to do? An old system backup will not work - programs are updated and added quarterly, and therefore an old system image made on a freshly installed system will not work.

It would be a good idea to leave everything old and at the same time make everything new. Just in such a situation, you can make a virtual copy of a computer that is still working and check its performance. (for example, on the administrator's computer). Then demolish everything on the accountant’s computer, install a fresh system and run a virtual machine on this fresh system until the work smoothly flows to the host machine. At the same time, you can leave the guest file (this is essentially a working accounting backup!) in the archive - after all, it’s just a file, albeit 20 gigs in size, but who cares about that now.

So the idea is clear. Its implementation is also not difficult. To do this, we will use two free programs: Oracle VirtualBox And Paragon Go Virtual.

Step 1: create a virtual copy of a working computer

To create a virtual copy of your computer, we use the Paragon Go Virtual program. This program is available for download from http://www.paragon-software.com/home/go-virtual/ for free. You only need to provide your name and email - a letter with a serial number will be sent to this email. After installing the program, you will need to restart your computer.

The program interface is extremely simple - only two buttons on the main window. Select "P2V" (physical to virtual). It will be necessary to select the type of future virtual machine - we choose Oracle VirtualBox.

The copying process will take some time, you can drink some tea. At the end, the program will create at least two files: drive C and a settings file with the OVF extension. If you create a copy of your computer with multiple drives, there will be more files. The created disk images will be in VMDK (VMWare) format. But VirtualBox works great with them.

Step 2: import the created copy into Virtual Box

For the purity of the experiment, let’s copy the resulting files to another computer (let’s call it the admin’s computer). If the administrator’s computer does not yet have VirtualBox (!!! ahtung!!!), install it immediately.

In the main window of the VirtualBox program, select the “file” menu - “Import configuration” and select the file with the OVF extension created by Paragon Go Virtual in step 1. VirtualBox itself will understand what to do next.

Note: before performing this operation, look in the VirtualBox settings where it will store the disk and virtual machine settings files - the files will be quite large, and by default, the path will be on the system drive, which is not always convenient.

During the virtual machine creation process, VirtualBox will copy the hard drive files created by Paragon Go Virtual. Once VirtualBox has finished the import process, the files created by Go Virtual can be deleted (check that the virtual machine starts first!).

Step 3: Finish

Most likely, you do all this at work, so be careful when starting a virtual machine - because if the VirtualBox network adapter is in bridge mode, your copy of a real working computer on the network may cause conflicts. I usually do this: before starting the virtual machine, I completely disable the network in the settings of this machine in the console of the main VirtualBox window. From sin. I connect VBoxGuestAdditions.iso as a CD and after loading the virtual machine I install add-ons (for mouse integration, adjusting the screen size, etc.). Please note that you need to give Windows some time to update the hardware list and install new display drivers, etc. The guest virtual machine will need to be rebooted.

All. You have created a real working copy of the computer and you can do whatever you want on it.

Please note that this method can be considered an advanced option for creating backups. For example, we can consider that we are not creating a backup copy of data, but applications that are already configured and ready for use.

Reducing the disk space of a virtual machine in VMDK format (VMWare)

As a rule, a constantly used computer has more programs installed than is necessary for storage in a virtual machine. Well, really, why do you need Gimp, ICQ, Skype, ImageViewer or a media player as well as “My Documents” and “My Music”? Down with everything unnecessary. The disk of the virtual machine will most likely be at least 10 GB, and then there will be rubbish.

Well, you launched the virtual machine, removed unnecessary programs, but the vdisk.vmdk file (for example) did not reduce its size. It's good if you didn't increase it. You deleted 3 GB of junk, but the size did not become smaller?

The disk file is created in VMware format. VMware, together with the VMware Server and VMware Workstation products, supplies a console utility for working with virtual disks vmware-vdiskmanager. This utility is a powerful virtual disk conversion tool. You can find the vdiskmanager utility in the folder where VMware Server or VMware Workstation products are installed. Those. just install the trial version of WMware Workstation and find the file in its folder vmware-vdiskmanager.

Using this utility in our case is simple: vmware-vdiskmanager.exe -k<путь до вашего файла vdisk.vmdk> .

In my case, this allowed me to reduce the size from 22 GB to 14 GB!

If you don’t want to install VMware, you can try downloading the archive with this utility from here (856 kb, MD5: CF48CF9B69EA712E7B7B8C94EFA7AB49). The archive contains the utility itself and two libraries necessary for its operation. At least with the "-k" switch. I hope that this will be enough and that you will not need to install the full VMware distribution.

Using VM Groups

VM groups allow the user to create special groups of virtual machines for collective management.

Create a group using the GUI

1) Drag one virtual machine on top of another virtual machine.

2) Select multiple virtual machines and select " Group» in the right-click menu as shown below:

You can create nested groups.

Group operations allow you to perform common actions for virtual machines for all members of the group at once.

Pictures

With snapshots, you can save a specific state of a virtual machine for later use. At any subsequent time you can return to this state, even though you may have changed the VM significantly since then. So a snapshot of a virtual machine is similar to a machine in a "saved" state as described above, but there can be many of them, and these saved states are stored permanently.

You can see snapshots of a virtual machine by first selecting the machine in VirtualBox Manager and then clicking the " Pictures" in the upper right corner. Until you take a picture of the car, the list of pictures will be empty, except for the item " Current state", which represents the point " Now"in the life of a virtual machine.

Creating, restoring and deleting snapshots

There are three operations associated with snapshots:

  1. You can to take a photo. This makes a copy of the current state of the machine, which you can later return to at any time.
  • If your virtual machine is currently running, select " Take a snapshot of the state..." in the drop-down menu " Car» VM windows.
  • If your virtual machine is currently in the " saved" or " off" (as shown next to the virtual machine in the main VirtualBox window), click the " Pictures" in the upper right corner of the main window, and then
    • or on the small camera icon (for “ To take a photo"), or
    • right click on the element " Current state" in the list and select " To take a photo».

In any case, a window will appear asking for the name of the image. This name is for reference purposes only to help you remember the snapshot status. For example, a useful name would be " Fresh installation from scratch, without guest additions th" or " Service pack only 3". You can also add longer text in the " Description", if you want to.

Your new snapshot will then appear in the list of snapshots. Below the new photo you will see an item called " Current state", meaning that the current state of your virtual machine is a variant based on the snapshot you used previously. If you later take another photo, you'll see that they will appear sequentially, with each subsequent photo derived from the earlier one:

VirtualBox doesn't place any restrictions on the number of pictures you can take. The only practical limitation is the disk space on your host: each snapshot saves the state of the virtual machine and thus takes up some disk space.

  1. You can restore snapshot by right-clicking on any photo you took in the list of photos. Restoring a snapshot is like going back to the moment it was taken: the current state of the car is lost, and the car is returned to the exact state the car was in when the snapshot was taken.

Note Note: Restoring a snapshot will affect the virtual hard disks attached to your virtual machine. This also means that all files created since the snapshot was taken and all other changes to files will be lost. To prevent data loss when using the Snapshot feature, you can add a second hard drive in " write-through» using the VBoxManage interface and use it to store your data. Because writable hard drives are not included in snapshots, they remain unchanged when the machine is returned.

To avoid losing the current state when you restore a snapshot, you can create a new snapshot before restoring.

By restoring an earlier snapshot and taking more snapshots, you can create a sort of alternate reality and switch between these different histories of the virtual machine. This may result in a tree of virtual machine snapshots as shown in the screenshot above.

  1. You can also delete the snapshot, which will not affect the state of the virtual machine, but only release the disk files that VirtualBox used to store the snapshot data, thereby freeing up disk space. To delete a snapshot, right-click it in the snapshot tree and select " Delete" Since VirtualBox 3.2, snapshots can be deleted even while the machine is running.

Note Note: While creating and restoring snapshots are fairly fast operations, deleting a snapshot can take a significant amount of time because it may require copying a large amount of data between multiple disk image files. Temporary disk files may also require a large amount of disk space while the operation is running.

There are some situations that cannot be processed while the virtual machine is running, and you will receive a corresponding message that you should delete this snapshot while the virtual machine is turned off.

Think of a snapshot as time that you have saved. More formally, a photograph consists of three things:

  1. It contains a complete copy of the virtual machine settings, including hardware configuration, so that when the snapshot is restored, the VM settings are also restored. (For example, if you change the hard drive configuration or system settings of the virtual machine, that change is discarded when the snapshot is restored.)
  2. A copy of the settings is saved in the device configuration, an XML text file and therefore takes up very little space.
  3. The full state of all virtual disks attached to the machine is saved. Returning to a snapshot means that all changes made to the computer's disks - file by file, bit by bit - will also be undone. Files created since creation will disappear, files that have been deleted will be restored, changes to files will be undone.

(Strictly speaking, this is only true for virtual hard disks in "normal" mode. As mentioned above, you can configure the disks to behave differently with snapshots. Even more formally and technically correct, restoring a snapshot does not restore the virtual disk itself Instead, when a snapshot is taken, VirtualBox creates diff images that contain only the changes since the snapshot was taken, and when the snapshot is restored, VirtualBox discards that diff image, thus reverting to the previous state. This is faster and uses less disk space.

Creating a differential image as such initially does not take up much space on the host's disk, since the differential image will initially be empty (and later grow dynamically with each disk write operation). However, the longer you use the machine after taking a picture, the more the size of the different image will increase.

Finally, if you took a snapshot while the machine was running, the device's memory state is also saved in the snapshot (just as memory can be saved when closing a VM window). When you restore such a snapshot, execution resumes at the exact moment the snapshot was taken.

The memory state file can be as large as the virtual machine's memory and therefore take up quite a lot of disk space.

Removing virtual machines

To delete a virtual machine that you no longer need, right-click it in the VM Manager list, select " Delete».

A confirmation window appears allowing you to choose whether to remove the machine from the list of machines only, or whether to also delete the files associated with it.

Menu item " Delete

Cloning virtual machines

To experiment with a virtual machine's configuration, test different levels of a guest OS, or simply create a backup of a virtual machine, VirtualBox can create a full or linked copy of an existing virtual machine.

The wizard will guide you through the cloning process:

This wizard can be called from the VM Manager list context menu (select " Clone") for the selected virtual machine. First, choose a new name for the clone. You can select the option to generate MAC addresses of all network cards, then each network card in the clone will receive a new MAC address. This is useful when both the source VM and the cloned virtual machine need to run on the same network. If you leave this unchanged, all NICs will have the same MAC address as the one in the source VM. Depending on how you invoke the wizard, you have different options for the cloning operation. First you need to decide whether the clone should be linked to the original VM or a completely independent clone:

Full cloning: In this mode, all disk image dependencies are copied to a new VM folder. The clone can run completely without the original virtual machine.

Linked cloning: This mode creates new distinctive disk images where the parent disk images are images of the source disk. If you selected the current state of the source VM as the cloning point, a new snapshot will be created implicitly.

After selecting the cloning mode, you need to decide what exactly you want to clone. You can always create a clone of just the current state or everything. When you select all, the current state and in addition all snapshots are cloned. If you started with a snapshot with additional children, you can also clone the current state and all children. This creates a clone starting from this snapshot and including all child snapshots.

The cloning operation itself can be lengthy depending on the size and number of disk images attached. Also keep in mind that each snapshot has different disk images that need to be cloned as well.

Menu item " Clone» switches off while the machine is running.

Import and export of virtual machines

VirtualBox can import and export virtual machines in the standard Open Virtualization Format (OVF).

OVF is a cross-platform standard supported by many virtualization products that allows you to create ready-made virtual machines that can then be imported into a virtualizer such as VirtualBox. Importing and exporting into VirtualBox in OVF format is very simple and is done from the Manager window, as well as the command line interface. This allows you to package so-called virtual devices: disk images along with configuration settings that can be easily deployed. This way you can offer complete, ready-to-use software packages (operating systems with applications) that require no configuration or installation other than importing into VirtualBox.

Note: The OVF standard is complex and its support in VirtualBox is an ongoing process. In particular, VirtualBox is not guaranteed to support all devices created by other virtualization software.

Devices in OVF format can be displayed in two options:

  1. They may be supplied in multiple files as one or more disk images, usually in the widely used VMDK format and an XML text file with the extension .ovf. To be able to import them, the files must be in the same directory.
  2. Alternatively, the above files may be packaged together into a single archive file, typically with the extension .ova. (Such archive files use a variant of the TAR archive format and therefore can be unpacked outside of VirtualBox with any utility that can unpack standard TAR files.)

To import device into one of the above formats, simply double-click the OVF/OVA file. Or select " File» → « Importing configurations" in the Manager window. In the file dialog box that appears, navigate to the file with the extension .ovf or .ova.

If VirtualBox can process this file, a dialog box similar to the following will appear:

It represents the virtual machines described in the OVF file and allows you to change the virtual machine's settings by double-clicking the description elements. Once you click " Import", VirtualBox will copy the disk images and create local virtual machines with the settings described in the dialog box. They will then appear in the Manager's list of virtual machines.

Please note: Because disk images tend to be large, and the VMDK images that come with virtual appliances are typically sent in a special compressed format that is not suitable for direct use by virtual machines, the images will first need to be uncompressed and copied, which may take several minutes .

And vice versa, for export virtual machines that you already have in VirtualBox, select " File» → « Export configurations" Another dialog box will appear that allows you to combine multiple virtual machines into an OVF device. Then select the location where the target files should be saved and the conversion process will begin. It can take some time.

Note: OVF cannot describe the snapshots that were taken for the virtual machine. As a result, when exporting a virtual machine with snapshots, only the current state of the machine will be exported, and the disk images in the export will have a “flattened” state identical to the current state of the virtual machine.

Global Settings

The global settings dialog can be found in the menu " File", selecting the item " Settings….» It offers a set of settings that apply to all virtual machines of the current user or, in the case of extensions, to the entire system:

  • Are common. Allows the user to specify the default folder/directory for VM files and the VRDP authentication library.
  • Enter. Allows the user to specify a Host key. It is used to switch the cursor out of focus of the virtual machine or host operating system windows, and is also used to trigger certain virtual machine actions.
  • Updates. Allows the user to specify various automatic update options.
  • Language. Allows the user to specify the language of the graphical user interface.
  • Display. Allows the user to specify the screen resolution, as well as its width and height.
  • Net. Allows the user to configure network information for the host only.
  • Plugins. Allows the user to view and manage installed extension packs.
  • Proxy. Allows the user to configure an HTTP proxy server.