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