summaryrefslogtreecommitdiff
path: root/ntfsprogs/ntfsclone.8 (plain)
blob: c4f44dadf381b7a6e21281062ed868778531d097
1.\" Copyright (c) 2003\-2005 Richard Russon.
2.\" Copyright (c) 2003\-2006 Szabolcs Szakacsits.
3.\" Copyright (c) 2004 Per Olofsson.
4.\" This file may be copied under the terms of the GNU Public License.
5.\"
6.TH NTFSCLONE 8 "February 2006" "ntfs-3g 2014.2.15"
7.SH NAME
8ntfsclone \- Efficiently clone, image, restore or rescue an NTFS
9.SH SYNOPSIS
10.B ntfsclone
11[\fIOPTIONS\fR]
12.I SOURCE
13.br
14.B ntfsclone \-\-save\-image
15[\fIOPTIONS\fR]
16.I SOURCE
17.br
18.B ntfsclone \-\-restore\-image
19[\fIOPTIONS\fR]
20.I SOURCE
21.br
22.B ntfsclone \-\-metadata
23[\fIOPTIONS\fR]
24.I SOURCE
25.SH DESCRIPTION
26.B ntfsclone
27will efficiently clone (copy, save, backup, restore) or rescue an NTFS
28filesystem to a sparse file, image, device (partition) or standard output.
29It works at disk sector level and
30copies only the used data. Unused disk space becomes zero (cloning to
31sparse file), encoded with control codes (saving in special image format),
32left unchanged (cloning to a disk/partition) or
33filled with zeros (cloning to standard output).
34
35.B ntfsclone
36can be useful to make backups, an exact snapshot of an NTFS filesystem
37and restore it later on, or for developers to test NTFS read/write
38functionality, troubleshoot/investigate users' issues using the clone
39without the risk of destroying the original filesystem.
40
41The clone, if not using the special image format, is an exact copy of the
42original NTFS filesystem from sector to sector thus it can be also mounted
43just like the original NTFS filesystem.
44For example if you clone to a file and the kernel has loopback device and
45NTFS support then the file can be mounted as
46.RS
47.sp
48.B mount \-t ntfs \-o loop ntfsclone.img /mnt/ntfsclone
49.sp
50.RE
51.SS Windows Cloning
52If you want to copy, move or restore a system or boot partition to another
53computer, or to a different disk or partition (e.g. hda1\->hda2, hda1\->hdb1
54or to a different disk sector offset) then you will need to take extra care.
55
56Usually, Windows will not be able to boot, unless you copy, move or restore
57NTFS to the same partition which starts at the same sector on the same type
58of disk having the same BIOS legacy cylinder setting as the original
59partition and disk had.
60
61The ntfsclone utility guarantees to make an exact copy of NTFS but it
62won't deal with booting issues. This is by design: ntfsclone is a
63filesystem, not system utility. Its aim is only NTFS cloning, not Windows
64cloning. Hereby ntfsclone can be used as a very fast and reliable
65build block for Windows cloning but itself it's not enough.
66.SS Sparse Files
67A file is sparse if it has unallocated blocks (holes). The reported size of
68such files are always higher than the disk space consumed by them. The
69.BR du
70command can tell the real disk space used by a sparse file.
71The holes are always read as zeros. All major Linux filesystem like,
72ext2, ext3, reiserfs, Reiser4, JFS and XFS, supports
73sparse files but for example the ISO 9600 CD\-ROM filesystem doesn't.
74.SS Handling Large Sparse Files
75As of today Linux provides inadequate support for managing (tar,
76cp, gzip, gunzip, bzip2, bunzip2, cat, etc) large sparse files.
77The only main Linux filesystem
78having support for efficient sparse file handling is XFS by the
79XFS_IOC_GETBMAPX
80.BR ioctl (2) .
81However none of the common utilities supports it.
82This means when you tar, cp, gzip, bzip2, etc a large sparse file
83they will always read the entire file, even if you use the "sparse support"
84options.
85
86.BR bzip2 (1)
87compresses large sparse files much better than
88.BR gzip (1)
89but it does so
90also much slower. Moreover neither of them handles large sparse
91files efficiently during uncompression from disk space usage point
92of view.
93
94At present the most efficient way, both speed and space\-wise, to
95compress and uncompress large sparse files by common tools
96would be using
97.BR tar (1)
98with the options
99.B \-S
100(handle sparse files "efficiently") and
101.B \-j
102(filter the archive through bzip2). Although
103.BR tar
104still reads and analyses the entire file, it doesn't pass on the
105large data blocks having only zeros to filters and it also avoids
106writing large amount of zeros to the disk needlessly. But since
107.BR tar
108can't create an archive from the standard input, you can't do this
109in\-place by just reading
110.BR ntfsclone
111standard output. Even more sadly, using the \-S option results
112serious data loss since the end of 2004 and the GNU
113.BR tar
114maintainers didn't release fixed versions until the present day.
115.SS The Special Image Format
116It's also possible, actually it's recommended, to save an NTFS filesystem
117to a special image format.
118Instead of representing unallocated blocks as holes, they are
119encoded using control codes. Thus, the image saves space without
120requiring sparse file support. The image format is ideal for streaming
121filesystem images over the network and similar, and can be used as a
122replacement for Ghost or Partition Image if it is combined with other
123tools. The downside is that you can't mount the image directly, you
124need to restore it first.
125
126To save an image using the special image format, use the
127.B \-s
128or the
129.B \-\-save\-image
130option. To restore an image, use the
131.B \-r
132or the
133.B \-\-restore\-image
134option. Note that you can restore images from standard input by
135using '\-' as the
136.I SOURCE
137file.
138.SS Metadata\-only Cloning
139One of the features of
140.BR ntfsclone
141is that, it can also save only the NTFS metadata using the option
142.B \-m
143or
144.B \-\-metadata
145and the clone still will be
146mountable. In this case all non\-metadata file content will be lost and
147reading them back will result always zeros.
148
149The metadata\-only image can be compressed very
150well, usually to not more than 1\-8 MB thus it's easy to transfer
151for investigation, troubleshooting.
152
153In this mode of ntfsclone,
154.B NONE
155of the user's data is saved, including the resident user's data
156embedded into metadata. All is filled with zeros.
157Moreover all the file timestamps, deleted and unused spaces inside
158the metadata are filled with zeros. Thus this mode is inappropriate
159for example for forensic analyses.
160This mode may be combined with \fB\-\-save\-image\fP to create a
161special image format file instead of a sparse file.
162
163Please note, filenames are not wiped out. They might contain
164sensitive information, so think twice before sending such an
165image to anybody.
166.SH OPTIONS
167Below is a summary of all the options that
168.B ntfsclone
169accepts. Nearly all options have two equivalent names. The short name is
170preceded by
171.B \-
172and the long name is preceded by
173.B \-\- .
174Any single letter options, that don't take an argument, can be combined into a
175single command, e.g.
176.B \-fv
177is equivalent to
178.B "\-f \-v" .
179Long named options can be abbreviated to any unique prefix of their name.
180.TP
181\fB\-o\fR, \fB\-\-output\fR FILE
182Clone NTFS to the non\-existent
183.IR FILE .
184If
185.I FILE
186is '\-' then clone to the
187standard output.
188.TP
189\fB\-O\fR, \fB\-\-overwrite\fR FILE
190Clone NTFS to
191.IR FILE ,
192overwriting if exists.
193.TP
194\fB\-s\fR, \fB\-\-save\-image\fR
195Save to the special image format. This is the most efficient way space and
196speed\-wise if imaging is done to the standard output, e.g. for image
197compression, encryption or streaming through a network.
198.TP
199\fB\-r\fR, \fB\-\-restore\-image\fR
200Restore from the special image format specified by
201.I SOURCE
202argument. If the
203.I SOURCE
204is '\-' then the image is read from the standard input.
205.TP
206\fB\-n\fR, \fB\-\-no\-action\fR
207Test the consistency of a saved image by simulating its restoring without
208writing anything. The NTFS data contained in the image is not tested.
209The option \fB\-\-restore\-image\fR must also be present, and the options
210\fB\-\-output\fR and \fB\-\-overwrite\fR must be omitted.
211.TP
212\fB\-\-rescue\fR
213Ignore disk read errors so disks having bad sectors, e.g. dying disks, can be
214rescued the most efficiently way, with minimal stress on them. Ntfsclone works
215at the lowest, sector level in this mode too thus more data can be rescued.
216The contents of the unreadable sectors are filled by character '?' and the
217beginning of such sectors are marked by "BadSectoR\\0".
218.TP
219\fB\-m\fR, \fB\-\-metadata\fR
220Clone
221.B ONLY METADATA
222(for NTFS experts). Only cloning to a (sparse) file is allowed, unless used
223the option \fB\-\-save\-image\fP is also used.
224You can't metadata\-only clone to a device.
225.TP
226\fB\-\-ignore\-fs\-check\fR
227Ignore the result of the filesystem consistency check. This option is allowed
228to be used only with the
229.B \-\-metadata
230option, for the safety of user's data. The clusters which cause the
231inconsistency are saved too.
232.TP
233\fB\-t\fR, \fB\-\-preserve\-timestamps\fR
234Do not wipe the timestamps, to be used only with the
235.B \-\-metadata
236option.
237
238
239.TP
240\fB\-\-new\-serial\fR, or
241.TP
242\fB\-\-new\-half\-serial\fR
243Set a new random serial number to the clone. The serial number is a 64
244bit number used to identify the device during the mounting process, so
245it has to be changed to enable the original file system
246and the clone to be mounted at the same time on the same computer.
247
248The option \fB\-\-new\-half\-serial\fP only changes the upper part of the
249serial number, keeping the lower part which is used by Windows unchanged.
250
251The options \fB\-\-new\-serial\fP and \fB\-\-new\-half\-serial\fP can
252only be used when cloning a file system of restoring from an image.
253
254The serial number is not the volume UUID used by Windows
255to locate files which have been moved to another volume.
256
257.TP
258\fB\-f\fR, \fB\-\-force\fR
259Forces ntfsclone to proceed if the filesystem is marked
260"dirty" for consistency check.
261.TP
262\fB\-q\fR, \fB\-\-quiet\fR
263Do not display any progress-bars during operation.
264.TP
265\fB\-h\fR, \fB\-\-help\fR
266Show a list of options with a brief description of each one.
267.SH EXIT CODES
268The exit code is 0 on success, non\-zero otherwise.
269.SH EXAMPLES
270Clone NTFS on /dev/hda1 to /dev/hdc1:
271.RS
272.sp
273.B ntfsclone \-\-overwrite /dev/hdc1 /dev/hda1
274.sp
275.RE
276Save an NTFS to a file in the special image format:
277.RS
278.sp
279.B ntfsclone \-\-save\-image \-\-output backup.img /dev/hda1
280.sp
281.RE
282Restore an NTFS from a special image file to its original partition:
283.RS
284.sp
285.B ntfsclone \-\-restore\-image \-\-overwrite /dev/hda1 backup.img
286.sp
287.RE
288Save an NTFS into a compressed image file:
289.RS
290.sp
291.B ntfsclone \-\-save\-image \-o \- /dev/hda1 | gzip \-c > backup.img.gz
292.sp
293.RE
294Restore an NTFS volume from a compressed image file:
295.RS
296.sp
297.B gunzip \-c backup.img.gz | \\\\
298.br
299.B ntfsclone \-\-restore\-image \-\-overwrite /dev/hda1 \-
300.sp
301.RE
302Backup an NTFS volume to a remote host, using ssh. Please note, that
303ssh may ask for a password!
304.RS
305.sp
306.B ntfsclone \-\-save\-image \-\-output \- /dev/hda1 | \\\\
307.br
308.B gzip \-c | ssh host 'cat > backup.img.gz'
309.sp
310.RE
311Restore an NTFS volume from a remote host via ssh. Please note, that
312ssh may ask for a password!
313.RS
314.sp
315.B ssh host 'cat backup.img.gz' | gunzip \-c | \\\\
316.br
317.B ntfsclone \-\-restore\-image \-\-overwrite /dev/hda1 \-
318.sp
319.RE
320Stream an image file from a web server and restore it to a partition:
321.RS
322.sp
323.B wget \-qO \- http://server/backup.img | \\\\
324.br
325.B ntfsclone \-\-restore\-image \-\-overwrite /dev/hda1 \-
326.sp
327.RE
328Clone an NTFS volume to a non\-existent file:
329.RS
330.sp
331.B ntfsclone \-\-output ntfs\-clone.img /dev/hda1
332.sp
333.RE
334Pack NTFS metadata for NTFS experts. Please note that bzip2 runs
335very long but results usually at least 10 times smaller archives
336than gzip on a sparse file.
337.RS
338.sp
339.B ntfsclone \-\-metadata \-\-output ntfsmeta.img /dev/hda1
340.br
341.B bzip2 ntfsmeta.img
342.sp
343Or, outputting to a compressed image :
344.br
345.B ntfsclone \-mst \-\-output - /dev/hda1 | bzip2 > ntfsmeta.bz2
346.sp
347.RE
348Unpacking NTFS metadata into a sparse file:
349.RS
350.sp
351.B bunzip2 \-c ntfsmeta.img.bz2 | \\\\
352.br
353.B cp \-\-sparse=always /proc/self/fd/0 ntfsmeta.img
354.sp
355.RE
356.SH KNOWN ISSUES
357There are no known problems with
358.BR ntfsclone .
359If you think you have found a problem then please send an email describing it
360to the development team:
361.nh
362ntfs\-3g\-devel@lists.sf.net
363.hy
364.sp
365Sometimes it might appear ntfsclone froze if the clone is on ReiserFS
366and even CTRL\-C won't stop it. This is not a bug in ntfsclone, however
367it's due to ReiserFS being extremely inefficient creating large
368sparse files and not handling signals during this operation. This
369ReiserFS problem was improved in kernel 2.4.22.
370XFS, JFS and ext3 don't have this problem.
371.hy
372.SH AUTHORS
373.B ntfsclone
374was written by Szabolcs Szakacsits with contributions from Per Olofsson
375(special image format support) and Anton Altaparmakov.
376It was ported to ntfs-3g by Erik Larsson and Jean-Pierre Andre.
377.SH AVAILABILITY
378.B ntfsclone
379is part of the
380.B ntfs-3g
381package and is available at:
382.br
383.nh
384http://www.tuxera.com/community/
385.hy
386.SH SEE ALSO
387.BR ntfsresize (8)
388.BR ntfsprogs (8)
389.BR xfs_copy (8)
390.BR debugreiserfs (8)
391.BR e2image (8)
392