📜 ⬆️ ⬇️

Automatic recovery of disk partitions using Ghost

Virtually every new laptop now has a recovery system that works when the operating system fails to boot several times in a row. Great idea: a regular user who does not go into the subtleties of his computer and operating system, is now free from 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 have been better if the recovery system did not exist at all. Firstly, with regular restoration, user data is lost, which, in principle, is expected. Secondly, the recovery process is indecently time consuming. On a computer with a hard drive in 1TB, the process went 8 hours and it is not known how long he would have walked if I had not interrupted him. 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, with a request to reinstall the operating system, then here is the way out.
It may also be interesting to incoming system administrators serving organizations with small networks, since You can significantly save time on trips to these same organizations. Now there are a huge number of parasitic programs that can transform the OS even in the absence of administrative rights, despite the presence of an antivirus.

At first, I wanted to use Linux + dd to restore partitions, but refused this idea, because dd creates too large images (even if archived) and the speed of backup \ recovery is much inferior, for obvious reasons, to software that file systems understand. The choice fell on ghost (dos), because It supports startup keys on the command line, which allows you to restore a partition with a single click.
')
Now how to do it all. First of all, you need to determine the size of the partition under the system. In my case, the hard drive was broken as follows:

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

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 section, so it turned out that after recovery, everything that was in “my documents” remained in place.

So, after installing the system (win 7 in my case), software and disabling the second section, it was necessary to make a copy of the section, and to do this, run Ghost. It turned out that the seven loader may well be loaded from diskette images and in some cases from cd / dvd images. I downloaded the floppy image with 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:

image

After the reboot, an additional item will appear in the boot menu with the name that was specified in EasyBCD when creating a new record. Booting from this image, you can run ghost and make a backup of the system partition. Suppose that the image is on the second partition and is called system.gho. For automatic deployment, you need to prepare a second boot image of the floppy disk, which will differ from the first one only by 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.
Src key:
1: 2 - the first disc, the second section
system.gho: 1 - the name of the image and the partition 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.
Dst key
1: 1 - the first section of the first disk.
Key fx terminates the application after the end.
The sure key allows you to perform a recovery in automatic mode, without answering questions like "Are you sure that ...?".
The rb key restarts the computer after the application is shut down.

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

Also in autoexec.bat before starting ghost, you can add protection from unwanted recovery, when the wrong item was 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 the floppy image has reboot.com, you can use it instead of exit.

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

Source: https://habr.com/ru/post/238083/


All Articles