Replacing A Disk With A Smaller One Using Clonezilla Live
Replacing A Disk With A Smaller One Using Clonezilla Live
Replacing A Disk With A Smaller One Using Clonezilla Live
This document is currently a draft in test mode! Feel free to report any error or to suggest enhancements to the author.
Summary
1. Presentation ...................................................................................................................... 4 1.1. Prerequisites .............................................................................................................. 4 1.2. Process Overview ..................................................................................................... 4 1.3. Estimated Duration ................................................................................................... 5 2. Preparing The System ...................................................................................................... 7 2.1. Source Disk Processing ............................................................................................ 7 2.2. Preparing The Target Disk ........................................................................................ 9 3. Replicating To The Target Disk ........................................................................................ 9 3.1. First Method: Direct Cloning (Disk To Disk) ........................................................... 9 3.2. Second Method: Using A Temporary Image ........................................................... 10 4. Windows FAQ ................................................................................................................ 11 5. References ...................................................................................................................... 11 6. Credits ............................................................................................................................ 12 7. License ............................................................................................................................ 12
2/12
We sometimes change a PC disk, just because it is failing or because SSD replacements are smaller than standard mechanical ones or for whatever reason. When it comes to disk cloning or imaging, Clonezilla is usually the Libre software tool of choice: its efficient, fast and very well supported. Theres a drawback, though: Clonezilla cant directly clone or restore to a smaller target than the source device. The Devil is in details, too! It happens that, within the same series of disks (same commercial reference), two of them are not strictly of the same capacity 1. Yet, a very small difference can make the cloning impossible. We all know that often, for optimisation sake, vendors are adjusting their own hardware providers, so this situation is certainly not uncommon. Then, how can we deal with these situations with our tool of choice? This is what were going to show here with a solution that works, at least for the author.
Backup Your Data! Any action that touches disk structure, partitions and filesystems is a potential source of failure. You should never test on living data but on dedicated material and hardware. A backup of the data before any other action is highly advised!
What This Document Is Not This document supposes that disk geometry is a topic known by the reader and that such tools like Clonezilla Live and GParted are well known. In other words, this document is in no way a manual explaining the uses of these tools. Its goal is just to introduce a solution to a common problem.
1 To ensure that two disks from the same vendor and type are from the same batch, check the model codes that are printed onto the drives.
3/12
1. Presentation
Clonezilla Live is a Free software live CD that can clone or backup disks or partitions. Using Clonezilla makes it is easy to restore a disk to a previous state that had been saved at that time. In corporate environments, Clonezilla allows to create identical machines from one unique model configuration, whatever the underlying operating system.
1.1. Prerequisites
Hardware
The target (replacement) disk. (not mandatory but highly recommended) A spare device for temporary storage.
Software
Clonezilla Live (version used here: v.1.2.12-10) ; PartedMagic (or GParted or any similar tool) (version used here: v.6.7).
The process is a three-step one: first we set our source disk so that it can be cloned, second we partition the target disk according to the source disk partitioning and, third, we copy the data from the source to the target. Figure 2 shows how we are going to deal with the disk cloning. We ran our experiments in a virtual machine (VirtualBox v. 4.1.8) set up with three disks: a source disk (disk 1), with a Windows XP system on two partitions, a target disk (disk 2) and a temporary disk for backup (disk 3). Table 1 gives details about our three test disks. The following chapters give more details about the process which is not complicated. Somewhat lengthy if the source disk is big and holds much data, but not complicated at all.
4/12
partitions Partition 1: 19.58 GiB, primary, NTFS, boot Partition 2: 10.42 GiB, primary, NTFS Partition 1: 14.65 GiB, primary, NTFS, boot Partition 2: 9.77 GiB, primary, NTFS One single partition, any Clonezilla supported file system (FAT, ext, NTFS, etc.)
5/12
Preparing source disk Defragmenting (MS Windows) Partition shrinking (GParted) Second partition moving (GParted) System checks (MS Windows) Preparing target disk Partitioning (GParted) Direct cloning (Clonezilla) Cloning sda1 Cloning sda2 Imaging (Clonezilla) Image creation Image restoration Overall, in case of direct cloning Overall, using a temporary storage Table 2: Process duration on the Windows test system
Please note that:
50 minutes 15 minutes 2 minutes 25 minutes 5 minutes 5 minutes 5 minutes minutes minutes minutes minutes minutes minutes minutes minutes
The delays noted here are highly dependant on the actual data on disk. Processing non-Windows systems will skip some operations and will be shorter. The partition move is certainly the longest operation. The actual amount of data on sda2 implies the length of that process.
6/12
When the defragmentation is over, we may process the partitions. B. Source Partition Processing Using some dedicated tool well now process the source disk partitions without destroying the data they carry. GNU/Linux distributions most often come with such a tool. GParted is very well known but our distro might offer some alternative. Windows systems never propose that kind of tool. In this situation, well resort to using GParted that comes on the PartedMagic live CD. Figure 3 shows the source disk geometry before the cloning, as displayed by GParted.
Partitions Shrinking
We can see that the free space remaining in each partition allows shrinking them without hassle. Well shrink successively: sda1 from 19.58 to 14.65 GiB (15,000 MiB), sda2 from 10.42 to 9.77 GiB (10,000 MiB),
7/12
which gives a total new size of 24.42 GiB. We get the new geometry displayed at figure 4.
Partition Moving
We notice that some new unallocated areas have appeared because of the shrinking. We now have to adjust both partitions in order to suppress the unallocated interval between them.
Figure 5: The source disk partitions are now ready for cloning
For that, using the same tool, we move sda2 to the left so that the interval becomes null. Figure 5 shows the final state.
Be Patient! The move operation is, by far, the longest one in the overall process. Depending upon the amount of data, this can take much more than an hour (in our example it took 25 minutes to move sda2).
If the partitions hold NTFS filesystems (MS Windows), we must check each of the partitions. Clonezilla wont process any unchecked NTFS-formatted partition. As re-dimensioning a partition implies a check during the next Windows start up, lets start the machine once again! 2
2 This operation may be forced issuing the Windows shell command: chkdsk <disk:> -f eg: chkdsk c: -f
8/12
Figure 6: The target disk has the same geometry as the source
Direct cloning requires to clone one partition at a time. We cant clone several partitions at once, which is possible using the second method, explained below at chapter 3.2. We first select the source partition (sda1) then the target (here sdb1) and we accept all default values. The process executes (figure 7). In the end, we select (3) Start over to start again and process the second partition in the same way.
9/12
Using The Target Disk Once the cloning of a Windows system is over, it is mandatory to disconnect one of the disks from the machine. Otherwise, MS Windows would be disturbed when finding two identical disks therefore refusing to boot.
3 As a reference, our Windows XP sp3 install and some more software give a 3,06 GiB image.
10/12
4. Windows FAQ
A common problem to many cloning schemes is a cloned Windows operating system wont boot on the cloned disk. MS Windows systems are very sensitive to any hardware change and may be highly disturbed by a new disk structure. Here are three questions that come over and over, with links to the answers on the Clonezilla web site FAQ pages. A. After I Did A Disk-to-disk Clone, My MS Windows In The Source Disk Fails To Boot. Why? Did you leave both disks into the machine? http://drbl.org/faq/fine-print.php? path=./2_System/111_disk_to_disk_fail_boot_MS_win.faq#111_disk_to_disk_fail_boot_ MS_win.faq B. After The Image Is Restored To Another Machine, It Fails To Boot. The Error Message Is Missing Operating System Or Just A Blinking Underscore Usually this is because GNU/Linux and MS Windows interpret the CHS (cylinder, head, sector) value of hard drives differently. Some possible solutions are given here: http://drbl.org/faq/fine-print.php? path=./2_System/23_Missing_OS.faq#23_Missing_OS.faq C. I Get An Error 0xc00000e : Can't Run WINLOAD.EXE (or 0xc0000425) After Restoring A Windows7 Image Heres the solution: http://drbl.org/faq/fine-print.php? path=./2_System/86_Win_7_0xc00000e_error.faq#86_Win_7_0xc00000e_error.faq
5. References
Heres some information about the tools weve been using throughout this document. At the web addresses below, youll find more resources and information: downloads, help and documentation, etc. Clonezilla Live PartedMagic VirtualBox http://www.clonezilla.org/ http://partedmagic.com/doku.php?id=start https://www.virtualbox.org/
11/12
6. Credits
Author: Jean-Francois Nifenecker, jean-francois.nifenecker@laposte.net Acknowledgements: to Steven Shiau and the Clonezilla Team, also to the members of the Clonezilla forums who gave feedback. Translation:
Modification History
Comments First draft for proofreading Second draft with some additions and corrections
7. License
This Document is subject to the conditions of the Creative Commons license, options BY-NC-SA v.3.0. For more information, refer to: http://creativecommons.org/licenses/by-nc-sa/3.0/
12/12