Do-it-yourself frivolous cloning of MS Windows XP / Server 2003 OS, GNU / Linux tools

Explanatory letter

I publish the journalized result of work to ensure a universal, viable image of the installed operating system (hereinafter OS) Windows XP SP3.

It was needed to speed up the process of installing the system on computers of customers who wanted to definitely use this familiar version of the windows despite the rants regarding support, activation, and other unimportant moments for the user.

Why is this needed?

What distinguishes this material from common articles on the topic of OS cloning? The limitations set before me by life and by myself. I will list them:

1) the OS must be installed and work on partitions of arbitrary sizes;
2) The OS must boot properly, being installed on any type of media that supports booting (equipped with MBR *);
3) the OS must operate on various versions of the hardware-dependent level (HAL **);
4) The OS image should occupy a minimum of space on the media to accelerate its transfer, retrofitting, bulkhead;
5) The OS image should include the necessary set of software installed and configured in the best way (the “turnkey system” option);
6) All manipulations on image preparation and on its development should be performed using standard GNU / Linux *** tools. Meaning: disassemble the operating principle of the existing software for OS cloning;
7) The carrier of the OS image can be a server on the network, a USB drive (solid state or hard drive), an optical or hard magnetic disk;
8) The OS image carrier must be equipped with diagnostic and repair tools for computer software;
9) It is desirable to make the process of OS cloning as accessible as possible for the sake of good repeatability without reducing the reliability of the result;
10) The dd command is certainly good, but just reluctant to bother with empty space, zeros and the lack of a clear conclusion of the current action. In addition, the partition in which the clone will be installed must be arbitrary (see paragraph 1).

Out of consideration:

1) Legal aspects of installing an currently unsupported OS;
2) Activation of the now officially inactive OS;
3) The feasibility of the actions taken. Not zadrotstva Krasnoglazov sake, but the will of him that sent me tokmo users. Those who sent for trying to convince kosher of using fresh, free software on their block machines;
4) Details of a typical installation of Windows XP and add. Software on a computer, with the exception of disk partitioning;
5) Details of the network cloning method: I will consider in the future, now I do not have such a need.

Who needs this?

The work is focused on satisfying the needs of end users. This article is written for system administrators who want to adopt the experience and knowledge I have acquired and use the method described below. Hence the details that hasty people may not like. The volume of the text, in my opinion, is monstrous for easy perception, but I cannot do otherwise: I must convey every step I take.

Constructive criticism is welcome; Especially valuable are suggestions for improving the method, as well as a theory justifying the observations.

The article was written on December 2, 2014, therefore I send my greetings to future generations, and I don’t know how much the material remains relevant to you.

Welcome,% username%, under the cut.

What needs to be done at all?

Dear reader, cloning involves the preparation of tools and materials, their creation of a clone and its distribution (installation). The Windows XP operating system is quite capricious of any kind of flash drive swinging, and especially disgusting moments await us at the bootloader installation stage and when starting a cloned OS on SATA controllers enabled in AHCI mode. However, patience and work will grind everything.


First, we introduce the terminology .

1) Reference computer **** , or reference computer = PC, on which a clean installation and configuration of the operating system, the necessary programs, updates are performed. Accordingly, the resulting software is called a reference OS ;
2) A clone of the OS , it is the image of the reference OS = archive, containing the contents of the system partition of the installed OS. And nothing more;
3) Target computer (target computer) = PC on which you want to deploy the resulting clone of the reference OS;
4) Under additional softwareI am roaming distributions of all kinds of office programs, multimedia codecs and players, a normal human browser. Anonymous, you yourself determine this!


We describe the materials necessary for the work.

0) Strong hands, an inquiring mind, a persistent desire for a result. In the absence of any component, anonymous, you have been warned;
1) Full information about the hardware configuration of the target computer, specifically: the name of the controller NMZh *****. If one is built into the motherboard, then the name of the south bridge (hereinafter referred to as UM) will be required.
2) A clean image of the installation disk of MS Windows XP; service pack and language = to taste. In an economy of each administrator of a wide profile should be;
3) GNU / Linux boot distribution image = to taste; Mandatory support for working with NTFS, FAT16, FAT32 file systems. The maximum set of drivers on board is desirable. I used the ubuntu-12.04.5-dvd-i386 distribution;
4) The minimum set of external media: an optical disk for the Windows XP installer, any bootable media for the Linux distribution and storage of a clone of the reference OS. I used USB-HDD: there is a lot of space, enough for everything, and a normal partition table to the heap;
5) Prepare the media and dig the necessary materials on a running computer running a network operating system. I used a regular office PC and Ubuntu 12.04 distribution for this. I boldly assure the username: everything can be done from under Windows;
6) Fresh driver of the controller NMZhD or UM motherboard target computer, compatible with Windows XP;
7) Unpacked archive (can be found in the image of the Windows XP installation disk);
8) Unpacked archive (can be found on the Microsoft website );
9) Unpacked grub4dos archive ( assembly links , Russian-language manual ). And additional assistance to the fragile foggy consciousness of a young admin:

Bake a clone

Here, we have collected all of the above, combing the brains with the general scheme for creating a clone . We will consider the details later.

0) Prepare a reference computer: let it be a computer with a hardware configuration that is most appropriate for the configuration of most target computers;
1) Prepare bootable media for a clean installation of Windows XP (in other words, boot disc with Windows);
2) Prepare the bootable media of any Linux distribution. It will serve us as a means of preparation / development of the clone, as well as diagnostics / repair of the target computer. It should have an unpacked grub4dos archive;
3) Install the Windows XP OS on a reference computer, configure it most generally (as customers like it the most);
4) Install the list of additional software for this OS, configure;
5) We install on the reference OS the driver of the controller of the hard drive for the target computer;
6) We write in the root section of the reference OS the necessary means of preparing the clone. We complete the work of the target computer.
7) We load the media of the Linux distribution on the reference computer, mount the file system (hereinafter referred to as the FS) of the partition with the installed reference OS;
8) Create a clone of the reference OS, save it to any media mounted on Linux (in my case, the same bootable Linux media).

Serve on the table

The clone is created and looks at you,% username%. Now it’s general how to roll it onto the user’s target computer:

0) We take the Linux distribution media, go to the user, drive it away, stick the media into his (target) computer. Start!
1) If you do not smoke, download our live Linux distribution;
2) From this moment, the rollback of actions will be very difficult , I warned. So, we mark up in a new way the hard disk (or SSD?) Of the target computer. We create a section on it under Windows. Formatting (I would choose ntfs). We mount the received section somewhere;
3) Unpack the clone of the reference OS into the resulting disk partition of the target computer;
4) Install the boot loader Grub4Dos on the disk of the target computer;
5) Turn off, remove the extra media, take a deep breath, start;
6) If everything went well, you will be greeted by the program for installing Windows XP, where you and the user will set everything as it should;
7) I will use an overseas word: PROFIT!

How do we achieve this?

So, my patient reader, we got to the pulp . Yes, now the cherished lines of commands will be displayed on the monitor screen, detailed instructions for each step of the scheme for creating and rolling the clone will be announced. The title should have been titled “How I Did It,” but I hope you succeed exactly the same!

Inventory preparation

I repeat, I prepared everything under the control of the Ubuntu 12.04 OS.

1) Get a clean, devoid of any twists installation image of MS Windows XP, they are also called 'MSDN-images'. Implemented the latest service pack is desirable. Having obtained it, roll it onto a suitable optical disc. I did this with the Brasero program;
2) Download any suitable GNU / Linux distribution with the ability to boot from any medium (the so-called Live system). Requirements: wide support for various hardware, support for NTFS, FAT16, FAT32 file systems. For best compatibility, use a 32-bit OS. Repeat: used the distribution ubuntu-12.04.5-dvd-i386, satisfies in all respects. Torrent , direct download link ;
3) You can roll up the extracted Linux from under Ubuntu using the usb-creator-gtk program, everything is intuitive there. I rolled on a separate clean 160GB USB-HDD with one NTFS partition, allocating all the remaining space for stored files and folders; Thus, I immediately received a boot disk and a place for various means, clones, user data and a library of programs;
3.1) No one bothered me to normally format, format my USB-HDD, and write the image to it using the command:

dd if=/путь-до-образа-линупса of=/dev/sd{ваш носитель} [ bs={размер кэша носителя по желанию в МБ} ]
It is only better to wait until the disk indicator stops flashing, because the command is insidious;
4) Add the unpacked archive with the fresh Grub4Dos assembly ( download here ) to the carrier with life-giving Linux. Desirable closer to the root. Why rude4do? Yes, because I do not want to force you to learn the joys of your native Windows loader, but it’s rude and more pleasant to set up. This archive contains the menu.lst boot menu control file: if you want to configure the bootloader, do it now in any text editor. Details here ;
5) On the same medium, if space allows, place installation software packages that users will need. In any directory, of course;
6) To ensure the best compatibility of the Windows clone with various motherboards (or rather, power management methods), subsequently there will be a need to supplement the list of loaded XP cores. To do this, from the installation image of Windows XP, unzip the i386 / archive. Look for the following dlls in it: hal, halaacpi, halacpi, halapic, halmacpi, halmps, halsp. Copy these files to some directory of the Linux bootable media, we will need them soon;
7) To avoid problems with loading XP on target computers, download and unzip the latest drivers from suitable NMZD controllers. If the controllers are built into the motherboard, download drivers to its UM. In any case, you will have to reinstall the drivers after each target computer. Save the drivers to the same healing Linux media;
8) Admin! Be attentive and accurate. Check everything that you dumped onto this multi-purpose medium, learn the file paths. Know: you may have to look for them in the Linux shell. Do not scatter files, distribute them better competently in directories. And finally, copy the installation image of Windows to the same medium: the stock of trouble does not repair.

Clones, it's time to execute command 66!

We have prepared the necessary. We take the reference computer in hand, the disk with Windows - in the teeth. Our task: install and configure the reference OS, ext. programs, complete the preliminary preparation of the cloned system.

1) Set the reference axis to the reference comp. We add as needed the minimum of necessary programs, so as not to squeeze after them. Activating Windows and programs is not worth it now: you need to do this with the end user on the target computer;
2) We work for this OS. Objective: to provide, after cloning, the choice of the power management configuration of the motherboard of the target computer. We connect our bootable media with Linux: I guess you formatted it in NTFS? We copy from it to the% systemroot% \ system32 \ directory the files {halaacpi, halacpi, halapic, halmacpi, halmps, halsp} .dll, which we saved in advance in a secluded folder on the media. These are microkernels for loading the OS with a specific motherboard device. In order to use these kernels, we modify the configuration file of the Windows boot loader% systemdrive% \ boot.ini. Do not forget to back up the file! You should get something like the following:

[boot loader]
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /fastdetect
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Standart PC" /fastdetect /hal=halstd.dll
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="ACPI PC" /fastdetect /hal=halacpi.dll
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="ACPI Uniprocessor PC " /fastdetect /hal=halmacpi.dll
C:\grldr="Загрузчик GRUB4DOS"

Do you recognize? This is the same hidden choice of the XP installer, available by pressing F5 when installing from disk. The last line will serve us in the future;
3) If you downloaded the latest hard drive controller driver for the target computer, install it in the reference XP forcibly. Good for you! And you don’t have to bathe in the BIOS of the target computer, turn on the compatibility mode (IDE) ...
4) Check the whole system. See if everything is set up correctly. Further actions will need to be performed without reboots;
5) Prepare the system for cloning completely. To do this, look for the archive, which we saved in advance on the Linux bootable media. Open it with any archiver, and then unzip the SYSPREP folder to the root of% systemdrive% (drive C: in our opinion). This is a natural microsoft tool for preparing the OS for cloning. We will use it in order to avoid a bunch of small problems like the same SID of cloned OSes, the same activation data, and all that. This is done in detail like this:

5.1) Run setupmgr.exe. Select Create a new answer file, Sysprep Install. CAREFULLY choose your version of Windows. We answer Yes, full automate the installation. Fill in the fields as we want and click "Next". The program will save the results of its work in the file C: \ SYSPREP \ SYSPREP.INF.
5.2) Run:

c:\sysprep\sysprep.exe -pnp -mini

Change Shutdown mode to quit, click “Reseal”, wait for the program to finish working.
We will be careful. The next time the system boots, the installation starts, so it is better not to allow it to be reloaded.
6) Most likely, the reference OS has completed work. Now is the time to take her image. To do this, we connect our life-giving media with Linux to the reference computer, boot from it (do not allow XP to boot!). Of course, we are not interested in installing the system, but simply loading it. In the case of Ubuntu, we get a graphical interface and a bunch of different useful applications;
7) Today we act decisively and quickly. Open the terminal emulator (ctrl + alt + t), execute a sequence of commands:

sudo su
mkdir /mnt/sd{1,2}

- go under the root and create mount points for two media. Our task now: to mount the drive on which the reference OS is installed, and an external drive with Linux and our files. We accomplish this by substituting the necessary values ​​of partitions and disks into the commands:

mount /dev/sd<внутр. носитель_1-й раздел> /mnt/sd1
mount /dev/sd<внеш. носитель_нужный раздел> /mnt/sd2

We check whether we have mounted:

ls /mnt/sd1
ls /mnt/sd2

Directories for transferring the image are ready;
8) Launch the Windows clone using the tar command:

cd /mnt/sd1
tar -czvf /mnt/sd2/xp.tar.gz ./*

9) We observe the packaging process. I got the xp.tar.gz archive in the root of the Linux media, about 1.2 GB in size. This is a ready-made clone of the reference OS!

Clone distribution

Before a sustainable result, I had to do these steps about fifteen times.

The task now: to roll our image on a trial target computer, install the bootloader and make sure that everything works .

1) Take with us our life-giving Linux media. It now has a clone and a means to put it. We connect to the target computer, load Linux. Again, open the terminal emulator and begin work;
2) Let's mark the hard drive of the target computer. I use the old-fashioned fdisk program. Attention! If there is anything valuable on the destination drive, be sure to copy it to a reliable backup medium! After that we execute the commands:

sudo su
mkdir /mnt/sd{1,2}
mount /dev/sd<Носитель с Линуксом, нужный раздел> /mnt/sd1
ls /mnt/sd1
mount /dev/sd<Носитель целевой ЭВМ, если есть разделы> /mnt/sd2
ls /mnt/sd2

So, we checked to see if we identified the drives correctly. Suppose everything is correct, and everything is mounted exactly as indicated. Then proceed further (hedgehogs #, of course, do not enter, this is a comment):

umount /dev/sd<Носитель целевой ЭВМ, если есть разделы>
fdisk /dev/sd<Носитель целевой ЭВМ>
#Новая таблица разделов
o ввод
#Новый раздел
n ввод
#Указываем нужные параметры: первичный, номер 1, начало, конец (в блоках)
#Укажем тип файловой системы NTFS
t ввод
1 ввод //первый раздел
7 ввод //тип=NTFS
#Сделаем раздел загрузочным (активным по-виндовому)
a ввод
1 ввод
#Записываем новую таблицу разделов на носитель целевой ЭВМ (практически необратимо!)
w ввод

Fdisk should complete successfully. Otherwise, complain, and then look for a solution on the Web. Often, the administrator forgets to unmount the media before changing the partition table, this prevents it from being overwritten. Umount will help;
3) We format the quickly received partition in NTFS, mount it:

mkfs.ntfs -f /dev/sd<Носитель целевой ЭВМ, первый раздел>
mount /dev/sd<Носитель целевой ЭВМ, первый раздел> /mnt/sd2
ls /mnt/sd2

The output of the last command should be empty;
4) Unpack our clone of the reference OS into this section:

cd /mnt/sd1
tar -xzvf xp.tar.gz -C /mnt/sd2

We sit, we drink coffee fast, fast, in one gulp!
5) The last major touch: installing the bootloader. Let me remind you that we put the unpacked archive of the fresh grub4dos assembly onto Linux media:

cd /mnt/sd1/Путь до распакованного архива
#Если мы в каталоге архива, выполняем установку загрузчика:
./ /dev/sd<Носитель эталонной ОС>
#Для полноценной работы скопируем файлы загрузчика grldr и меню menu.lst в корень первого раздела носителя эталонной ОС:
cp grldr menu.lst /mnt/sd2

6) Turn off the target computer, you can do this:

shutdown -h now

Is the end to torment?

That's it, my patient reader! If the stars formed today correctly, you did it. If not, then either I missed something, or - lay out the configuration, we'll see.

Thanks for attention!

Also popular now: