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 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
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
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
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
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.
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
79 Running *snf-image-creator* with *--print-sysprep* on a raw file that hosts a
80 debian system, we print the following output:
84 .. code-block:: console
86 $ snf-image-creator --print-sysprep ubuntu.raw
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
98 Enabled system preparation operations:
100 Remove all regular files under /var/cache
103 Empty all files under /var/log
106 Remove all passwords and lock all user accounts
109 Remove all files under /tmp and /var/tmp
112 Delete sensitive userdata
115 Replace acpid powerdown action scripts to immediately shutdown the
116 system without checking if a GUI is running.
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.
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.
129 use-persistent-block-device-names:
130 Scan fstab & grub configuration files and replace all non-persistent
131 device references with UUIDs.
133 Disabled system preparation operations:
135 Remove all files under /var/mail and /var/spool/mail
137 remove-user-accounts:
138 Remove all user accounts with id greater than 1000
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:
146 .. code-block:: console
148 $ snf-image-creator --enable-sysprep cleanup-mail --enable-sysprep remove-user-accounts ...
153 *snf-mkimage* receives the following options:
155 .. code-block:: console
158 Usage: snf-mkimage [options] [<input_media>]
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
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:
170 .. image:: /snapshots/select_media.png
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`_).
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.
182 When *snf-mkimage* runs in *wizard* mode, the user is just asked to provide the
183 following basic information:
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
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.
195 For most users the functionality this mode provides should be sufficient.
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:
203 .. image:: /snapshots/main_menu.png
205 In the *Customize* sub-menu the user can control:
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
212 In the *Register* sub-menu the user can provide:
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*)
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.
223 Host bundling operation
224 =======================
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).
237 Suppose you want to create a new Ubuntu server image. Download the installation
238 disk from the Internet:
240 .. code-block:: console
242 $ wget http://ubuntureleases.tsl.gr/12.04.2/ubuntu-12.04.2-server-amd64.iso
244 Verify that it has been downloaded correctly:
246 .. code-block:: console
248 $ echo 'a8c667e871f48f3a662f3fbf1c3ddb17 ubuntu-12.04.2-server-amd64.iso' > check.md5
249 $ md5sum -c check.md5
251 Create a 2G sparse file to host the new system:
253 .. code-block:: console
255 $ truncate -s 2G ubuntu.raw
257 And install the Ubuntu system on this file:
259 .. code-block:: console
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
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.
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::
272 $ sudo kvm -m 1G -boot c -drive file=ubuntu.raw,format=raw,cache=none,if=virtio
274 After you're done, you may use *snf-mkimage* as root to create and upload the
277 .. code-block:: console
280 $ snf-mkimage ubuntu.raw
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*.
285 .. image:: /snapshots/wizard.png
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.
291 .. image:: /snapshots/confirm.png
293 Choosing *YES* will create and upload the image to your cloud account.
298 Supported operating systems
299 ---------------------------
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.
309 The program cannot work on LVM partitions [#f1]_. The input media may only
310 contain primary or logical partitions.
312 Para-virtualized drivers
313 ------------------------
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.
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).
333 Some caveats on image creation
334 ==============================
336 Image partition schemes and shrinking
337 -------------------------------------
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.
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.
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.
353 Large temporary files
354 ---------------------
356 *snf-image-creator* may create large temporary files when running:
358 * During image shrinking, the input media snapshot file may reach the size of
360 * When bundling the host system, the temporary image file may became as large
361 as the rest of the disk files altogether.
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*.
372 .. rubric:: Footnotes
374 .. [#f1] http://sourceware.org/lvm2/
375 .. [#f2] http://mirrors.slackware.com/slackware/slackware-14.0/README.initrd