File: virt-sysprep.pod

package info (click to toggle)
libguestfs 1%3A1.18.1-1%2Bdeb7u3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 49,156 kB
  • sloc: ansic: 282,408; ml: 22,707; sh: 16,121; perl: 5,946; java: 5,047; cs: 4,329; makefile: 3,191; haskell: 2,564; erlang: 1,510; python: 1,502; xml: 509; ruby: 217; pascal: 142; cpp: 11
file content (444 lines) | stat: -rw-r--r-- 14,672 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
=encoding utf8

=head1 名前

virt-sysprep - 仮想マシンをクローンできるようリセットまたは設定解除

=head1 書式

 virt-sysprep [--options] -d domname

 virt-sysprep [--options] -a disk.img [-a disk.img ...]

=head1 説明

Virt-sysprep "resets" or "unconfigures" a virtual machine so that clones can
be made from it.  Steps in this process include removing SSH host keys,
removing persistent network MAC configuration, and removing user accounts.
Each step can be enabled or disabled as required.

Virt-sysprep modifies the guest or disk image I<in place>.  The guest must
be shut down.  If you want to preserve the existing contents of the guest,
you I<must copy or clone the disk first>.  See L</COPYING AND CLONING>
below.

You do I<not> need to run virt-sysprep as root.  In fact we'd generally
recommend that you don't.  The time you might want to run it as root is when
you need root in order to access the disk image, but even in this case it
would be better to change the permissions on the disk image to be writable
as the non-root user running virt-sysprep.

"Sysprep" stands for "system preparation" tool.  The name comes from the
Microsoft program C<sysprep.exe> which is used to unconfigure Windows
machines in preparation for cloning them.  Having said that, virt-sysprep
does I<not> currently work on Microsoft Windows guests.  We plan to support
Windows sysprepping in a future version, and we already have code to do it.

=head1 オプション

=over 4

=item B<--help>

簡単なヘルプを表示します。

=item B<-a> file

=item B<--add> file

仮想マシンからディスクイメージの I<file> を追加します。

The format of the disk image is auto-detected.  To override this and force a
particular format use the I<--format> option.

=item B<-c> URI

=item B<--connect> URI

libvirt を使用していると、指定された I<URI> に接続します。  省略すると、デフォルトの libvirt ハイパーバイザーに接続します。

ゲストのブロックデバイスを直接指定していると((I<-a>))、libvirt は何も使用されません。

=item B<-d> guest

=item B<--domain> guest

名前付きの libvirt 仮想マシンからすべてのディスクを追加します。  ドメインの UUID が名前の代わりに使用されます。

=item B<-n>

=item B<--dry-run>

Perform a read-only "dry run" on the guest.  This runs the sysprep
operation, but throws away any changes to the disk at the end.

=item B<--enable> operations

Choose which sysprep operations to perform.  Give a comma-separated list of
operations, for example:

 --enable ssh-hostkeys,udev-persistent-net

would enable ONLY C<ssh-hostkeys> and C<udev-persistent-net> operations.

If the I<--enable> option is not given, then we default to trying most
sysprep operations (see I<--list-operations> to show which are enabled).

Regardless of the I<--enable> option, sysprep operations are skipped for
some guest types.

特定のバージョンの virt-sysprep によりサポートされる操作の一覧を表示するには I<--list-operations> を使用します。

See L</OPERATIONS> below for a list and an explanation of each operation.

=item B<--format> raw|qcow2|..

=item B<--format> auto

The default for the I<-a> option is to auto-detect the format of the disk
image.  Using this forces the disk format for I<-a> options which follow on
the command line.  Using I<--format auto> switches back to auto-detection
for subsequent I<-a> options.

例:

 virt-sysprep --format raw -a disk.img

C<disk.img> に対してローイメージを強制します(自動検出しません)。

 virt-sysprep --format raw -a disk.img --format auto -a another.img

C<disk.img> に対してロー形式(自動検知なし)を強制し、C<another.img> に対して自動検知に戻します。

仮想マシンのディスクイメージが信頼できないロー形式であるならば、ディスク形式を指定するためにこのオプションを使用すべきです。これにより、悪意のある仮想マシンにより起こり得るセキュリティ問題を回避できます
(CVE-2010-3851)。

=item B<--list-operations>

virt-sysprep プログラムによりサポートされる操作を一覧表示します。

These are listed one per line, with one or more single-space-separated
fields, eg:

 $ virt-sysprep --list-operations
 bash-history * Remove the bash history in the guest
 cron-spool * Remove user at-jobs and cron-jobs
 dhcp-client-state * Remove DHCP client leases
 dhcp-server-state * Remove DHCP server leases
 [etc]

The first field is the operation name, which can be supplied to
I<--enable>.  The second field is a C<*> character if the operation is
enabled by default or blank if not.  Subsequent fields on the same line are
the description of the operation.

Before libguestfs 1.17.33 only the first (operation name) field was shown
and all operations were enabled by default.

=item B<-q>

=item B<--quiet>

Don't print log messages.

To enable detailed logging of individual file operations, use I<-x>.

=item B<--selinux-relabel>

=item B<--no-selinux-relabel>

I<--selinux-relabel> forces SELinux relabelling next time the guest boots.
I<--no-selinux-relabel> disables relabelling.

The default is to try to detect if SELinux relabelling is required.  See
L</SELINUX RELABELLING> below for more details.

=item B<-v>

=item B<--verbose>

デバッグ用の冗長なメッセージを有効にします。

=item B<-V>

=item B<--version>

バージョン番号を表示して終了します。

=item B<-x>

libguestfs API 呼び出しのトレースを有効にします。

@EXTRA_OPTIONS@

=back

=head1 OPERATIONS

If the I<--enable> option is I<not> given, then most sysprep operations are
enabled.

Use C<virt-sysprep --list-operations> to list all operations for your
virt-sysprep binary.  The ones which are enabled by default are marked with
a C<*> character.  Regardless of the I<--enable> option, sysprep operations
are skipped for some guest types.

Operations can be individually enabled using the I<--enable> option.  Use a
comma-separated list, for example:

 virt-sysprep --enable=ssh-hostkeys,udev-persistent-net [etc..]

Future versions of virt-sysprep may add more operations.  If you are using
virt-sysprep and want predictable behaviour, specify only the operations
that you want to have enabled.

C<*> = enabled by default when no I<--enable> option is given.

@OPERATIONS@

=head1 コピー方法およびクローン方法

virt-sysprep
は仮想マシンをクローンするプロセスの一部として使用できます。もしくは、クローンされた仮想マシンからテンプレートを準備するために使用できます。仮想化ツールを使用してこれを実現する他の方法がいろいろとあります。このセクションは単に概要を説明します。

仮想マシン(停止状態の場合)は 2 つの部分からなります:

=over 4

=item I<configuration>

仮想マシンの設定または説明。  例: libvirt XML (C<virsh dumpxml> 参照) 、仮想マシンの実行中の設定、または OVF
のような他の外部形式。

いくつかの設定項目は変更する必要があるかもしれません:

=over 4

=item *

名前

=item *

UUID

=item *

ブロックデバイスへのパス

=item *

ネットワークカードの MAC アドレス

=back

=item I<ブロックデバイス>

One or more hard disk images, themselves containing files, directories,
applications, kernels, configuration, etc.

Some things inside the block devices that might need to be changed:

=over 4

=item *

ホスト名および他のネットワーク設定

=item *

UUID

=item *

SSH ホストキー

=item *

Windows の一意なセキュリティ ID (SID)

=item *

Puppet の登録

=back

=back

=head2 ブロックデバイスのコピー法

Starting with an original guest, you probably wish to copy the guest block
device and its configuration to make a template.  Then once you are happy
with the template, you will want to make many clones from it.

                        virt-sysprep
                             |
                             v
 元のゲスト --------> テンプレート ---------->
                                      \------> クローン
                                       \-----> 済みゲスト
                                        \---->

もちろん、ホストにおいて L<cp(1)> または L<dd(1)> を使用してブロックデバイスをコピーできます。

               dd                      dd
 元のゲスト --------> テンプレート ---------->
                                      \------> クローン
                                       \-----> 済みゲスト
                                        \---->

よりスマート(かつ高速)な方法もあります:

=over 4

=item *

                          snapshot
            テンプレート ---------->
                            \------> クローン
                             \-----> 済みゲスト
                              \---->

Use the block device as a backing file and create a snapshot on top for each
guest.  The advantage is that you don't need to copy the block device (very
fast) and only changes are stored (less storage required).

Note that writing to the backing file once you have created guests on top of
it is not possible: you will corrupt the guests.

Tools that can do this include: L<qemu-img(1)> (with the I<create -f qcow2
-o backing_file> option), L<lvcreate(8)> (I<--snapshot> option).  Some
filesystems (such as btrfs) and most Network Attached Storage devices can
also create cheap snapshots from files or LUNs.

=item *

Get your NAS to snapshot and/or duplicate the LUN.

=item *

L<virt-sparsify(1)> を使用してテンプレートを準備します。以下を参照してください。

=back

=head2 virt-clone

A separate tool, L<virt-clone(1)>, can be used to duplicate the block device
and/or modify the external libvirt configuration of a guest.  It will reset
the name, UUID and MAC address of the guest in the libvirt XML.

L<virt-clone(1)> does not use libguestfs and cannot look inside the disk
image.  This was the original motivation to write virt-sysprep.

=head2 スパース化

          virt-sparsify
 元のゲスト --------> テンプレート

L<virt-sparsify(1)> can be used to make the cloning template smaller, making
it easier to compress and/or faster to copy.

Notice that since virt-sparsify also copies the image, you can use it to
make the initial copy (instead of C<dd>).

=head2 容量変更

                         virt-resize
            テンプレート ---------->
                            \------> クローン
                             \-----> 済みゲスト
                              \---->

If you want to give people cloned guests, but let them pick the size of the
guest themselves (eg. depending on how much they are prepared to pay for
disk space), then instead of copying the template, you can run
L<virt-resize(1)>.  Virt-resize performs a copy and resize, and thus is
ideal for cloning guests from a template.

=head1 セキュリティ

Although virt-sysprep removes some sensitive information from the guest, it
does not pretend to remove all of it.  You should examine the L</OPERATIONS>
above and the guest afterwards.

Sensitive files are simply removed.  The data they contained may still exist
on the disk, easily recovered with a hex editor or undelete tool.  Use
L<virt-sparsify(1)> as one way to remove this content.  See also the
L<scrub(1)> command to get rid of deleted content in directory entries and
inodes.

=head2 乱数の種

I<(このセクションは Linux 仮想マシンのみに適用します)>

The virt-sysprep C<random-seed> operation writes a few bytes of randomness
from the host into the guest's random seed file.

If this is just done once and the guest is cloned from the same template,
then each guest will start with the same entropy, and things like SSH host
keys and TCP sequence numbers may be predictable.

Therefore you should arrange to add more randomness I<after> cloning from a
template too, which can be done by just enabling the C<random-seed>
operation:

 cp template.img newguest.img
 virt-sysprep --enable random-seed -a newguest.img

=head2 SELinux の再ラベル付け

I<(このセクションは SELinux を使用している Linux 仮想マシンのみに適用されます。)>

If any new files are created by virt-sysprep, then virt-sysprep touches
C</.autorelabel> so that these will be correctly labelled by SELinux the
next time the guest is booted.  This process interrupts boot and can take
some time.

I<--selinux-relabel> オプションを指定することにより、すべての仮想マシンに対して強制的に再ラベルできます。

I<--no-selinux-relabel> オプションを指定することにより、すべての仮想マシンに対して強制的に再ラベルできます。

=head1 SHELL QUOTING

Libvirt guest names can contain arbitrary characters, some of which have
meaning to the shell such as C<#> and space.  You may need to quote or
escape these characters on the command line.  See the shell manual page
L<sh(1)> for details.

=head1 終了ステータス

このプログラムは、成功すると 0 を返します。または、エラーが起きると 1 を返します。

=head1 関連項目

L<guestfs(3)>, L<guestfish(1)>, L<virt-clone(1)>, L<virt-rescue(1)>,
L<virt-resize(1)>, L<virt-sparsify(1)>, L<virsh(1)>, L<lvcreate(8)>,
L<qemu-img(1)>, L<scrub(1)>, L<http://libguestfs.org/>,
L<http://libvirt.org/>.

=head1 著者

Richard W.M. Jones L<http://people.redhat.com/~rjones/>

Wanlong Gao, Fujitsu Ltd.

=head1 COPYRIGHT

Copyright (C) 2011-2012 Red Hat Inc.

Copyright (C) 2012 Fujitsu Ltd.

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 51
Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.