How to make a backup of the entire disk. Features and rules for completely cloning hard drive data from HDD to SSD. An easy way to clone a hard drive or SSD using Acronis True Image

Preventive computer maintenance takes a lot of time. Either you need to configure the operation of applications, or remove useless “garbage” in temporary folders, or restore the normal operation of lost drivers. And even the most careful user, who is used to constantly maintaining order in the system, periodically has to be distracted by such actions. There is no escape from this, so the only way to somehow deal with this problem is to approach it wisely. For example, take a “snapshot” of the most important files - save a backup copy of the data.

An interesting personal observation: many users are very conservative in their preferences. From year to year, they use approximately the same set of software, select the same system configuration parameters, and even almost never change the color scheme of the interface of their work applications. For such people, there is a simple and effective solution to the problem of information loss and system failure - restoration using a backup copy of the system partition. This method is familiar to any more or less experienced user. In this case, reinstalling the system with all its settings is reduced to a single operation of copying the file with the partition image.

The tools with which you can perform the operation of data cloning and recovery are not very diverse. Almost the sole leader in this area is the Acronis True Image software package. It is this tool that is most often mentioned when discussing the problem of taking an image of an entire disk. There is also a Symantec Ghost Solution Suite. Among Russian-speaking users, this program is not as popular as the Acronis product, but it can be used with the same success for system migration and deployment. Both of these products are certainly very convenient and have a lot of advantages, but they are not free. And the full range of capabilities of these applications will be unnecessary for many. Let's try to figure out which free programs for taking images of disk partitions can replace these popular tools.

⇡ Testing boot images using a virtual machine

Bootable media images can be tested directly from Windows using a virtual machine such as VirtualBox. In this program, you just need to create a new virtual PC configuration and specify the disk image as the boot source.

It is very convenient to store such images on multiboot media. In addition to tools for removing and restoring images from disk partitions, such a boot disk may also contain a number of additional options - a Windows installer, a couple of Linux distributions, and so on. If you decide to burn such a bootable USB flash drive, you can also test it in VirtualBox. However, the Oracle Corporation product does not support booting from removable media, so you will have to perform a number of steps to force VirtualBox to boot from a flash drive.

To do this, you need to open the standard disk management utility diskmgmt.msc. Based on the contents of the window of this utility, determine by what number the USB drive being written is identified in the system. Then run command line mode (cmd.exe) with administrator rights and go to the VirtualBox folder using the command cd %programfiles%\oracle\virtualbox. At the command line, type VBoxManage internalcommands createrawvmdk -filename "%USERPROFILE%"\.VirtualBox\usb.vmdk -rawdisk \\.\PhysicalDrive#, replacing the # symbol with the previously memorized disk number. Now you can create a new virtual machine. At the stage of setting up the disk to be used, select an external disk (use existing hard disk) and specify the location of the usb.vmdk file. Go!

Redo Backup

The main advantage of Redo Backup is that the program is as simple as possible, lacks numerous options and works reliably. The shell launches almost instantly, after which the most simplified Linux environment (Ubuntu 12.04 LTS) and a utility window for creating a backup copy of partitions appear on the screen.

In addition to the main tool for cloning disks, the distribution includes a small set of essential utilities. In the Redo Backup boot image shell you will find a fast file manager PCManFM, a simple text editor Leafpad, an image viewer GPicView, a Chromium browser and a utility for launching a terminal. Among the tools for working with disks, there is a small but useful program for resetting all media parameters to their original state. True, you can use it only at your own peril and risk - the data is deleted, and no one gives a guarantee that the hard drive or any other storage device will function properly. Using the Gparted partition editor, you can partition your disks and configure them in the Disk Utilities media manager.

The application with the funny name baobab will show a diagram of disk fullness. The distribution also includes the PhotoRec utility, the main purpose of which is to recover deleted files.

The created images of the specified partitions can be saved to one of the available partitions of the local machine or written to a folder on a remote PC that can be accessed over the network. Data can also be uploaded to an FTP server.

The boot image of this utility is so small that it will fit even on a good old CD. Of course, today this medium is hopelessly outdated and is living its last days. On the other hand, if you still have a laser drive and a stack of unused CD-R discs, then why not get rid of one of the extra “blanks” and make yourself a copy of the saving tool?

AOMEI Backupper

In addition to a bootable disk image (AOMEI Backupper Linux Bootable Disk Image) with a proprietary utility, the developers of AOMEI Tech offer users several products for running the application from Windows - two free editions of the program and one paid one.

It must be said that the developer caused some confusion by releasing two free versions, because the differences between them are not immediately clear. One is called AOMEI Backupper Standard, the other is AOMEI Backupper Standard Win7. The size of the first one is several times larger, but there are few real differences. Don't be fooled by the words For Win7 - both versions work great on Windows 7. The one that For Win7 does not work on outdated versions of the operating system from Microsoft - Windows Vista and Windows XP, while AOMEI Backupper Standard officially supports them . In addition, AOMEI Backupper Standard For Win7 does not have the option to create bootable media.

In our opinion, the paid edition of the AOMEI Backupper Professional program has nothing special to attract the attention of the average user. Its main advantage is the ability to combine partition images with support for incremental data copying (that is, copying only changed files, which greatly speeds up the process). In addition, the advanced version supports running the backup process using the command line and allows full use of the PXE Boot Tool (a network boot application) with an unlimited number of clients on the local network.

According to the developers, the free versions copy slower than the Pro version. This may be true, but if you compare the speed of creating a partition image using boot images of Redo Backup and AOMEI Backupper, the difference is unnoticeable: the process takes approximately the same time in both cases.

But compared to Redo Backup, the AOMEI Backupper utility offers many more options. Here you can copy in several ways: clone a partition, transfer content from disk to disk, make a backup copy of the system disk, individual directories or certain files. To save space in AOMEI Backupper, you can enable the maximum compression mode, but if you need to speed up the process of recording a backup copy, you can completely disable file compression in the settings. In addition to this, you can also set up a task scheduler that will record a backup copy of your data at a specified time.

There are many ways to burn a boot image to a USB flash drive. For example, you can use the Sardu utility, which will do this automatically, and even help you make multiboot media with a rich arsenal of Linux distributions. But it’s best to write everything to a flash drive directly in the AOMEI Backupper program itself, in this case you will receive a guaranteed working bootable media with the current version of the AOMEI Backupper engine. The boot image can be compiled against Linux or Windows PE.

It is preferable to use the second option, since if you create bootable media on Linux, only the basic functions of the program will be active in the AOMEI Backupper shell. The desktop application AOMEI Backupper Standard has even more options - for example, it is possible to automatically split the image into files of a specified size, there is an option for intelligent data reading (in this case, the contents of only those sectors that are used by the file system are copied), you can control file compression, and so on .

Clonezilla

Clonezilla is a completely free and open source software developed by Taiwanese programmer Stephen Shiau.

This program is aimed at experienced users rather than beginners. It is designed on the principle of a step-by-step wizard and works almost in text mode, without an interface as such.

The situation is saved a little by the fact that Clonezilla supports the Russian language and many operations, as well as comments to them, are correctly translated. The choice of language occurs at the very beginning of the data backup wizard launch.

The program is universal - it supports all popular file systems, including ext2, ext3, ext4, reiserfs, xfs, jfs (GNU/Linux), FAT, NTFS7, HFS+ (Mac OS).

To create a bootable USB drive, you will need to follow several steps. To get started, download the boot image in ZIP format from the official Clonezilla website. Note that the type of Live image loaded depends on the architecture used. It is also worth paying attention to whether the Secure Boot feature is enabled on your computer. It is one of the UEFI options and is designed to protect the computer from malicious code that modifies the MBR boot sector. When you enable the secure boot option (uEFI secure boot enabled), you need to download a separate boot image built on Ubuntu - links to it are also available on the download page of the official Clonezilla website.

After downloading the required file, unpack the contents of the ZIP archive onto a USB drive. Run the makeboot.bat file directly from the flash drive, which is located in the utils\win32 directory (or makeboot64.bat at drive:\utils\win64).

A backup copy of data can be recorded “as is,” that is, in the form of files and folders, or it can be saved in a single image file. Of course, the image file can be used to restore information on the media. The backup copy can be saved to a local disk, written to a SAMBA network environment server, an SSH server, or using the NFS protocol. Clonezilla supports AES-256 encryption. The program is completely undemanding to PC system resources and can run on the oldest “toasters”.

The program does not support differential and incremental copying of files, and a prerequisite for the normal completion of the process of writing a backup copy of a disk is that the volume of the media on which the recording is being made must be no less than the volume of the disk (partition) from which the data is read.

Along with the regular version of the Clonezilla boot disk, users are offered the Clonezilla Server Edition. This application is a tool for running simultaneous cloning on an entire array of computers (more than forty PCs).

Paragon Backup & Recovery 14 Free Edition

Paragon's products are well known to many, but for some reason not everyone knows that among the programs of this developer there is also free software, for example, a version of the Paragon Backup & Recovery 14 Free Edition application for creating a backup copy of data.

The only condition that Paragon sets for users is that they use Backup & Recovery 14 Free Edition only for non-commercial purposes (for personal use). And although the company has been selling a newer edition of this program for a long time, the fourteenth version still remains relevant. It even officially supports Windows 8, which is reflected in the interface of Backup & Recovery 14. The tiled Express interface that appears when you first launch it can be disabled, then the application will take a more familiar look.

The set of free tools for working with disks that Paragon's program offers is small. Most options are unavailable, and the developer himself suggests upgrading to activate all the features of the utility.

However, the functions that exist are quite enough to solve the main problem - creating a backup copy. In addition, the user has tools for managing disk partitions. With their help, you can create, format, delete partitions, hide or open them, assign a letter and change the volume label, and check the integrity of the file system.

In the program menu you will find the Recovery Media Builder wizard. This wizard is designed to burn a boot disk image to ISO format or prepare a bootable USB flash drive. When creating bootable media for data recovery, you can choose settings that are convenient for you - specify BIOS or EFI, select an environment (Linux or Windows PE), use WIM images of the current operating system for recovery, and so on. If you burn a boot disk in expert mode, you can manually add drivers for storage devices and network devices to the media, as well as specify specific network parameters.

The engine for creating a backup copy of disk partitions provides the ability to carry out a copy operation in one of two ways: the standard method, creating images of cloned partitions, or placing all the backup data on the Paragon virtual disk (for example, this way you can collect several images in one place at once). The backup copy can be written to a mounted partition or to an unmounted partition that has not been assigned a letter.

The program pays special attention to data security. One of the options of Paragon Backup & Recovery 14 Free Edition is that data can be backed up into a so-called capsule, that is, into a hidden partition that cannot be mounted and seen in the operating system.

We would like to draw your attention to one more very important point. While testing the bootable media recording option, we discovered an error in the program. Recording an image with the Microsoft Windows PE environment from the “classic” interface of Paragon Backup & Recovery 14 Free Edition may be accompanied by a failure and a message stating that there is no access to the partition.

The solution to the problem was found on the official Paragon support forum - recording media must be started from the Express interface, then the error will not appear.

Paragon Backup & Recovery 14 works well with all types of hard drives. The contents of a hard disk image with a cluster size of 512 bytes are restored to another media with a cluster size of 4 kilobytes without additional user action.

DriveImage XML

If you've ever lost data as a result of erroneous formatting or some kind of file system glitch, Runtime Software should be a familiar name. The GetDataBack utility made by this developer has been helping to rescue data and recover information from problematic media for many years. In addition to GetDataBack and other great utilities, Runtime Software includes DriveImage XML, a free tool for creating disk backups.

The program can be installed as a standalone application, or can be launched using a boot image based on the Linux distribution Knoppix 7. Of all the boot images discussed in this review, the Runtime Software disk can be considered the “most life-saving”. In addition to DriveImage XML Private Edition (free version for home use only), Knoppix contains the entire range of programs from Runtime Software for data recovery and working with disks: GetDataBack NTFS, GetDataBack FAT, GetDataBack Simle, RAID Reconstructor, RAID recovery for Windows, DiskExplorer for FAT , DiskExplorer for Linux, Captain Nemo Pro and so on. Please note that commercial utilities require registration.

Knoppix is ​​a universal assembly, it has a browser, a video player, and a text editor. For completeness, the only thing missing is the free office suite, which was apparently excluded from the build to save storage space.

Windows versions are launched on the system using Wine (software for an alternative implementation of WindowsAPI).

Using the Microsoft Volume Shadow Service (VSS), the program can take a disk image, including system and locked data that is currently being worked on. The procedure for creating a backup copy in DriveImage XML will result in the following output: two files. The first, written in *.XML format, will contain a description of the disk. The program will save the second file as *.DAT - it stores the binary data of the captured image. Program options that are tied to standard Windows services may not work, so developers recommend that you independently burn bootable disks with the Windows PE environment or an alternative BartPE environment.For the second option, plugins are posted on the official Runtime Software website that simplify the connection of the main utilities of this developer.

⇡ Conclusion

Programs for creating copies of disks can be used not only for quickly reinstalling the system. They can also successfully serve as regular means for backing up important data. Take photographs, for example. Paper photo albums are practically a thing of the past, and with them the persistent tradition of taking them out of the closet and showing guests family history in photographs has sunk into oblivion. It's scary to think how many children today will be deprived of pleasant memories when they grow up. The phrase “I don’t have children’s photos because my parents’ hard drive on their computer once crashed” has every chance of becoming very popular in the next few years. Don't want this to happen in your family? All you need to do is take care of a backup. It's very simple and, as you can see, free.

Few Windows 7 users know about such a very useful function as creating a backup copy of the installed operating system. Let's look at what it is and how to make a backup copy of Windows 7 here and now.

What is this function?

This is which, using archiving tools, can create a backup copy of user information and the OS as a whole. There are a lot of benefits from it, since with its help you can make an OS image, thanks to which you can then restore a damaged operating system. This will become a real lifeline in the event that it is not created, and a rollback is impossible. Of course, it is also advisable to make a restore point in case the operating system is damaged, but there are different situations in which a good old rollback will not help. For example, when the system does not start, and the disk on which Windows 7 is recorded is not at hand.

Why not a rollback?

Unlike a rollback (restore function in a different way), which simply returns the system to a previously saved state, a backup saves user settings and the image of Windows 7 as a whole. The benefits of this are enormous. For example, you get the opportunity to restore all user data that was erased during the reinstallation process.

And if the operating system fails, it can always be returned to normal using a backup copy; in addition, drivers, programs and personal data (saves and profiles in games, etc.) will also be restored.

How to backup Windows 7?

Creating a copy of the OS is carried out by a fairly large number of utilities. In addition, Windows 7 has sufficient functionality for this. Before you create a backup of Windows 7, you need to do the following steps.

We go to the “Start” menu, where in “All Programs” we look for the “Maintenance” folder. In it we find and click on the item “Backup and Restore”. There are also a couple of alternative ways to open this function:

  • open “Start”, enter “Backup and Restore” in the search line and go when it appears;
  • We go to the control panel, where the “Backup and Restore” section immediately catches your eye.

It doesn’t matter which opening method is chosen, the main thing is that the window with this service is open. There you can use three functions:

  • configure backup;
  • create an OS image;
  • create a disk designed to return the system to normal.

Let's start with how to create a backup copy of Windows 7, then we'll look at the other two functions.

Backup

To do this, in the “Backup and Restore” window, click on the “Set up backup” hyperlink highlighted in blue. The archiving settings window appears. At this stage you will have to wait a little. Patience will be rewarded by the appearance of a window called “Archiving Settings”, where you will be offered a choice of where to save the copy. Of course, a reserve can be created on drive D, for example. But if all the data on the hard drive is deleted or damaged, then the backup copy will be of no use. Therefore, it is best to store the backup on an external hard drive. In addition, if you connect an external hard drive, the system will offer nothing more than to backup the Windows 7 system to it. When the choice is made, move on using the "Next" button.

In the next window you need to choose whether to leave the selection of files for Windows archiving or choose what data will be archived (individual files, folders, disks). By the way, this feature can help you on how to backup Windows 7 drivers.

If there is no trust in the operating system, and the decision was made to distribute the data manually, in the window that appears, you must click “Include disk system image: (C)” so that you can restore the faulty system using a backup, and also check the boxes for the necessary data. As usual, click on “Next”. Before making a backup copy of Windows 7, we check that all settings are correct. After that - “Save and run”.

Creating an OS image

This time we click on “Create an image” instead of such a fad as making a backup copy of the Windows 7 disk. In this case, an image is created that includes the disks necessary for normal operation of the OS. We are in the window for choosing where to save the future image. It is best to prefer a portable (that is, external) hard drive, since the image can weigh several tens or even hundreds of gigabytes. Next, you select the disks from which the image will be created. In the next window, we check again the disks that will be in the image, and then click “Archive”.

Creating a recovery disk

This is done in the same place, instead of such an item as making a backup copy of Windows 7, only it is located next to the image creation button. True, this step is not necessary for those who have Windows 7 on disk and who can use it to return the system to normal. For those who do not have such a disk, it is useful to go through this procedure, since in case of serious damage to the OS there will be something to restore it from.

To do this, you will need a blank DVD or CD, since the recovery files will weigh approximately 150 MB. In the “Backup and Restore” window, click the “Create system disk” option. Insert the disc into the drive, select it from the list and click on the “Create disc” button. We wait until the disk creation process comes to an end, after which we remove the disk.

Now this disk can be used if the operating system dies for a long time, and it will be impossible to enter it even from safe mode.

Good day.

Very often, many instructions, before updating drivers or installing any application, recommend making a backup copy to restore the functionality of your computer or Windows. I must admit that I often give the same recommendations...

In general, Windows has a built-in recovery function (if you haven’t disabled it, of course), but I wouldn’t call it super-reliable and convenient. In addition, it should be noted that such a backup will not help in all cases, plus add to this that it restores data loss.

In this article, I would like to talk about one of the methods that will help you make a reliable backup copy of the entire hard drive partition with all documents, drivers, files, Windows OS, etc.

So, let's begin…

1) What do we need?

1. Flash drive or CD/DVD

Why is this? Imagine, some error occurred and Windows no longer boots - a black screen just appears and that’s it (by the way, this can also happen after a “harmless” sudden power outage)…

To run the recovery program, we need a pre-created emergency flash drive (or a disk, just a flash drive is more convenient) with a copy of the program. By the way, any flash drive will do, even an old one with 1-2 GB.

2. Backup and recovery software

In general, there are quite a lot of programs of this type. Personally, I suggest going with Acronis True Image...

Acronis True Image

Key benefits (in terms of backups):

  • - quick creation of a backup copy of the hard drive (for example, on my PC, the system partition of the hard drive with Windows 8 OS with all programs and documents takes up 30 GB - the program made a complete copy of this “good” in just half an hour);
  • - simplicity and ease of use (full support for the Russian language + intuitive interface, even a novice user can handle it);
  • - easy creation of a bootable USB flash drive or disk;
  • - the backup copy of the hard drive is compressed by default (for example, my copy of a 30 GB HDD partition was compressed to 17 GB, i.e. almost 2 times).

The only drawback is that the program is paid, although not expensive (however, there is a test period).

2) Create a backup copy of your hard drive partition

After installing and launching the Acronis True Image program, you should see something like this window (a lot depends on the version of the program you will use; in my screenshots, the program is from 2014).

Immediately on the first screen you can select the backup function. Let's launch... (see screenshot below).

The disks on which we will make backup copies (here you choose yourself, I recommend choosing the system disk + the disk that the Windows system backed up, see the screenshot below).

Specify the location on another hard drive where the backup will be stored. It is advisable to save the backup copy to a separate hard drive, for example, to an external one (nowadays they are very popular and affordable).

The copy creation process will begin. The creation time varies greatly depending on the size of the hard drive you are making a copy of. For example, my 30 GB disk was completely saved in 30 minutes (even a little less, 26-27 minutes).

While creating a backup copy, it is better not to load your computer with extraneous tasks: games, movies, etc.

Here, by the way, is a screenshot of “my computer”.

And in the screenshot below is a 17 GB backup.

By regularly making a backup copy (after a lot of work has been done, before installing important updates, drivers, etc.), you can be more or less calm about the safety of information, and indeed, the performance of your PC.

3) Create a backup flash drive to run the recovery program

When the disk backup is ready, you must create another emergency flash drive or disk (in case Windows refuses to boot; and in general, it is better to restore by booting from a flash drive).

And so, let’s start by going to the backup and restore section and clicking the “ create bootable media«.

Then we will be asked to indicate the medium where the information will be recorded. Select a flash drive or disk.

Attention! All information on the flash drive will be deleted during this operation. Don't forget to copy all important files from the flash drive.

That's all. If everything went without errors, after 5 minutes (approximately) a message will appear stating that the bootable media was successfully created...

4) Restore from backup

When you want to restore all data from a backup, you need to configure the BIOS to boot from a flash drive, insert the flash drive into the USB and restart the computer.

Since I heard the good news about the existence of an operating system called GNU/Linux, which all real programmers use, I have tried several times to replace Bill Gates' brainchild with it and failed several times.

There were no gurus nearby, access to the Internet was severely limited, and therefore any non-trivial task became completely unsolvable in those days.

Then, when unlimited Internet appeared, as a result of which it became much easier to obtain software and knowledge, I set up a dual boot for myself and began to master Ubuntu.

The main difficulties in the moving process were created primarily due to the need to abandon programs familiar almost from childhood, which are simply not available in the operating system for real programmers.

In most cases it was not fatal. Instead of the usual foobar, you can always listen to music on Rhythmbox. Instead of Microsoft Office there is OpenOffice. Yes, its compatibility with the product of an evil corporation sometimes leaves much to be desired, but it can be used to solve the everyday problems of the average user. I’m generally silent about all sorts of Firefox, Opera and Chrome.

But in some cases I had to restart the computer, select Microsoft Windows from the bootloader menu and do everything the old fashioned way. Such a task was, for example, taking an image of a logical disk in order to transfer it to another physical medium, because the current one was already pretty worn out.

The program that was used in such situations was Acronis. My intuition suggested that figuring out how to do without it would take at least a week, and the result was usually needed within half an hour, so figuring out how to do without it would take at least a week.

But after another friendly joke about Linux being useless and incapable of anything, and therefore free, I decided that next time I wouldn’t need anything more than a bootable flash drive and a command line to create a disk image. And I went to Google.

Google created the clear impression that every dog ​​knows how to clone disks using open source OSes. Alas, clear instructions for implementing well-known and elementary things are usually the most difficult to find. As a result of persistent searches, some manuals were eventually discovered, but it was still a little difficult to work with them, because they were clearly written by literate people who have been fiddling with the topic for more than one or even two days, and simply do not remember that the knowledge they revered for the required minimum, not everyone owns it.

Now that the horrors of googling are behind me, I understand that everything is really quite simple and I want to present the results of my research in the form of a short guide to working with disk images in GNU/Linux, addressed primarily to those who are accustomed to Acronis or something similar to it program. At one time, such a document would have helped me a lot, and I hope that it will help someone else.

Acronis

In Acronis, everything was simple and clear: the window interface, prompts and previous experience working with CD images made the process uncomplicated. I removed the image, inserted a new screw, turned the image onto it - there’s not even anything to talk about. In the case of Linux, the process bogged down at the stage of removing the image - it was absolutely unclear how to do this. There was no special program with hints, or a program that added a virtual DVD to the list of devices - like Daemon Tools too. And the list of devices itself turned out to be quite problematic, so you can start right there.

Viewing a list of drives

For each connected drive (hard drive, flash drive), you can find the corresponding file in the /dev directory. Its name consists of letters SD and a letter indicating the device number. That is, the hard drive connected to the first channel will correspond to the sda ​​file, the second sdb, and so on. Accordingly, the easiest way to view the list of devices is ls -1 /dev/sd. This command will show a list of drives, but will not give us any information about them. And we need to at least see the list of sections.

Viewing a list of partitions on the drive

Each section in the dev directory also has a corresponding file. Its name is based on the name of the file corresponding to the drive and the partition number. That is, for an sda drive that has 2 partitions, 2 files will be created in the /dev directory - sda1 and sda2. You can view the list of partitions on the sda ​​drive with the command ls -1 /dev/sda a complete list of partitions on all devices is obtained from the command output ls -1 /dev/sd, and if there is a need to include the devices themselves in the list, then you can simply write ls -1 /dev/sd*, which is much less meaningful, but short and most importantly works. Or, as the comments suggest, there is another option cat /proc/partitions

Often the owner can identify a disk simply by this list (this is when he does not have 452 disks), but if this is not enough, then you can use the program hdparm.

Specifically hdparm -I /dev/sda will display detailed information about the /dev/sda device.

The same information, but scattered across different files, can be found in the directory /sys/block/sda. For example, the disk model is in the file /dev/block/sda/device/model.

If this is not enough, then all that remains is to mount the devices one by one and see what is recorded on them. But that's a completely different story.

Removing the image

So, the device has been identified and the partition from which the image needs to be removed has been found. Now the actual process. We usually call a disk image a copy of a disk at the partition or entire device level. And if a Windows user, in response to the question of how to make this copy, usually hears a recommendation to use specialized software, then in Linux everything is not so.

As I already said, here each disk and each disk partition is represented by a specific file. And, since the image is a file with a copy of the disk, it is logical to assume that the operation of removing an image and the operation of copying a partition file are one and the same.

The way it is. Let's say we need to take an image of the /dev/sda2 partition (Windows 7 usually stores the C: drive on it) and save it to a file called win_c.img.

To do this, just write cp /dev/sda2 win_c.img. Or cat /dev/sda2 >win_c.img. In short, you can use any program or combination of programs that copies files.

The right way

As you probably already guessed, you can achieve what you want in more than one or even two, ingenious and not very, ways, but the most correct and easiest way, in my opinion, is to use the utility ddrescue. What is essential is meant GNU ddrescue, and not the long-outdated original.

She, like cp, is engaged in copying files, but if errors are found, ddrescue will not interrupt the work with a happy message that the patient is more likely dead than alive, but will remember the place with the error in order to return to it later and try to read it again . Now it's slow and gentle.

Use ddrescue like this:
ddrescue<ключи> <файл который копируем> <новый файл, в который скопируем старый> <лог файл>

Ddrescue is not capable of accepting input data from the pipeline, or transmitting the result of work to the pipeline, which is not surprising. The ability to skip places with errors in the first iteration and return to them in subsequent loops implies the presence of files at the output and input.

A command that would perform an operation similar to the one described above would look like this:

ddrescue /dev/sda2 win_c.img win_c.img.log

By the way, at the moment I silently mean that the hard drive from which we are making a copy is more or less in good condition and does not throw tricks. If there are serious problems with the disk, then it is better to first familiarize yourself with the details of using ddrescue, for example. and apply this knowledge when shooting the image.

Wrong way

You can often find recommendations to use a program called dd to copy a device file or partition. As a rule, to remove an image it is suggested to do something like this:

dd if=/dev/sda2 of=win_c.img

Don't do this! Although the approach is semantically correct (one file will be copied to another), the consequences can be very sad. Yes, dd is superior to cp in the sense that if an error is detected, cp will stop working, but dd will not, but if there are bad or simply hard-to-read sectors on the disk, then dd will continue to try to read their contents until smoke comes out of the hard drive.

Yes, dd has an argument noerror, but when using it, copying may be performed with errors, attempts to recover which will not be made. ddrescue in a similar situation, after the first pass, will return to the missing places and try to read them in small pieces. And it will leave a log file, with the help of which you can continue trying to deduct bad places in the future.

In short, use ddrescue. And if there is nothing except dd, do not forget about the noerror argument.

The procedure described above can be used, for example, to save a disk image with a newly installed operating system for later recovery. Yes, a real Linux user will not do this, but among users of an operating system with a different name, this is a fairly common practice. And even penguin lovers can safely use it for periodic, thoughtful repairs of some pretty girl’s regularly broken computer. And if there are more than a certain number of girls, purely individual for each homemade product, then this method is simply irreplaceable. The main thing is not to confuse the names of files with images.

Viewing the contents of a partition image (logical drive)

Since each disk partition is represented by a file, it can be assumed that there must be a standard way to connect image files to the file system. From a certain point of view, this is true. The utility is used specifically for this mount, with which you can place the tree of files contained in the image in any directory of your choice. This process is called mounting.

So, we already have an image taken from the C: drive of the Windows 7 operating system. We named the image win_c.img and want to see its contents in a pre-created directory /mnt/win_c. To do this you need to enter the command mount -o loop win_c.img /mnt/win_c.

This is how you can make sure that the image that you are going to roll onto the hard drive of the next pink laptop is the image of the exact C: drive that you expect to see on this particular machine. Well, or you can simply copy files from it that you cannot do without and send this image into the outer darkness. And install the latest Ubuntu or Fedora on the laptop.

But we can go deeper.

Viewing the contents of a physical disk image

But mounting the entire disk image is not so simple. The terrible truth is that the kernel does not know how to mount files from an arbitrary location in the file system, and the -o loop argument of the mount command signals that you first need to associate the image with a virtual device file in the /dev directory, and then attach the contents of this devices to the file system.

Virtual device files are created in advance (at the system boot stage) and are named loop0, loop1, loop2, and so on in ascending order.

You can associate a partition image with one of these files with the command losetup. The mount command from the previous section is actually equivalent to the following two commands.

losetup /dev/loop0 win_c.img
mount /dev/loop0 /mnt/win_c

But in order to view the contents of an image that has several sections, this is not enough. The fact is that if you run the losetup command on such a file, then the entire image will be associated with the /dev/loop0 device. That is, this device will be the equivalent of /dev/sda, and we need the equivalents of /dev/sda1 and /dev/sda2.

Owners of the latest versions of the losetup program (read gentushniks and archaeologists) can execute losetup with the argument --partscan, which will lead to the automatic creation of files in the /dev directory corresponding to the image sections. That is, /dev/loop0p1, /dev/loop0p2 and so on until the horizon. And now these files can be given to the mount command.

losetup --partscan /dev/loop0 drive.img
mount /dev/loop0p2 /mnt/win_c

Those who are not so lucky with the distribution can use the program kpartx, which will do the same thing, but will put the files corresponding to the partitions not in the /dev directory, but in the /dev/mapper directory, from where they can be mounted and viewed.

kpartx -a /dev/loop0 drive.img
mount /dev/mapper/loop0p2 /mnt/win_c

But we can go even deeper than that...

Automatic creation of partition files when executing the losetup command

Actually, the kernel (specifically the module loop) has been able to search for a partition table in an image file for quite some time and create corresponding files, but this function is disabled by default.

It turns on if the module parameter loop max_part not equal to zero. This parameter can only be set when loading the module, so if the system is already running, the module must be unloaded from memory and loaded again with the already specified parameter. To do this, you need to run the following two commands.

modprobe -r loop
modprobe loop max_part=63

However, in some distributions (for example, in Ubuntu), the loop module is tightly compiled into the kernel and therefore, to set the parameter, you will have to enter loop.max_part=63 to the kernel command line and reboot the system.

Deploying an image to physical media

And now about how to actually roll the image onto another disk. As before, you need to be guided by the fact that disks and partitions are presented in the form of files. And if to remove the image it was necessary to create a copy of the device file or partition, then in order to roll this image back you need to perform a copy operation in the opposite direction. That is, instead of cp /dev/sda2 win_c.img write cp win_c.img /dev/sda2. Well, it’s better to remember the tips outlined in the image removal guide. Namely, use ddrescue and not use dd.

ddrescue --force win_c.img /dev/sda2 win_c_restore.img.log
Of course, we should remember that the partition into which we are restoring the image (in this case /dev/sda2) must be no smaller than the file with the image. If the partition turns out to be larger than this file, then there will be no problems during recovery, but there will be unallocated space in the partition. And you will either have to come to terms with this fact, or increase the size of the file system to the size of the partition using some specialized software (increasing, however, is usually much easier and faster than decreasing).

Compressing a partition image (logical drive)

A particularly nice feature of Acronis is the ability not to write parts of a disk or partition that do not contain files into the image file. This allows you to compress the image to the actual amount of data on the partition or disk.

The approach outlined earlier has fundamental limitations that do not allow implementing such a feature - sector-by-sector copy programs do not know anything about the structure of file systems and, even moreover, they do not know what a file system is.

However, there is a way out. True, to use it, the file system on which the image will be stored must support such a specific thing as sparse files.

Sparse files

A Sparse file is a file in which chunks containing zeros are not written to disk. That is, if half of the file is filled with data and the other half with zeros, only half of this file and additional information about the areas of the file filled with zeros will be written to disk. If the area with zeros is continuous and starts in the middle, then in reality the file on the disk will replace half of its theoretical volume.

Preparing a partition or device for compression

In order to take advantage of this opportunity to compress the image, you need to write zeros into the free space before removing it. This is not difficult to do - just mount the file system in a directory and create a file in this directory with binary zeros, the size of which will be equal to the size of the free space on the partition.

But fortunately, it is not necessary to find out the amount of free space and transfer it to the program that creates the file, and there is no need to look for a program that creates the file with zeros. In the /dev directory there is a dimensionless zero file, which, as you might guess from the name, is an inexhaustible source of binary zeros. All that remains is to copy it to the desired location.

Since the file is dimensionless, copying will continue until the copy fills all the space available to it, that is, all the free space in the partition, which is what we actually needed.

How to copy files using standard operating system tools has been written here so many times that the manual could well be called “The Art of Copying Files in the GNU Environment,” but since the truth does not fade with repetition, I’ll probably write it again.

To create a file with binary zeros, you can run the command cp /dev/zero zerofile or cat /dev/zero > zerofile.

Creating a sparse image file of a device or partition

Most file management utilities know about the existence of sparse files and can create them. The previously mentioned ddrescue, in order for the image to turn out to be a sparse file, you need to pass the key --sparse. Now the resulting file will take up as much space as it needs and no more.

What to do if you compress an image of a damaged disk

As you know, many disks are scary to even hold in your hands, so what can we talk about writing multi-gigabyte files on there. If you come across just such a disk, you should first remove the image and then make a sparse file from it. To do this, you need to mount the resulting image, then fill the free space with zeros and make a copy of the image, which will already be a full-fledged sparse file. The original image can then be deleted.

Copying a file can be done perfectly well by cp, which can do sparse files no worse than ddrescue. cp --sparse win_c.img win_c_sparse.img

Of course, these operations will require a lot of free space, but this is still much better than nothing at all.

Conclusion

And now, in a condensed form, what can be gleaned from this guide.
  1. In Linux, each drive and each partition on the drive has a file.
  2. Since the image is a byte-by-byte copy of the contents of a disk or partition, to create it it is enough to make a copy of the corresponding file with any program that can make copies.
  3. The best way to make a copy of a file corresponding to a partition or drive is the GNU ddrescue program.
  4. To restore the image, just copy it back.
  5. To view the contents of the image, just mount it in a directory of your choice, just as the system mounts devices when booting.
  6. Partition images and entire drive images are mounted differently and not exactly in the same way as real drives and partitions are mounted.
  7. To obtain a compressed image of a partition, you need to copy a pre-prepared partition in a special way to a file system that supports sparse files.
And what cannot be gleaned from this manual.
  1. There is a specialized software package called Clonezilla, as well as a distribution based on it, designed for backing up and restoring hard disk partitions.
  2. There are utilities ntfsclone And partclone who have knowledge about the structure of file systems and use this knowledge, for example, in order not to write empty space to the backup.
P.S. Just in case, I'm giving a link to

When replacing a hard drive with a new one, for example, a more capacious or high-speed one, as a rule, there is a need to transfer information from the old drive to it.

If you do it manually - reinstalling the system, programs and copying user files, you can spend the whole day.

It is much more convenient to entrust this to automation - special programs for cloning hard drives. With their help, all files, settings and the system itself will simply “move to a new location” in the form in which they were on the old media.

Hard disk cloning is a procedure for low-level sector-by-sector data transfer from one medium to another. In this case, the clone disk will be an exact copy of the original disk.

Hard drive cloning

Many paid and free programs have been released to create clone disks. Among them there are universal ones, working with any HDD and SSD, and highly specialized ones, designed for drives of a certain brand, for example, only Samsung or only Western Digital.

Let's look at five popular and easiest-to-use programs for cloning hard drives to SSDs or HDDs from any manufacturer.

EASEUS Disk Copy

Farstone RestoreIT Pro is primarily a tool for restoring system and user data after crashes, virus attacks, changes and accidental deletion.

This program does not create disk clones as such, but can create backups of any information on them.

The frequency of backups in RestoreIT Pro can be configured at least hourly. And restoration to a saved copy is done by pressing one button.

RestoreIT Pro features:

  • the ability to restore the system even after bootloader damage;
  • 2 backup modes - full and cumulative (saving only changed data);
  • monitoring the entire disk or only selected partitions;
  • storing the entire history of file changes, not just the last saved version.

The disadvantages of the program are the paid license ($24.95) and the lack of a disk cloning function.