How to create a copy of your hard drive. Backing up the Windows operating system in Acronis. Automatic creation of partition files when executing the losetup command

In this article, I want to share with you a super simple, extremely fast and completely free workflow that creates a perfect 1 in 1 copy of an HDD (or partition) for backup or for migration to an SSD drive. This method has saved me so many hours, days and maybe weeks of stress, and it's free and done in minutes.

You want to transfer the contents of hard drive A to drive B (maybe an SSD)

There are many backup tools (and sometimes even migration tools) that will backup your entire operating system for you, sometimes copying all the files on a hard drive, sometimes duplicating a full partition. I used them several times and trusted this tool, it only gave me the understanding that the result was completely unusable, simply because these tools do not create a REAL copy of the hard drive.

Windows' built-in backup tools will simply create a compressed image, which is only useful if you have a DVD drive burned with an ISO (disc) with exactly the same Windows version, a lot of time and a lot of luck. Creation completely working system of these backups very often end in failure.

Other tools create a complete copy of the entire Windows partition, which looks very very good. Until you actually need that backup and guess what, it turns out to be unbootable because these tools don't copy the tiny (hidden) partitions that contain the bootmanager. Bummer!

Or do you just want to backup your disk at extreme speed?

The instructions are also useful if you just want to make a one-to-one copy of any data disks that contain your files. Manual copying will process each file and each directory and initiate the copy process on a per-item basis, while the one-to-one copy method will simply copy everything as a big block in low-level hardware.

What do you need:

For this I use

Hidden from guests

Before you ask, it's completely free, I'm not getting paid or anything like that for saying this, and there's no affiliate link or anything like that. This is simply an awesome tool. I'm writing this in March 2015, and if you're reading this years later and the program is no longer free or available anymore: There are several websites online that contain an archive of earlier versions of almost any program, maybe this will help.

Macrium Reflect can copy individual partitions to any drive, usb or partition, or clone an entire drive (including hidden boot/swap partitions) to any other hard drive, even if the destination drive is smaller or larger. However, to be sure, there should be enough space for the content.

How to clone:

The cloning process is extremely simple. Check the box on the left to completely clone your hard drive. DO NOT uncheck the boxes at the bottom of sections, even if you don't understand what the sections are or where they come from. Because without these hidden partitions, your clone will not have a boot area.

Click “clone disk” and select the destination disk in the next window. Further everything is self-explanatory.

To confirm: Open command line, type “compmgmt.msc” there, go to -> “Computer Management” -> “Storage Devices” -> “Disk Management”. There you should see an exact copy, along with a hidden section.

Make sure to disconnect one of the drives so you don't get confused after rebooting.

how to make a backup copy of all partitions of the hard drive of a new laptop with installed Windows 8 in the Acronis True Image 13 program. I want to say that in this program you can make a backup copy of any partition of the hard drive separately or all partitions together (as you wish).

In the second part of the article, we will look at restoring a laptop from this backup in case it does not boot due to any errors. The True Image 13 program is paid, but nevertheless, letters with requests to make it detailed review(especially when working with new laptops and GPT (GUID Partition Table) style hard drives) comes from you a lot.

Note: A full backup of the hard drive of a laptop or a simple computer can be made not only using the Acronis True Image 13 program, there are several more free ways. For example, or, if interested, follow the links and read the articles. It will be very great if you play it safe and periodically use at least two methods to backup the hard drive of your computer or laptop.

If you use the built-in archiving tools of Windows 8 and Windows 7 to create a backup image, then the created image cannot be renamed and transferred anywhere, and the hard drive after creating the image cannot be further divided into partitions, since after this there is a high risk of not being restored from the backup image.



In the main program window, select Backup and Restore.

Third partition: volume 687 GB, installed Windows 8 operating system, that is, drive C:

Archive.

Get started.

Bootable media has been created.


Recovery process using Acronis True Image 13 boot disk


There is no need to disable the UEFI option!),

Select True Image


Disk recovery.

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 there 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.

Well, the last step is to just right-click on the desired backup copy (if you have several of them) and start the restore operation (see screenshot below).

That's all. If the Acronis program is not suitable for you for some reason, I recommend paying attention to the following: Paragon Partition Manager, Paragon Hard Disk Manager, EaseUS Partition Master.

That's all, all the best to everyone!

Hello, friends! I bring to your attention an article in which I will show you how to backup all partitions of the hard drive of a new laptop with Windows 8 installed in the Acronis True Image 13 program. I want to say that in this program you can make a backup copy of any partition of the hard drive separately or all partitions together (as you wish).

In the second part of the article, we will look at restoring a laptop from this backup in case it does not boot due to any errors. True Image 13 is a paid program, but nevertheless, you receive a lot of letters asking for a detailed review of it (especially when working with new laptops and GPT (GUID Partition Table) style hard drives.

This is what they say on the official website of the program!

Creating a backup copy of a laptop hard drive in Acronis True Image 13

Note: A full backup of the hard drive of a laptop or a simple computer can be made not only using the Acronis True Image 13 program, there are several other free methods. For example, or, if interested, follow the links and read the articles. It will be very great if you play it safe and periodically use at least two methods to backup the hard drive of your computer or laptop.

In this article we will talk about the Acronis True Image 13 program, which, in my opinion, deserves a special mention on our website and here’s why.

I am sure you will be interested in our new articles about Acronis True Image.

Firstly, Acronis True Image is specially designed to create backup copies of operating systems and restore from these backup copies, under the most unfavorable circumstances, for example, you can recover even when your computer or laptop does not boot.

Secondly, Acronis True Image 13 is compatible with the new Windows 8 operating system.

Acronis can create a backup image of all or any partition of the hard drive (including Windows) of your computer or laptop, netbook separately and restore it (them) in place if necessary.

For comparison, if you use the Recovery program built into a laptop to create a backup, then using it you can only backup all partitions of the hard drive together and restore them together, which will entail the loss of all information on the computer, laptop, or netbook.

If you use the built-in archiving tools of Windows 8 and Windows 7 to create a backup image, then the created image cannot be renamed and transferred anywhere, and the hard drive after creating the image cannot be further divided into partitions, since after this there is a high risk of not being restored from the backup image.

Using Acronis True Image, you can create a backup copy of anything and transfer it anywhere; when restoring, Acronis will definitely find its backup.
Acronis True Image can move your operating system to another hard drive partition, or to another hard drive altogether, or even to another computer. The backup copy can be divided into parts and renamed. Once upon a time, many years ago, I became acquainted with this program and still work with it, do not consider this as advertising. Imagine, you install an operating system, then install about a hundred programs into it for working with text, video, graphics, the Internet, accounting, and so on, almost every program has its own installation features, and it sometimes takes you several days to do everything. And in the end, you create an archival backup of everything that you may have to work with for several years and then work calmly without fear that your operating system will crash or become inoperable for some reason. You can restore it at any time using the program... Acronis True Image 13 Nowadays, most computers and laptops are sold with Windows 8 installed and the UEFI interface instead of the BIOS, therefore, the hard drive on such devices has a new style of placing GPT partition tables (GUID Partition Table). Works stably with such devices latest version Acronis True Image 13 program. But even if you do not have a new computer and the hard drive has an outdated MBR partition table, then Acronis True Image 13 will handle it even better.
On the official website http://www.acronis.ru/ you will find more information about the program. Choose "For Home"

and you will be able to download and install a trial version of the program for free, with which you can create an archived image of the operating system, consider all its capabilities, but you cannot only do one thing - restore from a backup image. To do this you will have to purchase the program. Creating a backup image in Acronis True Image 13 In the main program window, select Backup and recovery.

Backup disks and partitions.

Look carefully out the window Managing my laptop's disks, you can see two hard drives in it, the first Disk 0 has four partitions:

The first partition: System, hidden, capacity 1.00 GB, healthy (Recovery partition), this is the service partition of the laptop.

Second partition: Unnamed, hidden, volume 260 MB Healthy (Encrypted (EFI) system partition) belongs to the operating system.

Third partition: volume 687 GB, installed Windows 8 operating system, that is, drive C:

Fourth partition: Recovery, hidden, capacity 10.75 GB, Good (Recovery partition), this partition contains files with the factory settings of your laptop.

Disk 1: My Passport (E:) is our portable USB hard drive; in fact, we will place our backup image of all partitions of the laptop’s hard drive on it.

Acronis True Image 13 offers to include all existing laptop partitions in the backup image. If you just bought a laptop or computer, then my advice to you. First of all, create a complete backup image of all partitions of your laptop’s hard drive, as the program suggests. To do this, it is best to switch to disk mode, but before that we look at what will be included in our backup image.

Click Switch to disk mode.

We tick the hard drive of our Toshiba laptop, now we need to select the location of the image to be created, click “Browse”.

In the left window, select our portable USB hard drive My Passport (E:), left-click on it and click OK. Give the name of the backup copy in Latin or leave it as default, in my case – TOSHIBA MQ01. Click OK.

If you now click the Archive button, the process of creating a backup image of the laptop will begin, but before that, let's select the Backup Options button.

I want to say that they are configured optimally by default, but still some points are worthy of attention. For example, you can split the backup into several parts. I'll set this option to "Automatic"

Be sure to check the box "Archive in sector-by-sector mode"

And "Check the backup after it is created." Click OK.

Archive.

The process of creating a backup copy of the entire laptop hard drive begins.

After successfully creating a backup archive, look at where exactly our backup image was created on a portable USB hard drive, folder E:\My backups\TOSHIBA MQ01.

Creating bootable media for Acronis True Image 13

Now be sure to create bootable media. The natural question is why. Friends, you need to create bootable Acronis True Image 13 media in case extreme situation. For example, your laptop will not boot due to errors and even our article will not help you restore it. Then we boot from bootable media (CD or flash drive) and restore our laptop from the backup image. How to do this is described in detail later in the article. But first, let's create bootable media.

In the main program window, click on the Create bootable media button.

I select the drive and create a bootable disk with Acronis True Image 13. If you want to create a bootable flash drive, connect it and it will appear in this window. Further.

Get started.

Bootable media has been created.


Recovery process using Acronis True Image 13 boot disk

You can also restore Windows 8 using Acronis True Image 13 from a running system; run True Image 13 and select restore.

Caution: If you backed up only the C: drive, then all data on it will be replaced by the data from the backup copy. If you have created a backup archive of your entire hard drive, then all the information on your hard drive will be replaced with the data from the backup copy.

But usually they resort to recovery using Acronis True Image in extreme cases, that is, when the laptop does not boot at all and you cannot do without a program boot disk.

Let's imagine this situation: our laptop won't boot! This can happen for many reasons. For example, we were experimenting with creating new partitions on our laptop and accidentally deleted the service partition with the Windows 8 download files. Or you decided to reinstall Windows 8 on Windows 7, but something didn’t work out for you and now nothing loads on your laptop, except for errors on a black screen. Or maybe you successfully reinstalled Windows 8 on Windows 7, but after using the seven for a while, you decided to return the laptop to its original time factory condition.

For example, as an experiment, I deleted all partitions on the laptop hard drive

and now I will perform a recovery operation. I want to keep you from such experiments, no need to abuse your laptop unnecessarily.

Note: To restore from a backup archive, first of all you need to enter the UEFI BIOS of our laptop and disable the "Secure Boot" option ( There is no need to disable the UEFI option!),

otherwise, when you boot your laptop from the Acronis True Image 13 boot disk, you will receive an error. If you don't know how to do this, read our article ".

So, we boot our laptop from Acronis True Image 13 boot media (CD or flash drive). If you don’t know, follow the link and read.

For example, my laptop can be booted from disk if immediately after turning it on, I frequently press the F-12 key. The boot menu appears. I choose a DVD-ROM with an Acronis True Image 13 boot disk.

Select True Image

Sorry for the quality of the photos, but I carry out the operation of creating a backup archive, as well as restoring from it, on a real laptop, and not on a virtual machine. So it's all for real.
Disk recovery.

Finding a backup Windows archive 8. It is located on our portable hard drive USB drive My Passport (E:), in the folder My backups\TOSHIBA MQ01

Select it with the left mouse and click OK.

Check the box "In sector-by-sector mode"

Check the box for "Disk 1" and all other partitions

Check the "Restore disk signature" option and click Next.

The program shows what will be restored and in what order. Get started.

The process of restoring our laptop begins.

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 he appeared unlimited Internet, 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 full list partitions on all devices is obtained from the output of the command 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 device /dev/sda.

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.

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 carry out a copy operation in the opposite direction. That is, instead of To do this, just write 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 will be written to disk, and more Additional Information about areas of the file filled with zeros. 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 a 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

In this article I will tell you how to backup data: work files, multimedia and the operating system (make an image of it). Backup (data archiving) is extremely necessary, since as a result of a hard drive failure or a virus, you can lose important documents, photo archives, and works created in various programs. Maybe you just want to reinstall a clean copy of the OS with all the programs. Once this happens, the situation will be easy to correct.

The most common case for users is the failure of the operating system. In order to restore the computer to its previous state (programs, settings, etc.), you need to spend from several hours to several days installing and configuring the Windows OS, but the installation of additional software takes the most time. Often inexperienced users store their data on system disk, without thinking about transferring information to other sections of the hard drive, not to mention external HDDs.

Backup (archiving) and recovery methods

Windows 7: Built-in Backup and Restore Tool

It is quite easy to use and even allows you to perform this procedure automatically on a schedule. Location of the backup tool on the system: "Start | All programs | Service | Archiving and recovery". Menu in the left column - "Create a system repair disc" And "Creating a system image".

Creating a system image. It is necessary to indicate the location of the future archive: select another disk partition, external HDD or optical disk (DVD, Blue Ray). There is also the ability to save a backup copy to a network drive. It is not practical to use optical media, so use a logical drive with sufficient storage space or an external HDD to store the backup. Select a location and click the “Archive” button. The entire system partition will be archived. This procedure can be carried out on a schedule, and Windows updates a previously recorded system image without creating it again, which significantly saves time.

If you select the Backup tool, you can set up regular backups of important user data. To do this, select “Set up backup”, indicate which drive the backup will be saved to, click “Next”, in the next window select “Give me a choice” and then select the objects to be backed up. To restore the contents of a backup, choose one of three suggested actions: “Restore my files from this backup,” “Restore files for everyone on this computer,” or “Manage the disk space used by this backup.”

To restore the system if it does not boot or produces an error that you are unable to fix, you may need a disk disaster recovery. To create it, select “Create a system recovery disk” in the menu on the left and indicate on what media to organize it. Unfortunately, only laser discs are supported, which is not suitable for owners of laptops without an optical drive.

This built-in Windows tool is not without its drawbacks, such as for a long time archive creation and lack of compression function. However, there are other, more functional products.

Backup and restore using Acronis True Image Home 2013

For users of Windows XP, where there is no built-in backup tool, as well as users with higher requirements for the functionality of a backup program, I recommend using Acronis True Image Home 2013.

Acronis True Image Home uses 3 backup methods.

Full image - archiving absolutely all data, including the MBR (if the partition is bootable).

Differential - the backup copy includes only those data that have changed since the creation of the archive using the first (full) method.

Incremental method - allows you to supplement the backup copy with files changed since the last backup procedure.

It’s easy to make a backup copy of the system partition: in the main program window, select the first option - "Backup disks and partitions", then specify the partition or disk, set the location to save the archive and, if necessary, change the archiving parameters (for example, set the compression level of the archive on the "Performance" or protect the archive with a password). At the end of the process, a file with the extension will be created in the storage you specified. *.tib. Acronis True Image Home 2013 allows you to connect a backup copy as a logical drive and work with the necessary data. In this way, you can extract the desired file from a pre-created archive that you accidentally completely deleted from your hard drive.

In addition to backing up partitions and disks, you can archive (including on a schedule) individual directories and files, as well as the Windows address book, contact list and Microsoft Outlook correspondence. To recover in the most severe cases, you can use a bootable version of the program (boot disk or boot disk), and it is possible to create such a solution on both optical and USB media.

It happens that when experimenting with installing several operating systems, the Master Boot Record turned out to be damaged; you can try to “revive” it by checking the “MBR” checkbox when restoring from the image. Also, Acronis True Image Home 2011 can convert backups from its “native” format to the VHD format (these are backups created by the Windows 7 system tools, and at the same time virtual disk images, that is, they can be connected to almost any virtual machine) and vice versa .

In most cases, recovery comes down to selecting the desired archive and partition in which the contents of the backup copy will be deployed. It is worth noting the extremely long installation time and low performance of Acronis True Image Home on Windows XP.

Paragon Backup & Recovery Professional: Backup with More Features

About the Paragon Backup & Recovery Professional program, which provides file backup and recovery I told in, however, with a purpose Windows migration to another PC. Unlike the Acronis product, in addition to archiving operations, it also allows you to perform some actions with partitions - for example, changing the label, formatting, hiding and deleting. However, to do this you will need to switch to “Advanced Mode”.

Before backing up, it is recommended to create a rescue disk to restore data from the image. To do this, go to the “Utilities” section and select “Create a rescue disk”. Here you can also choose either an optical drive, an external hard drive, or a USB flash drive as a storage medium.

To create a backup copy of your data, go to the “Data Protection and Recovery | Intelligent archiving”, without forgetting to prepare reliable storage first. You can choose what to back up: “Disks or partitions”, e-mail (e-mails, accounts and address books of Outlook, Outlook Express and Windows Mail), “Media Files” and “Documents” (texts, photos, videos and music stored in the “My Documents” directory) or “Other Files or Folders”.

Next, you can make additional copying parameters - selecting the degree of image compression, password protection and sector-by-sector copying mode (all sectors of the disk are processed “as is”, including unused ones). You can also assign an FTP server as an archive storage, if you have one. If you choose optical media, the program will warn you that it will be impossible to save the master boot record of the disk.

For advanced users, Backup & Recovery has professional tool for working with images of Virtual PC, VMware Workstation and VMware Fusion virtual machines. Thanks to it, you can convert an image of a real hard drive, such as a system partition, and then open it along with all the data and programs in a virtual machine, even on another computer.

The main problem when changing a hard drive is the need to install and configure the operating system and programs from scratch. It takes a lot of time and effort.

The solution to the problem is automatic disk cloning (HDD, SSD) using special software.

Cloning is the process of sector-by-sector transfer of the operating system, software and personal user files from one drive to another. Unlike backing up or creating a disk image (ISO), cloning creates a 100% copy of the original media: the main partitions, structure and software are preserved.

The new cloned disk turns out almost identical to the old one. This means you don't have to re-configure your work environment, activate the system, or restore software licenses. The difference between it and the original media is that the operating system is removed from the binding to the computer hardware, but it also becomes impossible to roll back the system to its original settings while saving user data and reinstall it in update mode.

Preparing for cloning

Before you start cloning, make sure that nothing will interfere with the process:

  • If you are using a laptop, charge the battery;
  • Troubleshoot problems that cause your computer to reboot or shut down (if any).

It is also advisable to make backup copies of important data.

Connect the receiver disk via any available interface. The process will go faster if both media are connected to SATA 6 Gb or faster connectors, but if this is not possible, use, for example, USB (USB-SATA adapters are sold in computer stores).

Hard drive cloning time depends on the following factors:

  • Program capabilities.
  • Disk capacity. The larger it is, the longer the utility takes to transfer files, partitions and structure.
  • Speed ​​and type of source and destination drive: When working with SSD (solid state media), the process is faster than with HDD (magnetic hard drives).

Cloning utilities

We present to your attention the best, in our opinion, utilities for cloning hard drives.

Renee Becca


Macrium Reflect

The main advantage of Macrium Reflect is its simple and user-friendly interface. The program is also free for home use.

While the utility is running, disable heavy applications, as the program is demanding on computer resources.

To make a clone of a storage medium, you need:


Handy Backup

Handy Backup is an easy-to-use program for creating physical and logical copies of disks. The utility creates an exact copy of the HDD while completely preserving its structure.

Cloning is performed automatically: you do not need to manually clean up garbage, transfer files, or fix registry errors.

To use this software permanently, you need to purchase a license. A 30-day trial is available for free. It is sufficient to perform basic functions. The interface has been translated into Russian.

How to use Handy Backup:


HDClone

HDClone is another universal hard drive cloning tool that allows you to work with drives with a capacity of 137 GB or more.


Acronis True Image

A special feature of Acronis True Image is that the copies created in it can be stored not only on your computer, but also in the Acronis Cloud cloud storage. When storing data in the cloud, a copy of the disk can be accessed from any device connected to the Internet. To protect data, the program uses AES-256 encryption.

To use all the features of the utility, you need to buy a subscription. The cost of the standard version is 1,700 rubles. There is a trial version for 30 days.