4 snf-image-creator comes in 2 variants:
5 * snf-image-creator: A non-interactive command line program
6 * snf-mkimage: A user-friendly dialog-based program
8 Non-interactive version
9 =======================
11 snf-image-creator receives the following options:
13 .. code-block:: console
15 $ snf-image-creator --help
17 Usage: snf-image-creator [options] <input_media>
20 --version show program's version number and exit
21 -h, --help show this help message and exit
22 -o FILE, --outfile=FILE
24 -f, --force overwrite output files if they exist
25 -s, --silent silent mode, only output errors
26 -u FILENAME, --upload=FILENAME
27 upload the image to pithos with name FILENAME
28 -r IMAGENAME, --register=IMAGENAME
29 register the image with ~okeanos as IMAGENAME
30 -a ACCOUNT, --account=ACCOUNT
31 Use this ACCOUNT when uploading/registering images
33 -m KEY=VALUE, --metadata=KEY=VALUE
34 Add custom KEY=VALUE metadata to the image
35 -t TOKEN, --token=TOKEN
36 Use this token when uploading/registering images
38 --print-sysprep print the enabled and disabled system preparation
39 operations for this input media
40 --enable-sysprep=SYSPREP
41 run SYSPREP operation on the input media
42 --disable-sysprep=SYSPREP
43 prevent SYSPREP operation from running on the input
45 --no-sysprep don't perform system preparation
46 --no-shrink don't shrink any partition
49 Most input options are self-describing. If you want to save a local copy for
50 the image you create, you specify *-o* option. To upload the image to
51 *pithos+*, you specify valid credentials with *-a* and *-t* options and a
52 filename using *-u*. If you want to register the image with *~okeanos*,
53 in addition to *-u* specify a registration name using *-r*.
55 By default snf-image-creator will perform a number of system preparation
56 operations on the snapshot of the media and will shrink the last partition
57 found, before extracting the image. Both can be disabled by specifying
58 *--no-sysprep* and *--no-shrink* respectively.
60 If *--print-sysprep* is defined, the program will exit after outputing a
61 list of enabled and disabled system preparation operation applicable to this
62 media source. The user can enable or disable specific *syspreps* when creating
63 an image, using *-{enable,disable}-sysprep* options. You can specify those
64 options multiple times to enable or disable multiple *syspreps*.
66 Running *snf-image-creator* with *--print-sysprep* on a raw file that hosts a
67 debian system, we get the following output:
71 .. code-block:: console
73 $ snf-image-creator --print-sysprep debian_desktop.img
77 Examining source media `debian_desktop.img'... looks like an image file
78 Snapshotting media source... done
79 Enabling recovery proc
80 Launching helper VM... done
81 Inspecting Operating System... found a(n) debian system
82 Mounting the media read-only... done
84 Enabled system preparation operations:
86 Remove all regular files under /var/cache
89 Empty all files under /var/log
92 Remove all passwords and lock all user accounts
95 Remove all files under /tmp and /var/tmp
98 Delete sensitive userdata
101 Replace acpid powerdown action scripts to immediately shutdown the
102 system without checking if a GUI is running.
104 remove-persistent-net-rules:
105 Remove udev rules that will keep network interface names persistent
106 after hardware changes and reboots. Those rules will be created again
107 the next time the image runs.
110 Remove swap entry from /etc/fstab. If swap is the last partition
111 then the partition will be removed when shrinking is performed. If the
112 swap partition is not the last partition in the disk or if you are not
113 going to shrink the image you should probably disable this.
115 use-persistent-block-device-names:
116 Scan fstab & grub configuration files and replace all non-persistent
117 device references with UUIDs.
119 Disabled system preparation operations:
121 Remove all files under /var/mail and /var/spool/mail
123 remove-user-accounts:
124 Remove all user accounts with id greater than 1000
129 If we want the image to have all normal user accounts and all mail files
130 removed, we can create it specifying *--enable-sysprep* option like this:
132 .. code-block:: console
134 $ snf-image-creator --enable-sysprep cleanup-mail --enable-sysprep remove-user-accounts ...
139 *snf-mkimage* receives the following options:
141 .. code-block:: console
143 $ Usage: snf-mkimage [options] [<input_media>]
146 --version show program's version number and exit
147 -h, --help show this help message and exit
148 -l FILE, --logfile=FILE
149 log all messages to FILE
151 If the input media is not specified in the command line, in the first dialog
152 box the user will be asked to specify it. After the input media is examined and
153 the program is initialized, the user will be given the choice to run
154 *snf-mkimage* in *wizard* or *expert* mode.
159 When *snf-mkimage* runs in *wizard* mode, the user is just asked to provide the
160 following basic information:
162 * Name: A short name for the image (ex. "Slackware")
163 * Description: An one-line description for the image (ex. "Slackware Linux 14.0 with KDE")
164 * Account: An *~okeanos* account email
165 * Token: A token corresponding to the account defined previously
167 After confirming, the image will be extracted, uploaded to *pithos+* and
168 registered to *~okeanos*. The user will also be given the choice to keep a local
169 copy of it. For most users the functionality this mode provides should be
175 Expert mode allows the user to have better control on the image creation
176 process. In the picture below the main menu can be seen:
178 .. image:: /snapshots/main_menu.png
180 In the *Customize* sub-menu the user can control:
182 * The system preparation operations that will be applied on the media
183 * Whether the image will be shrunk or not
184 * The properties associated with the image
185 * The configuration tasks that will run during image deployment
187 In the *Register* sub-menu the user can provide:
189 * The credentials to login to *~okeanos*
190 * A pithos filename for the uploaded *diskdump* image
191 * A name for the image to be registered to *~okeanos* with
193 By choosing the *Extract* menu entry the user can dump the image to the local
194 file system and finally, if the user selects *Reset*, the system will ignore
195 all changes made so far and will start the image creation process again.
200 Suppose you want to create a new Ubuntu server image. Download the installation
201 disk from the Internet:
203 .. code-block:: console
205 $ wget http://ubuntureleases.tsl.gr/12.04.1/ubuntu-12.04.1-server-amd64.iso
207 Verify that it has been downloaded correctly:
209 .. code-block:: console
211 $ echo 'a8c667e871f48f3a662f3fbf1c3ddb17 ubuntu-12.04.1-server-amd64.iso' > check.md5
212 $ md5sum -c check.md5
214 Create a 2G sparse file to host the new system:
216 .. code-block:: console
218 $ truncate -s 2G ubuntu_hd.raw
220 And install the Ubuntu system on this file:
222 .. code-block:: console
224 $ sudo kvm -boot d -drive file=ubuntu_hd.raw,format=raw,cache=none,if=virtio \
225 -m 1000 -cdrom ubuntu-12.04.1-server-amd64.iso
229 During the installation, you will be asked about the partition scheme. Since
230 snf-image-creator does not support LVM partitions, you are advised to create
233 When the installation is complete, you can close the QEMU window. You
234 will be able to boot your installed OS and make any changes you want to it
235 (e.g. install openssh-server) using the following command::
237 $ sudo kvm -boot d -drive file=ubuntu_hd.raw,format=raw,cache=none,if=virtio
239 After you're done, become root, activate the virtual environment you have
240 installed snf-image-creator in, and use *snf-mkimage* to create and upload the
243 .. code-block:: console
246 $ source /path/to/snf-image-env/bin/activate
247 $ snf-mkimage ubuntu_hd.raw
249 In the first screen you will be asked to choose if you want to run the program
250 in *Wizard* or *Expert* mode. Choose *Wizard*.
252 .. image:: /snapshots/01_wizard.png
254 Then you will be asked to provide a name, a description, an *~okeanos* account
255 and the token corresponding to this account. After that you will be asked to
256 confirm the provided data.
258 .. image:: /snapshots/06_confirm.png
260 Choosing *YES* will create the image and upload it to your *~okeanos* account.
262 Some caveats on image creation
263 ==============================
265 Para-virtualized drivers
266 ------------------------
268 *~Okeanos* uses the *VirtIO* framework. The disk I/O controller and the
269 Ethernet cards on the VM instances are para-virtualized and need special
270 *VirtIO* drivers. Those drivers are included in the Linux Kernel mainline since
271 version 2.6.25 and are shipped with all the popular Linux distributions. The
272 problem is that if the driver for the para-virtualized disk I/O controller is
273 built as module, it needs to be preloaded using an initial ramdisk, otherwise
274 the VM will not be able to boot.
276 In the image creation demonstration above, we initially installed the Ubuntu
277 system on a hard disk (*ubuntu_hd.raw*) that was connected on a
278 para-virtualized interface (pay attention to the *if=virtio* option of the kvm
279 line). Ubuntu and Debian create a generic initial ramdisk file that contains
280 many different modules, including the VirtIO drivers. In many distros this is
281 not the case. In Arch Linux for example, the user needs to manually add
282 *virtio_blk* and *virtio_pci* drivers in */etc/mkinitcpio.conf* and rebuild the
283 initial ramdisk [#f1]_ to make the virtio drivers get preloaded during boot.
284 For now, *snf-image-creator* cannot resolve this kind of problems and it's left
285 to the user to do it.
290 If you want your image to have a swap partition, make sure this is the last
291 partition on the disk. If snf-image-creator detects a swap partition in the end
292 of the input media, it will remove the partition when shrinking and will save
293 enough information to be able to recreate it during image deployment. This will
294 make the image smaller and will speed up the deployment process.
296 .. rubric:: Footnotes
298 .. [#f1] https://wiki.archlinux.org/index.php/KVM#Paravirtualized_guests_.28virtio.29