4 snf-image-creator comes in 2 variants:
6 * snf-image-creator: A non-interactive command line program
7 * snf-mkimage: A user-friendly dialog-based program
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`_).
13 Non-interactive version
14 =======================
16 snf-image-creator receives the following options:
18 .. code-block:: console
20 $ snf-image-creator --help
21 Usage: snf-image-creator [options] <input_media>
24 --version show program's version number and exit
25 -h, --help show this help message and exit
26 -o FILE, --outfile=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 cloud with name FILENAME
32 -r IMAGENAME, --register=IMAGENAME
33 register the image with a cloud 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
42 -c CLOUD, --cloud=CLOUD
43 use this saved cloud account to authenticate against a
44 cloud when uploading/registering images
45 --print-syspreps 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
52 --print-sysprep-params
53 print the needed sysprep parameters for this input
55 --sysprep-param=SYSPREP_PARAMS
56 Add KEY=VALUE system preparation parameter
57 --no-sysprep don't perform any system preparation operation
58 --no-shrink don't shrink any partition
59 --public register image with the cloud as public
60 --tmpdir=DIR create large temporary image files under DIR
62 Most input options are self-describing. If you want to save a local copy of
63 the image you create, provide a filename using the *-o* option. To upload the
64 image to the storage service of a cloud, provide valid cloud API access info
65 (by either using a token and a URL with *-t* and *-a* respectively, or a cloud
66 name with *-c*) and a remote filename using *-u*. If you also want to register
67 the image with the compute service of the cloud, in addition to *-u* provide a
68 registration name using *-r*. All images are
69 registered as *private*. Only the user that registers the image can create
70 VM's out of it. If you want the image to be visible by other user too, use the
73 By default, before extracting the image, snf-image-creator will perform a
74 number of system preparation operations on the snapshot of the media and will
75 shrink the last partition found. Both actions can be disabled by specifying
76 *--no-sysprep* and *--no-shrink* respectively.
78 If *--print-sysprep* is defined, the program will exit after printing a
79 list of enabled and disabled system preparation operation applicable to this
80 input media. The user can enable or disable specific *syspreps*, using
81 *-{enable,disable}-sysprep* options. The user may specify those options
84 Running *snf-image-creator* with *--print-sysprep* on a raw file that hosts a
85 debian system, we print the following output:
89 .. code-block:: console
91 $ snf-image-creator --print-sysprep ubuntu.raw
94 Examining source media `ubuntu_hd.raw' ... looks like an image file
95 Snapshotting media source ... done
96 Enabling recovery proc
97 Launching helper VM (may take a while) ... done
98 Inspecting Operating System ... ubuntu
99 Mounting the media read-only ... done
100 Collecting image metadata ... done
101 Umounting the media ... done
103 Enabled system preparation operations:
105 Remove all regular files under /var/cache
108 Empty all files under /var/log
111 Remove all passwords and lock all user accounts
114 Remove all files under /tmp and /var/tmp
117 Delete sensitive userdata
120 Replace acpid powerdown action scripts to immediately shutdown the
121 system without checking if a GUI is running.
123 remove-persistent-net-rules:
124 Remove udev rules that will keep network interface names persistent
125 after hardware changes and reboots. Those rules will be created again
126 the next time the image runs.
129 Remove swap entry from /etc/fstab. If swap is the last partition
130 then the partition will be removed when shrinking is performed. If the
131 swap partition is not the last partition in the disk or if you are not
132 going to shrink the image you should probably disable this.
134 use-persistent-block-device-names:
135 Scan fstab & grub configuration files and replace all non-persistent
136 device references with UUIDs.
138 Disabled system preparation operations:
140 Remove all files under /var/mail and /var/spool/mail
142 remove-user-accounts:
143 Remove all user accounts with id greater than 1000
148 If you want the image to have all normal user accounts and all mail files
149 removed, you should use *--enable-sysprep* option like this:
151 .. code-block:: console
153 $ snf-image-creator --enable-sysprep cleanup-mail --enable-sysprep remove-user-accounts ...
158 *snf-mkimage* receives the following options:
160 .. code-block:: console
163 Usage: snf-mkimage [options] [<input_media>]
166 --version show program's version number and exit
167 -h, --help show this help message and exit
168 -l FILE, --logfile=FILE
169 log all messages to FILE
170 --tmpdir=DIR create large temporary image files under DIR
172 If the input media is not specified in the command line, in the first dialog
173 box the user will be asked to specify it:
175 .. image:: /snapshots/select_media.png
177 The user can select a file (regular or block device) or use the *Bundle Host*
178 button to create an image out of the running system (see
179 `Host bundling operation`_).
181 After the input media is examined and the program is initialized, the user will
182 be given the choice to run *snf-mkimage* in *wizard* or *expert* mode.
187 When *snf-mkimage* runs in *wizard* mode, the user is just asked to provide the
188 following basic information:
190 * Cloud: The cloud account to use to upload and register the resulting image
191 * Name: A short name for the image (ex. "Slackware")
192 * Description: An one-line description for the image
193 (ex. "Slackware Linux 14.0 with KDE")
194 * Registration Type: Private or Public
196 After confirming, the image will be extracted, uploaded to the storage service
197 and registered with the compute service of the selected cloud. The user will
198 also be given the choice to keep a local copy of it.
200 For most users the functionality this mode provides should be sufficient.
205 Expert mode allows the user to have better control on the image creation
206 process. The main menu can be seen in the picture below:
208 .. image:: /snapshots/main_menu.png
210 In the *Customize* sub-menu the user can control:
212 * The system preparation operations that will be applied on the media
213 * Whether the image will be shrunk or not
214 * The properties associated with the image
215 * The configuration tasks that will run during image deployment
217 In the *Register* sub-menu the user can provide:
219 * Which cloud account to use
220 * A filename for the uploaded *diskdump* image
221 * A name for the image to use when registering it with the storage service of
222 the cloud, as well as the registration type (*private* or *public*)
224 By choosing the *Extract* menu entry, the user can dump the image to the local
225 file system. Finally, if the user selects *Reset*, the system will ignore
226 all changes made so far and will start the image creation process again.
228 Host bundling operation
229 =======================
231 As a new feature in *v0.2*, snf-image-creator can create images out of the host
232 system that runs the program. This is done either by specifying / as input
233 media or by using the *Bundle Host* button in the media selection dialog of
234 snf-mkimage. During this operation, the files of the disk are copied into a
235 temporary image file, which means that the file system that will host the
236 temporary image needs to have a lot of free space (see `large temporary files`_
237 for more information).
242 Suppose you want to create a new Ubuntu server image. Download the installation
243 disk from the Internet:
245 .. code-block:: console
247 $ wget http://ubuntureleases.tsl.gr/12.04.2/ubuntu-12.04.2-server-amd64.iso
249 Verify that it has been downloaded correctly:
251 .. code-block:: console
253 $ echo 'a8c667e871f48f3a662f3fbf1c3ddb17 ubuntu-12.04.2-server-amd64.iso' > check.md5
254 $ md5sum -c check.md5
256 Create a 2G sparse file to host the new system:
258 .. code-block:: console
260 $ truncate -s 2G ubuntu.raw
262 And install the Ubuntu system on this file:
264 .. code-block:: console
266 $ sudo kvm -boot d -drive file=ubuntu.raw,format=raw,cache=none,if=virtio \
267 -m 1G -cdrom ubuntu-12.04.2-server-amd64.iso
271 During the installation, you will be asked about the partition scheme. Don't
272 use LVM partitions. They are not supported by snf-image-creator.
274 You will be able to boot your installed OS and make any changes you want
275 (e.g. install openssh-server) using the following command::
277 $ sudo kvm -m 1G -boot c -drive file=ubuntu.raw,format=raw,cache=none,if=virtio
279 After you're done, you may use *snf-mkimage* as root to create and upload the
282 .. code-block:: console
285 $ snf-mkimage ubuntu.raw
287 In the first screen you will be asked to choose if you want to run the program
288 in *Wizard* or *Expert* mode. Choose *Wizard*.
290 .. image:: /snapshots/wizard.png
292 Then you will be asked to select a cloud and provide a name, a description and
293 a registration type (*private* or *public*). Finally, you'll be asked to
294 confirm the provided data.
296 .. image:: /snapshots/confirm.png
298 Choosing *YES* will create and upload the image to your cloud account.
303 Supported operating systems
304 ---------------------------
306 *snf-image-creator* can only fully function on input media hosting *Linux*,
307 *FreeBSD* (tested on version 9.1) and *Windows* (Server 2008 R2 and Server
308 2012) systems. The program will detect the needed metadata and you may use it
309 to upload and register other *Unix* images, but you cannot use it to shrink
310 them or perform system preparation operations.
315 The program cannot work on LVM partitions [#f1]_. The input media may only
316 contain primary or logical partitions.
318 Para-virtualized drivers
319 ------------------------
321 Most synnefo deployments uses the *VirtIO* framework. The disk I/O controller
322 and the Ethernet cards on the VM instances are para-virtualized and need
323 special *VirtIO* drivers. Those drivers are included in the Linux Kernel
324 mainline since version 2.6.25 and are shipped with all the popular Linux
325 distributions. The problem is that if the driver for the para-virtualized disk
326 I/O controller is built as module, it needs to be preloaded using an initial
327 ramdisk, otherwise the VM won't be able to boot.
329 Many popular Linux distributions, like Ubuntu and Debian, will automatically
330 create a generic initial ramdisk file that contains many different modules,
331 including the VirtIO drivers. Others that target more experienced users, like
332 Slackware, won't do that [#f2]_. *snf-image-creator* cannot resolve this kind
333 of problems and it's left to the user to do so. Please refer to your
334 distribution's documentation for more information on this. You can always check
335 if a system can boot with para-virtualized disk controller by launching it with
336 kvm using the *if=virtio* option (see the kvm command in the
337 `Creating a new image`_ section).
339 For Windows and FreeBSD systems, the needed drivers need to be manually
340 downloaded and installed on the media before the image creation process takes
341 place. For *FreeBSD* the virtio drivers can be found
342 `here <http://people.freebsd.org/~kuriyama/virtio/>`_. For Windows the drivers
344 `Fedora Project <http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/>`_.
346 Some caveats on image creation
347 ==============================
349 Image partition schemes and shrinking
350 -------------------------------------
352 When image shrinking is enabled, *snf-image-creator* will shrink the last
353 partition on the disk. If this is a swap partition, it will remove it, save
354 enough information to recreate it during image deployment and shrink the
355 partition that lays just before that. This will make the image smaller which
356 speeds up the deployment process.
358 During image deployment, the last partition is enlarged to occupy the available
359 space in the VM's hard disk and a swap partition is added at the end if a SWAP
360 image property is present.
362 Keep this in mind when creating images. It's always better to have your swap
363 partition placed as the last partition on the disk and have your largest
364 partition (*/* or */home*) just before that.
366 Large temporary files
367 ---------------------
369 *snf-image-creator* may create large temporary files when running:
371 * During image shrinking, the input media snapshot file may reach the size of
373 * When bundling the host system, the temporary image file may became as large
374 as the rest of the disk files altogether.
376 */tmp* directory is not a good place for hosting large files. In many systems
377 the contents of */tmp* are stored in volatile memory and the size they may occupy
378 is limited. By default, *snf-image-creator* will use a heuristic approach to
379 determine where to store large temporary files. It will examine the free space
380 under */var/tmp*, the user's home directory and */mnt* and will pick the one
381 with the most available space. The user may overwrite this behaviour and
382 indicate a different directory using the *tmpdir* option. This option is
383 supported by both *snf-image-creator* and *snf-mkimage*.
385 .. rubric:: Footnotes
387 .. [#f1] http://sourceware.org/lvm2/
388 .. [#f2] http://mirrors.slackware.com/slackware/slackware-14.0/README.initrd