Statistics
| Branch: | Tag: | Revision:

root / docs / usage.rst @ c71f38be

History | View | Annotate | Download (14.3 kB)

1
Usage
2
^^^^^
3

    
4
snf-image-creator comes in 2 variants:
5

    
6
 * snf-image-creator: A non-interactive command line program
7
 * snf-mkimage: A user-friendly dialog-based program
8

    
9
Both expect the input media as first argument. The input media may be a local
10
file, a block device or *"/"* if you want to create an image out of the running
11
system (see `host bundling operation`_).
12

    
13
Non-interactive version
14
=======================
15

    
16
snf-image-creator receives the following options:
17

    
18
.. code-block:: console
19

    
20
   $ snf-image-creator --help
21
   Usage: snf-image-creator [options] <input_media>
22
   
23
   Options:
24
     --version             show program's version number and exit
25
     -h, --help            show this help message and exit
26
     -o FILE, --outfile=FILE
27
                           dump image to FILE
28
     -f, --force           overwrite output files if they exist
29
     -s, --silent          output only errors
30
     -u FILENAME, --upload=FILENAME
31
                           upload the image to the storage service with name FILENAME
32
     -r IMAGENAME, --register=IMAGENAME
33
                           register the image with the compute service as IMAGENAME
34
     -m KEY=VALUE, --metadata=KEY=VALUE
35
                           add custom KEY=VALUE metadata to the image
36
     -t TOKEN, --token=TOKEN
37
                           use this authentication token when
38
                           uploading/registering images
39
     -a URL, --authentication-url=URL
40
                           use this authentication URL when uploading/registering
41
                           images
42
     -c CLOUD, --cloud=CLOUD
43
                           use this saved cloud account to authenticate against a
44
                           cloud when uploading/registering images
45
     --print-sysprep       print the enabled and disabled system preparation
46
                           operations for this input media
47
     --enable-sysprep=SYSPREP
48
                           run SYSPREP operation on the input media
49
     --disable-sysprep=SYSPREP
50
                           prevent SYSPREP operation from running on the input
51
                           media
52
     --no-sysprep          don't perform any system preparation operation
53
     --no-shrink           don't shrink any partition
54
     --public              register image with the compute service as public
55
     --tmpdir=DIR          create large temporary image files under DIR
56

    
57
Most input options are self-describing. If you want to save a local copy of
58
the image you create, provide a filename using the *-o* option. To upload the
59
image to the storage service of a cloud, provide valid cloud API access info
60
(by either using a token and a URL with *-t* and *-a* respectively, or a cloud
61
name with *-c*) and a remote filename using *-u*. If you also want to register
62
the image with the compute service of the cloud, in addition to *-u* provide a
63
registration name using *-r*. All images are
64
registered as *private*. Only the user that registers the image can create
65
VM's out of it. If you want the image to be visible by other user too, use the
66
*--public* option.
67

    
68
By default, before extracting the image, snf-image-creator will perform a
69
number of system preparation operations on the snapshot of the media and will
70
shrink the last partition found. Both actions can be disabled by specifying
71
*--no-sysprep* and *--no-shrink* respectively.
72

    
73
If *--print-sysprep* is defined, the program will exit after printing a
74
list of enabled and disabled system preparation operation applicable to this
75
input media. The user can enable or disable specific *syspreps*, using
76
*-{enable,disable}-sysprep* options. The user may specify those options
77
multiple times.
78

    
79
Running *snf-image-creator* with *--print-sysprep* on a raw file that hosts a
80
debian system, we print the following output:
81

    
82
.. _sysprep:
83

    
84
.. code-block:: console
85

    
86
   $ snf-image-creator --print-sysprep ubuntu.raw
87
   snf-image-creator 0.3
88
   =====================
89
   Examining source media `ubuntu_hd.raw' ... looks like an image file
90
   Snapshotting media source ... done
91
   Enabling recovery proc
92
   Launching helper VM (may take a while) ... done
93
   Inspecting Operating System ... ubuntu
94
   Mounting the media read-only ... done
95
   Collecting image metadata ... done
96
   Umounting the media ... done
97
   
98
   Enabled system preparation operations:
99
       cleanup-cache:
100
           Remove all regular files under /var/cache
101
   
102
       cleanup-log:
103
           Empty all files under /var/log
104
   
105
       cleanup-passwords:
106
           Remove all passwords and lock all user accounts
107
   
108
       cleanup-tmp:
109
           Remove all files under /tmp and /var/tmp
110
   
111
       cleanup-userdata:
112
           Delete sensitive userdata
113
   
114
       fix-acpid:
115
           Replace acpid powerdown action scripts to immediately shutdown the
116
           system without checking if a GUI is running.
117
   
118
       remove-persistent-net-rules:
119
           Remove udev rules that will keep network interface names persistent
120
           after hardware changes and reboots. Those rules will be created again
121
           the next time the image runs.
122
   
123
       remove-swap-entry:
124
           Remove swap entry from /etc/fstab. If swap is the last partition
125
           then the partition will be removed when shrinking is performed. If the
126
           swap partition is not the last partition in the disk or if you are not
127
           going to shrink the image you should probably disable this.
128
   
129
       use-persistent-block-device-names:
130
           Scan fstab & grub configuration files and replace all non-persistent
131
           device references with UUIDs.
132
   
133
   Disabled system preparation operations:
134
       cleanup-mail:
135
           Remove all files under /var/mail and /var/spool/mail
136
   
137
       remove-user-accounts:
138
           Remove all user accounts with id greater than 1000
139
   
140
   
141
   cleaning up ...
142

    
143
If you want the image to have all normal user accounts and all mail files
144
removed, you should use *--enable-sysprep* option like this:
145

    
146
.. code-block:: console
147

    
148
   $ snf-image-creator --enable-sysprep cleanup-mail --enable-sysprep remove-user-accounts ...
149

    
150
Dialog-based version
151
====================
152

    
153
*snf-mkimage* receives the following options:
154

    
155
.. code-block:: console
156

    
157
 $ snf-mkimage --help
158
 Usage: snf-mkimage [options] [<input_media>]
159

    
160
 Options:
161
   --version             show program's version number and exit
162
   -h, --help            show this help message and exit
163
   -l FILE, --logfile=FILE
164
                         log all messages to FILE
165
   --tmpdir=DIR          create large temporary image files under DIR
166

    
167
If the input media is not specified in the command line, in the first dialog
168
box the user will be asked to specify it:
169

    
170
.. image:: /snapshots/select_media.png
171

    
172
The user can select a file (regular or block device) or use the *Bundle Host*
173
button to create an image out of the running system (see
174
`Host bundling operation`_).
175

    
176
After the input media is examined and the program is initialized, the user will
177
be given the choice to run *snf-mkimage* in *wizard* or *expert* mode.
178

    
179
Wizard mode
180
-----------
181

    
182
When *snf-mkimage* runs in *wizard* mode, the user is just asked to provide the
183
following basic information:
184

    
185
 * Cloud: The cloud account to use to upload and register the resulting image
186
 * Name: A short name for the image (ex. "Slackware")
187
 * Description: An one-line description for the image
188
   (ex. "Slackware Linux 14.0 with KDE")
189
 * Registration Type: Private or Public
190

    
191
After confirming, the image will be extracted, uploaded to the storage service
192
and registered with the compute service of the selected cloud. The user will
193
also be given the choice to keep a local copy of it.
194

    
195
For most users the functionality this mode provides should be sufficient.
196

    
197
Expert mode
198
-----------
199

    
200
Expert mode allows the user to have better control on the image creation
201
process. The main menu can be seen in the picture below:
202

    
203
.. image:: /snapshots/main_menu.png
204

    
205
In the *Customize* sub-menu the user can control:
206

    
207
 * The system preparation operations that will be applied on the media
208
 * Whether the image will be shrunk or not
209
 * The properties associated with the image
210
 * The configuration tasks that will run during image deployment
211

    
212
In the *Register* sub-menu the user can provide:
213

    
214
 * Which cloud account to use
215
 * A filename for the uploaded *diskdump* image
216
 * A name for the image to use when registering it with the storage service of
217
   the cloud, as well as the registration type (*private* or *public*)
218

    
219
By choosing the *Extract* menu entry, the user can dump the image to the local
220
file system. Finally, if the user selects *Reset*, the system will ignore
221
all changes made so far and will start the image creation process again.
222

    
223
Host bundling operation
224
=======================
225

    
226
As a new feature in *v0.2*, snf-image-creator can create images out of the host
227
system that runs the program. This is done either by specifying / as input
228
media or by using the *Bundle Host* button in the media selection dialog of
229
snf-mkimage. During this operation, the files of the disk are copied into a
230
temporary image file, which means that the file system that will host the
231
temporary image needs to have a lot of free space (see `large temporary files`_
232
for more information).
233

    
234
Creating a new image
235
====================
236

    
237
Suppose you want to create a new Ubuntu server image. Download the installation
238
disk from the Internet:
239

    
240
.. code-block:: console
241

    
242
   $ wget http://ubuntureleases.tsl.gr/12.04.2/ubuntu-12.04.2-server-amd64.iso
243

    
244
Verify that it has been downloaded correctly:
245

    
246
.. code-block:: console
247

    
248
   $ echo 'a8c667e871f48f3a662f3fbf1c3ddb17  ubuntu-12.04.2-server-amd64.iso' > check.md5
249
   $ md5sum -c check.md5
250

    
251
Create a 2G sparse file to host the new system:
252

    
253
.. code-block:: console
254

    
255
   $ truncate -s 2G ubuntu.raw
256

    
257
And install the Ubuntu system on this file:
258

    
259
.. code-block:: console
260

    
261
   $ sudo kvm -boot d -drive file=ubuntu.raw,format=raw,cache=none,if=virtio \
262
     -m 1G -cdrom ubuntu-12.04.2-server-amd64.iso
263

    
264
.. warning::
265

    
266
   During the installation, you will be asked about the partition scheme. Don't 
267
   use LVM partitions. They are not supported by snf-image-creator.
268

    
269
You will be able to boot your installed OS and make any changes you want
270
(e.g. install openssh-server) using the following command::
271

    
272
   $ sudo kvm -m 1G -boot c -drive file=ubuntu.raw,format=raw,cache=none,if=virtio
273

    
274
After you're done, you may use *snf-mkimage* as root to create and upload the
275
image:
276

    
277
.. code-block:: console
278

    
279
   $ sudo -s
280
   $ snf-mkimage ubuntu.raw
281

    
282
In the first screen you will be asked to choose if you want to run the program
283
in *Wizard* or *Expert* mode. Choose *Wizard*.
284

    
285
.. image:: /snapshots/wizard.png
286

    
287
Then you will be asked to select a cloud and provide a name, a description and
288
a registration type (*private* or *public*). Finally, you'll be asked to
289
confirm the provided data.
290

    
291
.. image:: /snapshots/confirm.png
292

    
293
Choosing *YES* will create and upload the image to your cloud account.
294

    
295
Limitations
296
===========
297

    
298
Supported operating systems
299
---------------------------
300

    
301
*snf-image-creator* can only fully function on input media hosting *Linux*
302
systems. The program will detect the needed metadata and you may use it to
303
upload and register other *Unix* or *Windows* images, but you cannot use it to
304
shrink them or perform system preparation operations.
305

    
306
Logical Volumes
307
---------------
308

    
309
The program cannot work on LVM partitions [#f1]_. The input media may only
310
contain primary or logical partitions.
311

    
312
Para-virtualized drivers
313
------------------------
314

    
315
Most synnefo deployments uses the *VirtIO* framework. The disk I/O controller
316
and the Ethernet cards on the VM instances are para-virtualized and need
317
special *VirtIO* drivers. Those drivers are included in the Linux Kernel
318
mainline since version 2.6.25 and are shipped with all the popular Linux
319
distributions. The problem is that if the driver for the para-virtualized disk
320
I/O controller is built as module, it needs to be preloaded using an initial
321
ramdisk, otherwise the VM won't be able to boot.
322

    
323
Many popular Linux distributions, like Ubuntu and Debian, will automatically
324
create a generic initial ramdisk file that contains many different modules,
325
including the VirtIO drivers. Others that target more experienced users, like
326
Slackware, won't do that [#f2]_. *snf-image-creator* cannot resolve this kind
327
of problems and it's left to the user to do so. Please refer to your
328
distribution's documentation for more information on this. You can always check
329
if a system can boot with para-virtualized disk controller by launching it with
330
kvm using the *if=virtio* option (see the kvm command in the
331
`Creating a new image`_ section).
332

    
333
Some caveats on image creation
334
==============================
335

    
336
Image partition schemes and shrinking
337
-------------------------------------
338

    
339
When image shrinking is enabled, *snf-image-creator* will shrink the last
340
partition on the disk. If this is a swap partition, it will remove it, save
341
enough information to recreate it during image deployment and shrink the
342
partition that lays just before that. This will make the image smaller which
343
speeds up the deployment process.
344

    
345
During image deployment, the last partition is enlarged to occupy the available
346
space in the VM's hard disk and a swap partition is added at the end if a SWAP
347
image property is present.
348

    
349
Keep this in mind when creating images. It's always better to have your swap
350
partition placed as the last partition on the disk and have your largest
351
partition (*/* or */home*) just before that.
352

    
353
Large temporary files
354
---------------------
355

    
356
*snf-image-creator* may create large temporary files when running:
357

    
358
 * During image shrinking, the input media snapshot file may reach the size of
359
   the original media.
360
 * When bundling the host system, the temporary image file may became as large
361
   as the rest of the disk files altogether.
362

    
363
*/tmp* directory is not a good place for hosting large files. In many systems
364
the contents of */tmp* are stored in volatile memory and the size they may occupy
365
is limited. By default, *snf-image-creator* will use a heuristic approach to
366
determine where to store large temporary files. It will examine the free space
367
under */var/tmp*, the user's home directory and */mnt* and will pick the one
368
with the most available space. The user may overwrite this behaviour and
369
indicate a different directory using the *tmpdir* option. This option is
370
supported by both *snf-image-creator* and *snf-mkimage*.
371

    
372
.. rubric:: Footnotes
373

    
374
.. [#f1] http://sourceware.org/lvm2/
375
.. [#f2] http://mirrors.slackware.com/slackware/slackware-14.0/README.initrd