]> wimlib.net Git - wimlib/blob - doc/imagex-apply.1.in
Generalized support for referencing resources in external WIMs
[wimlib] / doc / imagex-apply.1.in
1 .TH WIMLIB-IMAGEX "1" "August 2013" "@IMAGEX_PROGNAME@ @VERSION@" "User Commands"
2 .SH NAME
3 @IMAGEX_PROGNAME@-apply \- Extract one image, or all images, from a WIM archive
4 .SH SYNOPSIS
5 \fB@IMAGEX_PROGNAME@ apply\fR \fIWIMFILE\fR [\fIIMAGE\fR] \fITARGET\fR [\fIOPTION\fR...]
6 .SH DESCRIPTION
7 \fB@IMAGEX_PROGNAME@ apply\fR extracts an image, or all images, from the Windows
8 Imaging (WIM) file \fIWIMFILE\fR.  This command is also available as simply
9 \fBwimapply\fR if the appropriate hard link or batch file has been installed.
10 .PP
11 This command is designed to extract, or "apply", one or more full WIM images.
12 If you instead want to extract only certain files or directories contained in a
13 WIM image, consider using \fB@IMAGEX_PROGNAME@ extract\fR or
14 \fB@IMAGEX_PROGNAME@ mount\fR instead.  (\fB@IMAGEX_PROGNAME@ mount\fR is not
15 supported on Windows.)
16 .PP
17 \fIIMAGE\fR specifies the WIM image in \fIWIMFILE\fR to extract.  It may be a
18 1-based index of an image in \fIWIMFILE\fR, the name of an image in
19 \fIWIMFILE\fR, or the keyword "all" to indicate that all images in \fIWIMFILE\fR
20 are to be extracted.  Use the \fB@IMAGEX_PROGNAME@ info\fR (1) command to show
21 what images a WIM file contains.  \fIIMAGE\fR may be omitted if \fIWIMFILE\fR
22 contains only one image.
23 .PP
24 \fITARGET\fR specifies where to extract the WIM image to.  If \fITARGET\fR
25 specifies a directory, the WIM image is extracted to that directory (see
26 \fBDIRECTORY EXTRACTION (UNIX)\fR or \fBDIRECTORY EXTRACTION (WINDOWS)\fR).
27 Similarly, if \fITARGET\fR specifies a non-existent file, a directory is created
28 in that location and the WIM image is extracted to that directory.
29 .PP
30 If \fIIMAGE\fR is specified as "all", then all the images in \fIWIMFILE\fR are
31 actually extracted into subdirectories of \fITARGET\fR, each of which is given
32 the name of the corresponding image, falling back to the image index in the case
33 of an image with no name or a name not valid as a filename.
34 .PP
35 Alternatively, on UNIX-like systems only, if \fITARGET\fR specifies a regular
36 file or block device, it is interpreted as an NTFS volume to which the WIM image
37 is to be extracted (see \fBNTFS VOLUME EXTRACTION (UNIX)\fR).  Only a single
38 image can be extracted in this mode, and only extracting to the root of the NTFS
39 volume (not a subdirectory thereof) is supported.
40 .PP
41 \fIWIMFILE\fR may be "-" to read the WIM from standard input rather than from a
42 file, but see \fBPIPABLE WIMS\fR for more information.
43 .PP
44 \fB@IMAGEX_PROGNAME@ apply\fR supports applying images from stand-alone WIMs as
45 well as split WIMs.  See \fBSPLIT WIMS\fR.
46 .SH DIRECTORY EXTRACTION (UNIX)
47 This section documents how \fB@IMAGEX_PROGNAME@ apply\fR (and also
48 \fB@IMAGEX_PROGNAME@ extract\fR) extract a WIM image (or a possibly a subset
49 thereof, in the case of \fB@IMAGEX_PROGNAME@ extract\fR) to a directory on
50 UNIX-like systems.  See \fBDIRECTORY EXTRACTION (WINDOWS)\fR for the
51 corresponding documentation for Windows.
52
53 As mentioned, a WIM image can be applied to a directory on a UNIX-like system by
54 providing a \fITARGET\fR directory.  However, it is important to keep in mind
55 that the WIM format was designed for Windows, and as a result WIM files can
56 contain data or metadata that cannot be represented on UNIX-like systems.  The
57 main information that \fB@IMAGEX_PROGNAME@\fR will \fInot\fR be able to extract
58 on UNIX-like systems is the following:
59 .IP \[bu] 4
60 Windows security descriptors (which include the file owner, group, and ACLs).
61 .IP \[bu]
62 Named data streams.
63 .IP \[bu]
64 Reparse points other than symbolic links and junction points.
65 .IP \[bu]
66 Certain file attributes such as compression, encryption, and sparseness.
67 .IP \[bu]
68 Short (DOS) names for files.
69 .IP \[bu]
70 File creation timestamps.
71 .PP
72 Notes: Unsupported data and metadata is simply not extracted, but
73 \fB@IMAGEX_PROGNAME@\fR will attempt to warn you when the contents of the WIM
74 image can't be exactly represented when extracted.  Last access and last
75 modification timestamps are specified to 100 nanosecond granularity in the WIM
76 file, but will only be extracted to the highest precision supported by the
77 underlying operating system, C library, and filesystem.  Compressed files will
78 be extracted as uncompressed, while encrypted files will not be extracted at
79 all.
80 .SH NTFS VOLUME EXTRACTION (UNIX)
81 This section documents how \fB@IMAGEX_PROGNAME@ apply\fR extracts a WIM image
82 directly to an NTFS volume image on UNIX-like systems.  See \fBDIRECTORY EXTRACTION
83 (WINDOWS)\fR for the corresponding documentation for Windows.
84 .PP
85 As mentioned, \fB@IMAGEX_PROGNAME@\fR running on a UNIX-like system can apply a
86 WIM image directly to an NTFS volume by specifying \fITARGET\fR as a regular file
87 or block device containing an NTFS filesystem.  The NTFS filesystem need not be
88 empty, although it's expected that it be empty for the intended use cases.  A
89 new NTFS filesystem can be created using the \fBmkntfs\fR(8) command provided
90 with \fBntfs-3g\fR.
91 .PP
92 In this NTFS volume extraction mode, the WIM image is extracted to the root of
93 the NTFS volume in a way preserves almost all information contained in the WIM
94 image.  It therefore does not suffer from the limitations described in
95 \fBDIRECTORY EXTRACTION (UNIX)\fR.  This support relies on libntfs-3g to write
96 to the NTFS volume and handle NTFS-specific and Windows-specific data.
97 .PP
98 Please note that this NTFS volume extraction mode is \fInot\fR entered if
99 \fITARGET\fR is a directory, even if an NTFS filesystem is mounted on
100 \fITARGET\fR.  You must specify the NTFS volume itself (and it must be
101 unmounted, and you must have permission to write to it).
102 .PP
103 This NTFS volume extraction mode attempts to extract as much information as
104 possible, including:
105 .IP \[bu] 4
106 All data streams of all files, including the unnamed data stream as well as all
107 named data streams.
108 .IP \[bu]
109 Reparse points, including symbolic links, junction points, and other reparse
110 points.
111 .IP \[bu]
112 File and directory creation, access, and modification timestamps, using the
113 native NTFS resolution of 100 nanoseconds.
114 .IP \[bu]
115 Windows security descriptors, including all components (owner, group, DACL, and
116 SACL).
117 .IP \[bu]
118 DOS/Windows file attribute flags.
119 .IP \[bu]
120 All names of all files, including names in the Win32 namespace, DOS namespace,
121 Win32+DOS namespace, and POSIX namespace.  This includes hard links.
122 .PP
123 However, there are also several known limitations of the NTFS volume extraction
124 mode:
125 .IP \[bu] 4
126 Encrypted files will not be extracted.
127 .IP \[bu]
128 Although sparse file attributes will be applied, the full data will be extracted
129 to each sparse file, so extracted "sparse" files may not actually contain any
130 sparse regions.
131 .PP
132 Regardless, since almost all information from the WIM image is restored in this
133 mode, it is possible to restore an image of an actual Windows installation using
134 \fB@IMAGEX_PROGNAME@\fR on UNIX-like systems in addition to with
135 \fB@IMAGEX_PROGNAME@\fR on Windows.  In the examples at the end of this manual
136 page, there is an example of applying an image from the "install.wim" file
137 contained in the installation media for Windows Vista, Windows 7, and Windows 8
138 in the "sources" directory.
139 .PP
140 But in order to actually boot Windows from an applied image, you must understand
141 the boot process of Windows versions Vista and later.  Basically, it is the
142 following:
143 .nr step 1 1
144 .IP \n[step]. 3
145 The Master Boot Record loads the Volume Boot Record (also called the Boot
146 Sector) of the active partition, which is on an NTFS filesystem.  This partition
147 is called the "system partition".
148 .IP \n+[step].
149 The "bootmgr" program on the "system partition" is loaded (\\BOOTMGR).
150 .IP \n+[step].
151 bootmgr loads the Boot Configuration Data (\\Boot\\BCD) from the "system
152 partition".
153 .IP \n+[step].
154 Based on the information contained in the Boot Configuration Data, a loader for
155 the Windows kernel is executed from the "Boot" partition, which is where Windows
156 is installed.
157 .PP
158 So let's say you applied an image from an existing "install.wim" as in the
159 example, or you've applied a custom Windows image that you've created using the
160 \fB@IMAGEX_PROGNAME@ capture\fR (1) command.  You've just applied the "Boot" partition, or
161 the main Windows partition, but there is no "System" partition yet (i.e.  no
162 \\BOOTMGR and no \\Boot\\BCD).
163 .PP
164 A "System" partition can be created created by running the "bcdboot.exe" program
165 from within Windows or Windows PE.  Alternatively, you can capture a separate
166 WIM image containing the "System" partition.  Or, the "System" partition may the
167 same as the "Boot" partition, so the two "partitions" may be combined in one WIM
168 image.  However, as the \\Boot\\BCD file contains the Windows bootloader
169 configuration, a WIM containing it can only be used on systems where you are
170 setting up the same bootloader configuration, including the same partition
171 layout.
172 .PP
173 Besides setting up the files on the "System" partition, don't forget to set the
174 bootable flag on it, and have a master boot record that loads the bootable
175 partition (Windows' MBR does, and SYSLINUX provides an equivalent MBR).
176 .SH DIRECTORY EXTRACTION (WINDOWS)
177 On Windows, \fB@IMAGEX_PROGNAME@ apply\fR and \fB@IMAGEX_PROGNAME@ extract\fR
178 natively support Windows-specific and NTFS-specific data.  For best results, the
179 target directory should be located on an NTFS volume and \fB@IMAGEX_PROGNAME@\fR
180 should be run with Administrator privileges; however, non-NTFS filesystems and
181 running without Administrator privileges are also supported.
182 .PP
183 On Windows, \fB@IMAGEX_PROGNAME@ apply\fR and \fB@IMAGEX_PROGNAME@ extract\fR
184 try to extract as much data and metadata as possible, including:
185 .IP \[bu] 4
186 All data streams of all files.  This includes the default file contents, as well
187 as named data streams if supported by the target volume.
188 .IP \[bu]
189 Reparse points, including symbolic links, junction points, and other reparse
190 points, if supported by the target volume.  (Note: see \fB--rpfix\fR and
191 \fB--norpfix\fR for documentation on exactly how absolute symbolic links and
192 junctions are extracted.)  However, as per the default security settings of
193 Windows, it is impossible to create a symbolic link or junction point without
194 Administrator privileges; therefore, you must run \fB@IMAGEX_PROGNAME@\fR as the
195 Administrator if you wish to fully restore an image containing symbolic links
196 and/or junction points.  (Otherwise, merely a warning will be issued when a
197 symbolic link or junction point cannot be extracted due to insufficient
198 privileges.)
199 .IP \[bu]
200 File and directory creation, access, and modification timestamps, to the highest
201 resolution supported by the target volume.
202 .IP \[bu]
203 Security descriptors, if supported by the filesystem and \fB--no-acls\fR is not
204 specified.  Furthermore, unless \fB--strict-acls\fR is specified, the security
205 descriptors for individual files or directories may be omitted or only partially
206 set if the user does not have permission to set them, which can be a problem if
207 \fB@IMAGEX_PROGNAME@\fR is run as a non-Administrator.
208 .IP \[bu]
209 File attributes, including hidden, sparse, compressed, encrypted, etc, when
210 supported by the filesystem.
211 .IP \[bu]
212 DOS names (8.3) names of files; however, the failure to set them is not
213 considered an error condition.
214 .IP \[bu]
215 Hard links, if supported by the filesystem.
216 .PP
217 Additional notes about extracting files on Windows:
218 .IP \[bu] 4
219 \fB@IMAGEX_PROGNAME@\fR will issue a warning when it is unable to extract the
220 exact metadata and data of the WIM image, for example due to features mentioned
221 above not being supported by the target filesystem.
222 .IP \[bu]
223 Since encrypted files (with FILE_ATTRIBUTE_ENCRYPTED) are not stored in
224 plaintext in the WIM image, \fB@IMAGEX_PROGNAME@\fR cannot restore encrypted
225 files to filesystems not supporting encryption.  Therefore, such files are not
226 extracted.  Furthermore, even if encrypted files are restored to a filesystem
227 that supports encryption, they will only be decryptable if the decryption key is
228 available.
229 .IP \[bu]
230 Files with names that cannot be represented on Windows will not
231 be extracted by default; see \fB--include-invalid-names\fR.
232 .IP \[bu]
233 Files with full paths over 260 characters (MAX_PATH) are extracted by using the
234 \\\\?\\-prefixed path hack.  But beware that such files will be inaccessible to
235 most Windows software and may not be able to be deleted easily.
236 .SH SPLIT WIMS
237 You may use \fB@IMAGEX_PROGNAME@ apply\fR to apply images from a split WIM.  The
238 \fIWIMFILE\fR argument must specify the first part of the split WIM, while the
239 additional parts of the split WIM must be specified in one or more
240 \fB--ref\fR="\fIGLOB\fR" options.  Since globbing is built into the \fB--ref\fR
241 option, typically only one \fB--ref\fR option is necessary.  For example, the
242 names for the split WIM parts usually go something like:
243 .RS
244 .PP
245 .nf
246 mywim.swm
247 mywim2.swm
248 mywim3.swm
249 mywim4.swm
250 mywim5.swm
251 .RE
252 .fi
253 .PP
254 To apply the first image of this split WIM to the directory "dir", run:
255 .PP
256 .RS
257 @IMAGEX_PROGNAME@ apply mywim.swm 1 dir --ref="mywim*.swm"
258 .RE
259 .PP
260 As a special case, if you are applying an image from standard input from a split
261 WIM that is also pipable (as described in \fBPIPABLE WIMS\fR), the \fB--ref\fR
262 option is unneeded; instead you must ensure that all the split WIM parts are
263 concatenated together on standard input.  They can be provided in any order,
264 with the exception of the first part, which must be first.
265 .SH PIPABLE WIMS
266 As of wimlib 1.5.0, \fB@IMAGEX_PROGNAME@ apply\fR supports applying a WIM from a
267 nonseekable file, such as a pipe, provided that the WIM was captured with
268 \fB--pipable\fR (see \fB@IMAGEX_PROGNAME@ capture\fR(1)).  To use standard input
269 as the WIM, specify "-" as \fIWIMFILE\fR.  A useful use of this ability is to
270 apply an image from a WIM while streaming it from a webserver; for example, to
271 apply the first image from a WIM file to an NTFS volume on /dev/sda1:
272 .PP
273 .RS
274 wget -O - http://myserver/mywim.wim | wimapply - 1 /dev/sda1
275 .RE
276 .PP
277 (The above also used the \fBwimapply\fR abbreviation for \fB@IMAGEX_PROGNAME@
278 apply\fR.) Note: WIM files are \fInot\fR pipable by default; you have to
279 explicitly capture them with \fB--pipable\fR, and they are \fInot\fR compatible
280 with Microsoft's software.  See \fB@IMAGEX_PROGNAME@ capture\fR(1) for more
281 information.
282 .PP
283 It is possible to apply an image from a pipable WIM split into multiple parts;
284 see \fBSPLIT WIMS\fR.
285 .SH OPTIONS
286 .TP 6
287 \fB--check\fR
288 When reading \fIWIMFILE\fR, verify its integrity if the integrity table is
289 present.
290 .TP
291 \fB--ref\fR="\fIGLOB\fR"
292 File glob of additional WIMs or split WIM parts to reference resources from.
293 See \fBSPLIT_WIMS\fR.  This option can be specified multiple times.  Note:
294 \fIGLOB\fR is listed in quotes because it is interpreted by
295 \fB@IMAGEX_PROGNAME@\fR and may need to be quoted to protect against shell
296 expansion.
297 .TP
298 \fB--rpfix\fR, \fB--norpfix\fR
299 Set whether to fix targets of absolute symbolic links (reparse points in Windows
300 terminology) or not.  When enabled (\fB--rpfix\fR), extracted absolute symbolic
301 links that are marked in the WIM image as being fixed are assumed to have
302 absolute targets relative to the image root, and therefore have the actual root
303 of extraction prepended to their targets.  The intention is that you can apply
304 an image containing absolute symbolic links and still have them be valid after
305 it has been applied to any location.
306 .IP ""
307 The default behavior is \fB--rpfix\fR if any images in \fIWIMFILE\fR have been
308 captured with reparse-point fixups done.  Otherwise, it is \fB--norpfix\fR.
309 .IP ""
310 Reparse point fixups are never done in the NTFS volume extraction mode on
311 UNIX-like systems.
312 .IP ""
313 \fB--verbose\fR
314 Print the path to of each file or directory within the WIM image as it is
315 extracted.
316 .TP
317 \fB--hardlink\fR
318 When extracting a file from the WIM that is identical to a file that has already
319 extracted, create a hard link rather than creating a separate file.  This option
320 causes all identical files to be hard-linked, overriding the hard link groups
321 that are specified in the WIM image(s).  In the case of extracting all images
322 from the WIM, files may be hard-linked even if they are in different WIM images.
323 .IP ""
324 However, hard-linked extraction mode does have some additional quirks.  Named
325 data streams will not be extracted, and files can be hard linked even if their
326 metadata is not fully consistent.
327 .TP
328 \fB--symlink\fR
329 This option is similar to \fB--hardlink\fR, except symbolic links are created
330 instead.
331 .TP
332 \fB--unix-data\fR
333 (UNIX-like systems only)  By default, in the directory extraction mode on UNIX,
334 \fB@IMAGEX_PROGNAME@ apply\fR will ignore both Windows-style security
335 descriptors and UNIX-specific file owners, groups, and modes set when using
336 \fB@IMAGEX_PROGNAME@ capture\fR with the \fB--unix-data\fR flag.  By passing
337 \fB--unix-data\fR to \fB@IMAGEX_PROGNAME@ apply\fR instead, this causes this
338 UNIX-specific data to be restored when available.  However, by default, if
339 \fB@IMAGEX_PROGNAME@\fR does not have permission to set the UNIX owner, group or
340 file mode on an extracted file, a warning will be printed and it will not be
341 considered an error condition; use \fB--strict-acls\fR to get stricter behavior.
342 .TP
343 \fB--no-acls\fR
344 Do not restore security descriptors on extracted files and directories.
345 .TP
346 \fB--strict-acls\fR
347 Fail immediately if the full security descriptor of any file or directory cannot
348 be set exactly as specified in the WIM file.  On Windows, the default behavior
349 without this option is to fall back to setting a security descriptor with the
350 SACL omitted, then only the default inherited security descriptor, if
351 \fB@IMAGEX_PROGNAME@\fR does not have permission to set the desired one.  Also,
352 on UNIX-like systems, this flag can also be combined with \fB--unix-data\fR to
353 cause \fB@IMAGEX_PROGNAME@\fR to fail immediately if the UNIX owner, group, or
354 mode on an extracted file cannot be set for any reason.
355 .TP
356 \fB--include-invalid-names\fR
357 Extract files and directories with invalid names by replacing characters and
358 appending a suffix rather than ignoring them.  The meaning of this is
359 platform-dependent.
360 .IP "" 6
361 On POSIX-compliant systems, filenames are case-sensitive and may contain any
362 byte except '\\0' and \'/', so on a POSIX-compliant system this option will only
363 have an effect in the unlikely case that the WIM image for some reason has a
364 filename containing one of these characters.
365 .IP "" 6
366 On Windows, filenames are case-insensitive, cannot include the characters '/',
367 \'\\0', '\\', ':', '*', '?', '"', '<', '>', or '|', and cannot end with a space
368 or period.  Ordinarily, files in WIM images should meet these conditions as
369 well. However, it is not guaranteed, and in particular a WIM image captured with
370 \fB@IMAGEX_PROGNAME@\fR on a POSIX-compliant system could contain such files.  By
371 default, invalid names will be ignored, and if there are multiple names
372 differing only in case, one will be chosen to extract arbitrarily; however, with
373 \fB--include-invalid-names\fR, all names will be sanitized and extracted in some
374 form.
375 .SH NOTES
376 \fB@IMAGEX_PROGNAME@ apply\fR calculates the SHA1 message digest of every file
377 stream it extracts and verifies that it is the same as the SHA1 message digest
378 provided in the WIM file.  It is an error if the message digests don't match.
379 It's also considered to be an error if any WIM resources that need to be
380 extracted cannot be found in the stream lookup table.  So you can be fairly
381 certain that the file streams are extracted correctly, even though
382 \fB@IMAGEX_PROGNAME@ apply\fR don't have a \fB/verify\fR option like Microsoft's
383 ImageX does.  Note that this is separate from the integrity table of the WIM,
384 which provides SHA1 message digests over raw chunks of the entire WIM file and
385 is checked separately if the \fB--check\fR option is specified.
386 .SH EXAMPLES
387 Extract the first image from the Windows PE image on the Windows Vista/7/8
388 installation media to the directory "boot":
389 .RS
390 .PP
391 @IMAGEX_PROGNAME@ apply /mnt/windows/sources/boot.wim 1 boot
392 .RE
393 .PP
394 Same as above, but using the \fBwimapply\fR abbreviation:
395 .RS
396 .PP
397 wimapply /media/windows/sources/boot.wim 1 boot
398 .RE
399 .PP
400 On Windows, apply an image of an entire volume, for example from "install.wim"
401 which can be found on the Windows Vista/7/8 installation media:
402 .RS
403 .PP
404 @IMAGEX_PROGNAME@ apply install.wim 1 E:\\
405 .RE
406 .PP
407 Same as above, but running on a UNIX-like system where the corresponding
408 partition is /dev/sda2:
409 .RS
410 .PP
411 @IMAGEX_PROGNAME@ apply install.wim 1 /dev/sda2
412 .RE
413 .PP
414 Note that before running either of the above commands, an NTFS filesystem may
415 need to be created on the partition, for example with format.exe on Windows or
416 \fBmkntfs\fR(8) (part of NTFS-3g) on UNIX-like systems.  For example, you might
417 run:
418 .RS
419 .PP
420 mkntfs /dev/sda2 && wimapply install.wim 1 /dev/sda2
421 .RE
422 .PP
423 (Of course don't do that if you don't want to destroy all existing data on the
424 partition!)
425 .PP
426 An example of applying a pipable WIM from a pipe can be found in \fBPIPABLE
427 WIMS\fR, and an example of applying a split WIM can be found in \fBSPLIT
428 WIMS\fR.
429 .PP
430 And finally, just for fun, a silly way to recursively copy a directory tree
431 \fIsrc\fR to \fIdst\fR (but subject to the documented limitations, e.g.
432 platform and filesystem-dependent, of the capture and apply functionality of
433 \fB@IMAGEX_PROGNAME@\fR):
434 .RS
435 .PP
436 @IMAGEX_PROGNAME@ capture src - | @IMAGEX_PROGNAME@ apply - dst
437 .RE
438 .PP
439 .SH SEE ALSO
440 .BR @IMAGEX_PROGNAME@ (1)
441 .BR @IMAGEX_PROGNAME@-capture (1)
442 .BR @IMAGEX_PROGNAME@-extract (1)
443 .BR @IMAGEX_PROGNAME@-info (1)