]> wimlib.net Git - wimlib/blob - doc/imagex-apply.1.in
4b1a79aaaa71486284b04028797692d1e9dc0674
[wimlib] / doc / imagex-apply.1.in
1 .TH 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.  \fIWIMFILE\fR may be "-" to read the WIM from
9 standard input, but see \fBPIPABLE WIMS\fR.
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.
15 .PP
16 \fIIMAGE\fR specifies the WIM image to extract.  It may be a 1-based index of an
17 image in the WIM, the name of an image in the WIM, or the keyword "all" to
18 indicate that all images are to be extracted.  Use the \fB@IMAGEX_PROGNAME@
19 info\fR (1) command to show what images a WIM file contains.  \fIIMAGE\fR may be
20 omitted if \fIWIMFILE\fR contains only one image.
21 .PP
22 \fITARGET\fR specifies where to extract the WIM image(s) to.  If \fITARGET\fR
23 specifies a directory, the WIM image(s) are extracted to that directory.  If
24 \fITARGET\fR specifies a non-existent file, a directory is created in that
25 location and the WIM image(s) are extracted to that directory.  Alternatively,
26 on UNIX only, if \fITARGET\fR specifies a regular file or block device, it is
27 interpreted as an NTFS volume to which the WIM image is to be extracted.
28 .PP
29 \fB@IMAGEX_PROGNAME@ apply\fR supports applying images from stand-alone WIMs as
30 well as split WIMs.  See \fBSPLIT WIMS\fR.
31 .SH NORMAL MODE (UNIX)
32 This section documents how files are extracted on UNIX from the WIM image to a
33 directory.  See \fBWINDOWS VERSION\fR for the corresponding documentation for
34 the Windows version.
35 .PP
36 On UNIX, the "normal" extraction mode is entered when \fITARGET\fR is a
37 directory or non-existent file.  If a single WIM image is being extracted, it is
38 extracted with the root directory of the image corresponding to the directory
39 named by \fITARGET\fR; or, if the keyword \fBall\fR is given, the images are
40 extracted into subdirectories of \fITARGET\fR that are be named after the image
41 names, falling back to the image index for an image with no name.  \fITARGET\fR
42 can specify a directory on any type of filesystem.
43 .PP
44 In the "normal" mode of extraction on UNIX, the following information is
45 extracted from the WIM image(s):
46 .IP \[bu] 4
47 The default (unnamed) data stream of each file
48 .IP \[bu]
49 Hard links
50 .IP \[bu]
51 File and directory creation, access, and modification timestamps to the nearest
52 100 nanoseconds, if supported by the underlying filesystem, operating system,
53 and C library
54 .IP \[bu]
55 Symbolic links and junction points.  Drive letters will be stripped.
56 (Note: see \fB--rpfix\fR and \fB--norpfix\fR for documentation on how absolute
57 symbolic links and junctions are applied.)
58 .PP
59 However, in the "normal" mode of extraction on UNIX, the following information
60 will \fInot\fR be extracted from the WIM image(s):
61 .IP \[bu] 4
62 Security descriptors (file permissions) except through the extensions available
63 through the \fB--unix-data\fR option
64 .IP \[bu]
65 The alternate (named) data streams for each file
66 .IP \[bu]
67 Reparse points other than symbolic links and junction points
68 .IP \[bu]
69 Certain file attributes such as compression, encryption, and sparseness.
70 .IP \[bu]
71 Short (DOS) names for files
72 .SH NTFS MODE (UNIX)
73 This section documents how files are extracted directly to an NTFS volume image
74 on UNIX.  See \fBWINDOWS VERSION\fR for the corresponding documentation for the
75 Windows version.
76 .PP
77 On UNIX, a special extraction mode is entered when \fITARGET\fR is a regular
78 file or block device.  If this is the case, \fITARGET\fR is interpreted as an
79 NTFS volume and opened using libntfs-3g.  If successful, the WIM image is
80 extracted to the root of the NTFS volume in a special mode that preserves all
81 information contained in the WIM image.  \fIIMAGE\fR may not be "all" for this
82 action.
83 .PP
84 The NTFS volume does not need to be empty, although it's expected that it be
85 empty for the intended use cases.  A new NTFS filesystem can be created using
86 the \fBmkntfs\fR (8) command.
87 .PP
88 The NTFS extraction mode is not available if wimlib was compiled using the
89 \fB--without-ntfs-3g\fR option.
90 .PP
91 Please note that the NTFS extraction mode is \fInot\fR entered if \fITARGET\fR
92 is a directory, even if an NTFS filesystem is mounted on \fITARGET\fR.  You must
93 specify the NTFS volume itself (and it must be unmounted, and you must have
94 permission to write to it).
95 .PP
96 In the NTFS extraction mode on UNIX, the following information will be extracted
97 from the WIM image:
98 .IP \[bu] 4
99 The data streams of all files, including the un-named data stream as well as all
100 named data streams.
101 .IP \[bu]
102 Reparse points, including symbolic links, junction points, and other reparse
103 points.
104 .IP \[bu]
105 Hard links.
106 .IP \[bu]
107 File and directory creation, access, and modification timestamps are set to the
108 100-nanosecond resolution values specified in the WIM file.
109 .IP \[bu] 4
110 The security descriptor for each file is applied if there is one specified in
111 the WIM.
112 .IP \[bu]
113 File attribute flags are applied.
114 .IP \[bu]
115 Short (DOS) names for files are extracted.  The corresponding long name for each
116 DOS name is made to be a Win32 name.  Any additional names for the file in the
117 same directory are made to be names in the POSIX namespace.
118 .PP
119 However, the extraction of encrypted files is not supported in this mode.
120 .PP
121 Since all (or almost all) information from the WIM image is restored in this
122 mode, it is possible to restore an image of an actual Windows installation using
123 \fB@IMAGEX_PROGNAME@\fR on UNIX in addition to with \fB@IMAGEX_PROGNAME@\fR on
124 Windows.  In the examples at the end of this manual page, there is an example of
125 applying an image from the "install.wim" file contained in the installation
126 media for Windows Vista, Windows 7, and Windows 8 in the "sources" directory.
127 .PP
128 But in order to actually boot Windows from an applied image, you must understand
129 the boot process of Windows versions Vista and later.  Basically, it is the
130 following:
131 .nr step 1 1
132 .IP \n[step]. 3
133 The Master Boot Record loads the Volume Boot Record (also called the Boot
134 Sector) of the active partition, which is on an NTFS filesystem.  This partition
135 is called the "system partition".
136 .IP \n+[step].
137 The "bootmgr" program on the "system partition" is loaded (\\BOOTMGR).
138 .IP \n+[step].
139 bootmgr loads the Boot Configuration Data (\\Boot\\BCD) from the "system
140 partition".
141 .IP \n+[step].
142 Based on the information contained in the Boot Configuration Data, a loader for
143 the Windows kernel is executed from the "Boot" partition, which is where Windows
144 is installed.
145 .PP
146 So let's say you applied an image from an existing "install.wim" as in the
147 example, or you've applied a custom Windows image that you've created using the
148 \fB@IMAGEX_PROGNAME@ capture\fR (1) command.  You've just applied the "Boot" partition, or
149 the main Windows partition, but there is no "System" partition yet (i.e.  no
150 \\BOOTMGR and no \\Boot\\BCD).
151 .PP
152 A "System" partition can be created created by running the "bcdboot.exe" program
153 from within Windows or Windows PE.  Alternatively, you can capture a separate
154 WIM image containing the "System" partition.  Or, the "System" partition may the
155 same as the "Boot" partition, so the two "partitions" may be combined in one WIM
156 image.  However, as the \\Boot\\BCD file contains the Windows bootloader
157 configuration, a WIM containing it can only be used on systems where you are
158 setting up the same bootloader configuration, including the same partition
159 layout.
160 .PP
161 Besides setting up the files on the "System" partition, don't forget to set the
162 bootable flag on it, and have a master boot record that loads the bootable
163 partition (Windows' MBR does, and SYSLINUX provides an equivalent MBR).
164 .SH WINDOWS VERSION
165 The Windows version of \fB@IMAGEX_PROGNAME@ apply\fR acts similarly to the
166 corresponding command of Microsoft's ImageX.  For best results, the target
167 directory should be on an NTFS volume and you should be running with
168 Administrator privileges; however, non-NTFS filesystems and running without
169 Administrator privileges are also supported.
170 .PP
171 On Windows, \fB@IMAGEX_PROGNAME@ apply\fR tries to extract as much data as
172 possible.  This includes:
173 .IP \[bu] 4
174 All data streams of all files.  This includes the default file contents, as well
175 as named data streams if supported by the filesystem.
176 .IP \[bu]
177 Reparse points, including symbolic links, junction points, and other reparse
178 points, if supported by the underlying filesystem.  (Note: see
179 \fB--rpfix\fR and \fB--norpfix\fR for documentation on how absolute symbolic
180 links and junctions are applied.)
181 .IP \[bu]
182 File and directory creation, access, and modification timestamps.
183 .IP \[bu]
184 Security descriptors, if supported by the filesystem and \fB--no-acls\fR is not
185 specified.  Furthermore, unless \fB--strict-acls\fR is specified, the security
186 descriptor for individual files or directories may be omitted or only partially
187 set if the user does not have permission to set them.
188 .IP \[bu]
189 File attributes, including hidden, sparse, compressed, encrypted, etc, when
190 supported by the filesystem.
191 .IP \[bu]
192 DOS names (8.3) names of files; however, the failure to set them is not
193 considered an error condition.
194 .IP \[bu]
195 Hard links, if supported by the filesystem.
196 .PP
197 Additional notes about extracting files on Windows:
198 .IP \[bu] 4
199 Encrypted files will be extracted as raw encrypted data if the filesystem
200 does not support encryption.
201 .IP \[bu]
202 Compressed files and directories (with the compression attribute set) will be
203 extracted as uncompressed if the filesystem does not support transparent
204 compression.
205 .IP \[bu]
206 Files with names that cannot be represented on Windows will not
207 be extracted by default; see \fB--include-invalid-names\fR.
208 .IP \[bu]
209 Files with full paths over 260 characters (MAX_PATH) are extracted by using the
210 \\\\?\\-prefixed path hack.  But beware that such files will be inaccessible to
211 most Windows software and may not be able to be deleted easily.
212 .SH SPLIT WIMS
213 You may use \fB@IMAGEX_PROGNAME@ apply\fR to apply images from a split WIM.  The
214 \fIWIMFILE\fR argument is used to specify the first part of the split WIM, and
215 the \fB--refs\fR="\fIGLOB\fR" option is used to provide a shell-style file glob
216 that specifies the additional parts of the split WIM.  \fIGLOB\fR is expected to
217 be a single string on the command line, so \fIGLOB\fR must be quoted so that it
218 is protected against shell expansion.  \fIGLOB\fR must expand to all parts of
219 the split WIM, except optionally the first part which may either omitted or
220 included in the glob (but the first part MUST be specified as \fIWIMFILE\fR as
221 well).
222 .PP
223 Here's an example.  The names for the split WIMs usually go something like:
224 .RS
225 .PP
226 .nf
227 mywim.swm
228 mywim2.swm
229 mywim3.swm
230 mywim4.swm
231 mywim5.swm
232 .RE
233 .fi
234 .PP
235 To apply the first image of this split WIM to the directory "dir", run:
236 .PP
237 .RS
238 @IMAGEX_PROGNAME@ apply mywim.swm 1 dir --ref="mywim*.swm"
239 .RE
240 .PP
241 As a special case, if you are applying an image from standard input from a split
242 WIM that is also pipable (as described in \fBPIPABLE WIMS\fR), the \fB--ref\fR
243 option is unneeded; instead you must ensure that all the split WIM parts are
244 concatenated together on standard input.  They can be provided in any other,
245 with the exception of the first part, which must be first.
246 .SH PIPABLE WIMS
247 As of wimlib 1.5.0, \fB@IMAGEX_PROGNAME@ apply\fR supports applying a WIM from a
248 nonseekable file, such as a pipe, provided that the WIM was captured with
249 \fB--pipable\fR (see \fB@IMAGEX_PROGNAME@ capture\fR(1)).  To use standard input
250 as the WIM, specify "-" as \fIWIMFILE\fR.  A useful use of this ability is to
251 apply an image from a WIM while streaming it from a webserver; for example, to
252 apply the first image from a WIM file to a NTFS volume on /dev/sda1:
253 .PP
254 .RS
255 wget -O - http://myserver/mywim.wim | @IMAGEX_PROGNAME@ apply - 1 /dev/sda1
256 .RE
257 .PP
258 Note: WIM files are \fInot\fR pipable by default; you have to explicitly capture
259 them with \fB--pipable\fR, and they are \fInot\fR compatible with Microsoft's
260 software.  See \fB@IMAGEX_PROGNAME@ capture\fR(1) for more information.
261 .PP
262 It is possible to apply an image from a pipable WIM split into multiple parts;
263 see \fBSPLIT WIMS\fR.
264 .SH OPTIONS
265 .TP 6
266 \fB--check\fR
267 When reading \fIWIMFILE\fR, verify its integrity if the integrity table is
268 present.
269 .TP
270 \fB--ref\fR="\fIGLOB\fR"
271 File glob of additional split WIM parts that are part of the split WIM being
272 applied.  See \fBSPLIT_WIMS\fR.
273 .TP
274 \fB--rpfix\fR, \fB--norpfix\fR
275 Set whether to fix targets of absolute symbolic links (reparse points in Windows
276 terminology) or not.  When enabled (\fB--rpfix\fR), extracted absolute symbolic
277 links that are marked in the WIM image as being fixed are assumed to have
278 absolute targets relative to the image root, and therefore have the actual root
279 of extraction prepended to their targets.  The intention is that you can apply
280 an image containing absolute symbolic links and still have them be valid after
281 it has been applied to any location.
282 .IP "" 6
283 The default behavior is \fB--rpfix\fR if any images in \fIWIMFILE\fR have been
284 captured with reparse-point fixups done.  Otherwise, it is \fB--norpfix\fR.
285 .IP "" 6
286 Reparse point fixups are never done in the NTFS extraction mode on UNIX.
287 .TP
288 \fB--verbose\fR
289 Print the path to of each file or directory within the WIM image as it is
290 extracted.
291 .TP
292 \fB--hardlink\fR
293 When extracting a file from the WIM that is identical to a file that has already
294 extracted, create a hard link rather than creating a separate file.  This option
295 causes all identical files to be hard-linked, overriding the hard link groups
296 that are specified in the WIM image(s).  In the case of extracting all images
297 from the WIM, files may be hard-linked even if they are in different WIM images.
298 This option is not available in the NTFS extraction mode.
299 .TP
300 \fB--symlink\fR
301 (UNIX only) This option is similar to \fB--hardlink\fR, except symbolic links are created
302 instead.
303 .TP
304 \fB--unix-data\fR
305 (UNIX only)  By default, in the normal extraction mode on UNIX,
306 \fB@IMAGEX_PROGNAME@ apply\fR will ignore both Windows-style security
307 descriptors and UNIX-specific file owners, groups, and modes set when
308 using \fB@IMAGEX_PROGNAME@ capture\fR with the \fB--unix-data\fR flag.
309 By passing \fB--unix-data\fR to \fB@IMAGEX_PROGNAME@ apply\fR instead,
310 this causes this UNIX-specific data to be restored when available.  However, by
311 default, if \fB@IMAGEX_PROGNAME@\fR does not have permission to set the UNIX
312 owner, group or file mode on an extracted file, a warning will be printed and it
313 will not be considered an error condition; use \fB--strict-acls\fR to get
314 stricter behavior.
315 .TP
316 \fB--no-acls\fR
317 (Windows only) Do not restore security descriptors on extracted files and directories.
318 .TP
319 \fB--strict-acls\fR
320 On Windows: Fail immediately if the full security descriptor of any file or
321 directory cannot be set exactly as specified in the WIM file.  The default
322 behavior without this option is to fall back to setting a security descriptor
323 with the SACL omitted, then only the default inherited security descriptor, if
324 we do not have permission to set the desired one.  On UNIX: with
325 \fB--unix-data\fR, fail immediately if the UNIX owner, group, or file mode on an
326 extracted file cannot be set for any reason.
327 .TP
328 \fB--include-invalid-names\fR
329 Extract files and directories with invalid names by replacing characters and
330 appending a suffix rather than ignoring them.  The meaning of this is
331 platform-dependent.
332 .IP "" 6
333 On UNIX, filenames are case-sensitive and may contain any byte except '\\0' and
334 \'/', so on UNIX this option will only have an effect in the unlikely case that
335 the WIM image for some reason has a filename containing one of these characters.
336 .IP "" 6
337 On Windows, filenames are case-insensitive, cannot include the characters '/',
338 \'\\0', '\\', ':', '*', '?', '"', '<', '>', or '|', and cannot end with a
339 space or period.  Ordinarily, files in WIM images should meet these
340 conditions as well. However, it is not guaranteed, and in particular a WIM
341 image captured with \fB@IMAGEX_PROGNAME@\fR on UNIX could contain such files.
342 By default, invalid names will be ignored, and if there are multiple names
343 differing only in case, one will be chosen to extract arbitrarily; however,
344 with \fB--include-invalid-names\fR, all names will be sanitized and
345 extracted in some form.
346 .SH NOTES
347 \fB@IMAGEX_PROGNAME@ apply\fR calculates the SHA1 message digest of every file stream it
348 extracts and verifies that it is the same as the SHA1 message digest provided in
349 the WIM file.  It is an error if the message digests don't match.  It's also
350 considered to be an error if any WIM resources cannot be found in the stream
351 lookup table.  So you can be fairly certain that the file streams are extracted
352 correctly, even though \fB@IMAGEX_PROGNAME@ apply\fR don't have a \fB/verify\fR option like
353 Microsoft's ImageX does.  Please note that this is separate from the integrity
354 table of the WIM, which provides SHA1 message digests over raw chunks of the
355 entire WIM file and is checked separately if the \fB--check\fR option is
356 specified.
357 .SH EXAMPLES
358 .SS Applying a WIM image to a directory (both UNIX and Windows)
359 Extract the first image from the Windows PE image from the Windows Vista/7/8
360 installation media to the directory "boot":
361 .RS
362 .PP
363 @IMAGEX_PROGNAME@ apply /media/windows/sources/boot.wim 1 boot
364 .RE
365 .PP
366 Extract all images from the Windows PE image from the Windows Vista/7/8
367 installation media to the directory "boot", and hard link all identical files:
368 .RS
369 .PP
370 @IMAGEX_PROGNAME@ apply /media/windows8/sources/boot.wim all boot --hardlink
371 .RE
372 .PP
373 .SS Applying a WIM image directly to a NTFS volume image (UNIX only)
374 Apply a WIM image to an NTFS filesystem image:
375 .RS
376 .PP
377 @IMAGEX_PROGNAME@ apply mywim.wim 1 fsimage.ntfs
378 .RE
379 .PP
380 Create a new NTFS filesystem on the partition /dev/sda2 and apply the first
381 image in the Windows Vista/7/8 installation WIM to it.  (Obviously, only do this
382 if you want to erase everything on that partition.)
383 .RS
384 .PP
385 mkntfs /dev/sda2 && @IMAGEX_PROGNAME@ apply /media/windows/sources/install.wim 1 /dev/sda2
386 .RE
387 .SH SEE ALSO
388 .BR @IMAGEX_PROGNAME@ (1)
389 .BR @IMAGEX_PROGNAME@-extract (1)
390 .BR @IMAGEX_PROGNAME@-info (1)