Automatically restore disk partitions using Ghost

Almost every new laptop now has a recovery system that works when the operating system cannot boot several times in a row. Great idea: an ordinary user who does not go into the intricacies of the operation of his computer and operating system is now spared the need to contact a service center, which saves him time and money.

However, the implementation of this idea turned out to be such that it would be better if this recovery system were not at all. Firstly, with regular recovery, user data is lost, which, in principle, is expected. Secondly, the recovery process takes an indecent time. On a computer with a 1TB hard drive, the process went on for 8 hours and it is not known how long it would go if I had not interrupted it. How to deal with this disgrace you will learn under the cut.

If you are regularly approached by relatives and friends who themselves are not able to roll out the image, asking them to reinstall the OS, then here it is, a way out of the situation.
It can also be interesting for incoming system administrators serving organizations with small networks, as You can significantly save time traveling to these same organizations. Now there are a huge number of parasitic programs that can transform the operating system even in the absence of administrator rights, despite the presence of an antivirus.

At first I wanted to use Linux + dd for partition recovery, but I abandoned this idea, because dd creates images too large (even if archived) and the speed of backup / restore is much inferior, for well-known reasons, to software that understands file systems. The choice fell on ghost (dos), because it supports startup keys on the command line, which allows you to restore a partition with the click of a button.

Now about how to do it all. The first step is to determine the size of the partition for the system. In my case, the hard drive was broken like this:

1. 50 GB for the main system.
2. 20 GB under the partition for the image.
3. The rest of the data space.

The second partition was formatted in ntfs but was not mounted on the system, in order to avoid deleting the image. The user folders were moved to the third partition, so it turned out that after the restoration, everything that was in “my documents” remained in place.

So, after installing the system (win 7 in my case), software and disconnecting the second partition, it was necessary to make a copy of the partition, and to do this, run Ghost. It turned out that the bootloader of the seven may well boot from floppy disk images and, in some cases, from cd / dvd images. I downloaded the disk image from dos-6.22 from here . Unpacked the image, created a new one, adding ghost. You can download my image from here .

The easiest way to boot from this image is to use the EasyBCD utility:


After rebooting, an additional item with the name that was specified in EasyBCD when creating a new record will appear in the boot menu. After booting from this image, you can start ghost and make a backup of the system partition. Suppose that the image lies on the second section and is called system.gho. For automatic deployment, you need to prepare a second boot image of the diskette, which will differ from the first only in the contents of the autoexec.bat file:

ghost.exe -clone,mode=pload,src=1:2\system.gho:1,dst=1:1 -fx -sure -rb

This line is inserted at the end of the autoexec.bat file.
Key src:
1: 2 is the first disk, the second section is
system.gho: 1 is the name of the image and the section inside the image.
In this case, it is there alone, but it is possible to restore a specific partition from the image of the entire disk.
Key dst
1: 1 - the first partition of the first disk.
The fx key terminates the application after completion.
The sure key allows you to restore automatically, without answering questions like “Are you sure ...?”.
The rb key restarts the computer after the application terminates.

Please note that my system is installed on the first partition, without creating a bootable windows partition. If there is a boot partition, then you must add 1. to the partition numbers in the startup parameters.

Also, before launching ghost in autoexec.bat, you can add protection against unwanted recovery when the wrong item was accidentally selected in the boot menu.
set /P var="Destination Drive will be permanently overwritten. Proceed? (yes/no) : "
if not "%var%"=="yes" exit /b 1

If is on the disk image, you can use it instead of exit.

The second image must be added to the download in the same way as the first.

Also popular now: