Backing Up ntfs paritions

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
s243a
Posts: 2580
Joined: Tue 02 Sep 2014, 04:48
Contact:

Backing Up ntfs paritions

#1 Post by s243a »

I have a windows partition kicking around on one or more older machine that I never use and I need the space for linux stuff. I would like to back up the windows partition in case I need something from it (either windows or some document).

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:
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 as

Code: Select all

    mount -t ntfs -o loop ntfsclone.img /mnt/ntfsclone 
I'm not sure if this technique is a completely risk free approach:
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
Regarding the booting issue workaround. I found the following useful link by digging through the internet archive:
relocntfs - program for adjusting FS start sector on NTFS partitions
This is relevant because:
Usually, 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.
https://linux.die.net/man/8/ntfsclone

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
examples

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 
Note that in the above example the option "--save-image" is used to create the special image format which cannot be mounted. One can presumably leave off this option to create a sparse file instead, which can be mounted (see above). However, it might be more difficult to restore the system from a sparse file. Also, note that not all linux utilities may function as expected with sparse files. From the manpage:
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.
Further reading:
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).

s243a
Posts: 2580
Joined: Tue 02 Sep 2014, 04:48
Contact:

#2 Post by s243a »

P.S. I'm not sure if this stuff is still valid but here is a link on moving your windows to a virtual machine:

How to Convert a Physical Windows or Linux PC to a Virtual Machine

and some related stuff can be found at:
https://www.pearltrees.com/s243a/produc ... id16087054

such as how to download a legal iso for an older version of window. Again, I don't know what information is still valid and I'm posting this to give people clues of how they might back-up their old windows systems to create more space for linux (e.g. puppy)

p310don
Posts: 1492
Joined: Tue 19 May 2009, 23:11
Location: Brisbane, Australia

#3 Post by p310don »

I have used PUDD to create a backup of a windows partition a few times before.

It copies the entire partition at a tar.gz file, which is compressed to half the size of the partition. In my case, I backed up two separate 80gig hard drives of XP installations onto an external hard drive, as 40gig files each.

This on it's own might be the solution for you.

I have also converted those backups into working VDI files for use with Virtualbox.

As PUDD backs up the entire partition, you end up with a lot of wasted space. One of the backups I made actually only had about 10gig of data on it, however, the backup was 40gig, half of the 80gig partition.

I have shrunk the VDI file down to about 10gig at it works fine. I use it regularly for old windows work.

This is from memory, so you might need to fill in some gaps to complete the process....

I booted into Puppy on the XP machines using a live CD.

I then found a drive big enough to copy the backup to. In my case It was a network share. You could also use an external hard drive.

I ran PUDD, found under the utility menu of most Puppies.

Using PUDD, I created the backup. This resulted in a tar.gz file.

I extracted the file to a .img file.

I took that resultant .img file, and ran the conversion using virtualbox's inbuilt utility to convert it to a vdi using this command:

Code: Select all

VBoxManage convertdd input.img output.vdi
This gives you a vdi file to work with virtualbox. Use it to create a virtual machine. In the vbox settings you need to find the box and tick enable io/apic - from there it works.

You'll probably need to re-activate windows as the hardware has changed, but that is actually pretty easy (ring microsoft).

Once you have it working, you can possibly play with it some more using the vboxmanage tool to reduce the size of the vdi on disk. (this involves a defrag, zeroing unused space in the guest, and then using vboxmanage to shrink the vdi to be the size of actual used space)

p310don
Posts: 1492
Joined: Tue 19 May 2009, 23:11
Location: Brisbane, Australia

#4 Post by p310don »

of course, if what you need is only documents etc, then just copy those and be rid of windows. Pretty much everything works in linux

peterw
Posts: 430
Joined: Wed 19 Jul 2006, 12:12
Location: UK

Have a look at fsarchiver

#5 Post by peterw »

Best action is to just make a copy of the important documents from your Home Folder and forget the installation.
You can of course use Clonezilla https://clonezilla.org/ for the whole HD or Partions or if you want an even more compact set of files you could use http://www.fsarchiver.org/
The dd methods are very good but slow because the copy every bit.

Post Reply