How to recover data from Linux KVM virtual machines? If some important data is stored inside the machine, but it is beyond repair, how can you access the contents of its virtual hard disk? What should you do if the virtual hard disk is damaged? And what if you don’t have access to Linux and KVM hypervisor? In this article, we’ll try to explore all such things.
- Why Linux KVM virtual machine fails
- How to restore access to your Linux KVM virtual machine data
- How to recover data from Linux KVM virtual machine if its disk is damaged or inaccessible in KVM
- How to recover data from QCOW and QCOW2 with RS Partition Recovery
Why Linux KVM virtual machine fails
The main causes for a Linux KVM virtual machine to break down:
- Deleted Linux KVM files;
- Damaged Linux KVM files after a failed attempt to copy or move them;
- Linux KVM virtual machine breakdown after a power failure, while trying to make a snapshot, or when updating the hypervisor etc.;
- No access to Linux KVM virtual machine because the host system has been reinstalled.
You can try to fix your Linux KVM virtual machine and restore access to your data. For this purpose, you should re-create the virtual machine on the basis of the already existing virtual hard disk.
If re-creating the virtual machine doesn’t solve the problem, all you can do is to save the virtual machine data. The valuable information inside the Linux KVM virtual machine can be lost beyond retrieval.
How to restore access to your Linux KVM virtual machine data
To get access to the data stored in QCOW and QCOW2 – the two formats of Linux KVM virtual hard disks. It is necessary to connect the virtual hard disk of the damaged machine to another machine.
Accordingly, the solution is this: we access the data with the help of the guest operating system installed on another Linux KVM virtual machine.
Image files of Linux KVM virtual machine are located here:
How to recover data from Linux KVM virtual machine if its disk is damaged or inaccessible in KVM
But what if the data is deleted because of a virtual machine failure? Or if the disk containing Linux KVM is damaged? This is a challenging task that can only be handled by data recovery tools with special features
Such tools should:
- Support virtual hard disks in general, and the formats used in Linux KVM, in particular: QCOW and QCOW2;
- Provide access to the contents of virtual hard disks, even if they are damaged;
- Recover deleted files on a virtual machine. That is, recover deleted data in case when such data gets removed as a result of a virtual machine failure;
- Use effective data recovery algorithms.
Such tool is launched in the host system, mounts the virtual hard disk and provides access to the data stored inside it, including deleted files.
One of the few products meeting the abovesaid requirements is RS Partition Recovery. This tool supports virtual disk formats used by all known hypervisors operated in Linux KVM, including its native formats, QCOW and QCOW2.
RS Partition Recovery is a Windows utility, and it can come in handy when you need to recover Linux KVM data in the Windows environment. That is, if you have no access to Linux to run a KVM hypervisor which only works in Linux, or if there are problems with running KKVM in the Linux environment.
Note: in Linux RS Partition Recovery environment, you can try running it from Wine. This tool works well with Wine, but like many Windows-compatible software products, it may not work properly every time. In a perfect world, it is better to use RS Partition Recovery in Windows.
To recover data from a virtual machine with RS Partition Recovery, you need to move QCOW and QCOW2 files of a Linux KVM virtual machine to the disk partition with a file system recognized by Windows – NTFS, FAT32 or ExFAT. Linux allows you to create partitions with such file systems.
Create a partition in Linux – for example, with ExFAT – and follow the path where KVM virtual machine files are located:
And copy the machine files to the partition with a file system recognized by Windows.
You can also get access to Linux KVM virtual machine files with the help of RS Partition Recovery.
Install and run RS Partition Recovery.
Close the data recovery wizard which starts by default. Go to the drive manager window. Choose the Linux partition with Ext4 file system where Linux KVM virtual machine files are stored.
Run a quick scan.
When the scan is over, go to the folder containing virtual machine files.
Select an item and click Recovery (or choose this option from the context menu).
Save it to the disk with the file system recognized by Windows – NTFS, FAT32 or ExFAT.
How to recover data from QCOW and QCOW2 with RS Partition Recovery
In the Tools menu, select Mount Disk.
Select virtual hard disk formats. If the Linux KVM worked from the disk in its native format, QCOW or QCOW2, then select these formats, i.e., Linux KVM.
Give the path to the folder containing virtual machine files, where the virtual hard disk is stored.
Now, specify the actual virtual disk from where the data should be recovered.
If the virtual hard disk contains any snapshots, they will be displayed as well.
The added image will be shown in the program’s window, in the Mounted Disks section.
Click on the partitions where data needs to be recovered.
You’ll be offered two methods to search for data – Fast scan and Full analysis. The first option is quick. The second one is slower but it allows to recover more data.
When the scan is over, click Finish.
Now you can access the data stored on the Linux KVM virtual machine disk.
The program will display both existing data and deleted files (marked with a cross). Click on the files and folders to select them for recovery. Click the Recovery button.
Choose one of the options and save the data.