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