Backup files and MBR of windows partition without cloning whole image
No – it would destroy nearly all metadata that NTFS holds about the file. Most importantly, it'd lose file permissions (ACLs), but it'd also mishandle reparse points (which are more than just symlinks), alternate streams (which are like xattrs), and so on.
(Imagine copying your Linux system to a FAT32 drive. Some files were owned by root, others by special accounts; some were executable or even setuid; FAT32 would lose all that information.)
If you want to make a file-level backup from within Linux, use wimcapture
from wimlib (this is equivalent to the official DISM imaging tool that comes with Windows) and make sure to point it at a raw disk device, so that it could use libntfs-3g to read most of the metadata into a WIM-format archive:
wimcapture /dev/sda1 windows.wim
wimapply windows.wim /dev/sda1
I don't have a 100% guarantee of this working – you might get better results from actual dism /capture-image
, which you can run from any Windows installer USB stick.
dism /capture-image /imagefile:D:\windows.wim /capturedir:C:\
dism /apply-image /imagefile:D:\windows.wim /applydir:C:\
However, there's a simpler method which is to make a block-level backup and only skip the unallocated areas – this can be done using ntfsclone:
ntfsclone -o windows.img /dev/sda1
This will create a sparse file, which only occupies as much space as it contains data, even though on the outside it looks much larger. You can archive it but make sure to use tar --sparse
. Special tools aren't needed to restore this image, just cp
or dd
it back to the partition.
Since ntfsclone copies data at block level, it is guaranteed to work with any Windows version; it only needs to understand the NTFS "allocation bitmap" (which does not change).
Finally, two things about the MBR:
First, it isn't very useful to back up the "boot code" part of the MBR. It contains very generic code and there are tools both on Windows (bootsect.exe) and Linux (ms-sys) which can write a fresh boot code on demand. (Unless you've overwritten it with GRUB already, in which case you can just use grub-install.)
The only useful part you're backing up is the partition table. But you should be using 'sfdisk' to back up the partition table instead making a raw sector copy.
sfdisk --dump /dev/sda > partitions.txt
sfdisk /dev/sda < partitions.txt
Second, new Windows computers do not use the MBR for their boot process. On UEFI-based PCs, the entirety of the bootloader lives in the "EFI System Partition", and the partition table is no longer at sector 0 – it lives at sectors 1–64. (Using sfdisk will correctly capture both the MBR and UEFI/GPT partition table formats.)