I would like the back-up to be as close as possible to the original system but at the same not waste space in my backup due to unused space in the partition.
The tool ntfsclone (manpage), sounds like it will do what I want:
From the manpage:
I'm not sure if this technique is a completely risk free approach:Description
ntfsclone will efficiently clone (copy, save, backup, restore) or rescue an NTFS filesystem to a sparse file, image, device (partition) or standard output. It works at disk sector level and copies only the used data. Unused disk space becomes zero (cloning to sparse file), encoded with control codes (saving in special image format), left unchanged (cloning to a disk/partition) or filled with zeros (cloning to standard output).
ntfsclone can be useful to make backups, an exact snapshot of an NTFS filesystem and restore it later on, or for developers to test NTFS read/write functionality, troubleshoot/investigate users' issues using the clone without the risk of destroying the original filesystem.
The clone, if not using the special image format, is an exact copy of the original NTFS filesystem from sector to sector thus it can be also mounted just like the original NTFS filesystem. For example if you clone to a file and the kernel has loopback device and NTFS support then the file can be mounted asCode: Select all
mount -t ntfs -o loop ntfsclone.img /mnt/ntfsclone
Regarding the booting issue workaround. I found the following useful link by digging through the internet archive:The ntfsclone utility guarantees to make an exact copy of NTFS but it won't deal with booting issues. This is by design: ntfsclone is a filesystem, not system utility. Its aim is only NTFS cloning, not Windows cloning. Hereby ntfsclone can be used as a very fast and reliable build block for Windows cloning but itself it's not enough. You can find useful tips following the related links on the below page
http://wiki.linux-ntfs.org/doku.php?id=ntfsclone
relocntfs - program for adjusting FS start sector on NTFS partitions
This is relevant because:
https://linux.die.net/man/8/ntfscloneUsually, Windows will not be able to boot, unless you copy, move or restore NTFS to the same partition which starts at the same sector on the same type of disk having the same BIOS legacy cylinder setting as the original partition and disk had.
If the goal is to move windows to a different machine or virtual box then it's best to delete and re-install from disks. You can find (legal?) isos of these disks online which you can use to install windows provide you have a valid key.
Anyway, there are two types of output that this program generates. One is an image which is faster and can likely be used to restore the orginal file system. Usage:
Code: Select all
ntfsclone --save-image [OPTIONS] SOURCE
ntfsclone --restore-image [OPTIONS] SOURCE
Code: Select all
#Save an NTFS to a file in the special image format:
ntfsclone --save-image --output backup.img /dev/hda1
#Restore an NTFS from a special image file to its original partition:
ntfsclone --restore-image --overwrite /dev/hda1 backup.img
Further reading:Handling Large Sparse Files
As of today Linux provides inadequate support for managing (tar, cp, gzip, gunzip, bzip2, bunzip2, cat, etc) large sparse files. The only main Linux filesystem having support for efficient sparse file handling is XFS by the XFS_IOC_GETBMAPX ioctl(2). However none of the common utilities supports it. This means when you tar, cp, gzip, bzip2, etc a large sparse file they will always read the entire file, even if you use the "sparse support" options.
http://web.archive.org/web/200801140548 ... =ntfsclone
As a final though perhaps one can write the special image format to a sparse file by using a loop device. I'll have to look into this. Another idea is to restore the image to virtual media (i.e. the hard disk of a virtual machine).