This question is related to one from several years ago, where I was looking for a way to do a partial image backup. That piece of it was never answered, so this is a dedicated question for it.
The Problem
I planned to shrink a Windows partition and wanted to first make an image backup, as insurance. If recovery was required, the backup would need to be restored to the shrunken partition.
Since the purpose was insurance for the system as-is, the backup had to be the "virgin" contents, prior to any kind of modification that would change anything or introduce any new risks.
The Windows partition shrink tool tells you ahead of time how much it will shrink the partition. I wanted an image of only the portion of the partition that would remain after shrinkage.
I had a file-based backup, so I was not concerned about any files that might be outside the shrink area and potentially not captured by the backup.
Solution Concept
Conventional wisdom says that these requirements can't be met using dd. However, knowing just enough to be dangerous, there is an approach that seems like it ought to be a solution (I'm assuming a dd-based solution would be performed from within Linux).
The idea:
ddhas parameters available to specify starting and ending locations.- Any partition management tool will reveal where that partition sits on the drive.
- The Windows partition shrink tool displays how much it will shrink the Windows partition.
That would seem to be the raw material for calculating the dd parameters. Putting the pieces together is something I haven't done before. So the question is:
- how to determine the
ddparameters reflecting the shrunken portion of the partition - the
ddcommand to copy that relevant portion to a backup drive - the
ddcommand to restore that image to the same place on the original drive
Caveat
Defining and copying a desired section of a partition off bare metal looks like it ought to be straightforward. However, one point that isn't clear is whether the NTFS MFT is tied to the original partition size, so that restoring it to the shrunken partition would leave it corrupted, at least beyond the ability of something like chkdsk to repair.
Question Objective
The ultimate objective is to create a partial image backup of a Windows partition as described. This problem never attracted solutions in the original question, so this question is intended to offer the seed of a potential approach. However, my concept may not work. Thus, while a dd solution is the focus of this question, I wouldn't preclude an alternative solution using built-in or commonly available free tools. So a successful answer can be:
- A working
dd-based solution - An authoritative and definitive explanation of why a
dd-based solution cannot possibly work (or at least cannot be trusted to work reliably) - An alternative solution that accomplishes the objectives.
Addendum
Kamil Maciorowski's answer identifies another question, Clone only space in use from hard disk, that is fairly similar, but I don't believe it is a duplicate. Some key differences:
- That question seeks to clone only used space. This one seeks to clone a specific section of a partition.
- That question doesn't have any particular constraints on getting to the result. This one requires that the image be of the pristine current state, with no alteration of, or risk to, the content, which precludes any type of "preparation".
- That question is about an entire drive and a Linux filesystem. This one is about a section of a partition and NTFS.