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 appliable 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:
69 .. code-block:: console
71 $ snf-image-creator --print-sysprep debian_desktop.img
75 Examining source media `debian_desktop.img'... looks like an image file
76 Snapshotting media source... done
77 Enabling recovery proc
78 Launching helper VM... done
79 Inspecting Operating System... found a(n) debian system
80 Mounting the media read-only... done
82 Enabled system preparation operations:
84 Remove all regular files under /var/cache
87 Empty all files under /var/log
90 Remove all passwords and lock all user accounts
93 Remove all files under /tmp and /var/tmp
96 Delete sensitive userdata
99 Replace acpid powerdown action scripts to immediately shutdown the
100 system without checking if a GUI is running.
102 remove-persistent-net-rules:
103 Remove udev rules that will keep network interface names persistent
104 after hardware changes and reboots. Those rules will be created again
105 the next time the image runs.
108 Remove swap entry from /etc/fstab. If swap is the last partition
109 then the partition will be removed when shrinking is performed. If the
110 swap partition is not the last partition in the disk or if you are not
111 going to shrink the image you should probably disable this.
113 use-persistent-block-device-names:
114 Scan fstab & grub configuration files and replace all non-persistent
115 device references with UUIDs.
117 Disabled system preparation operations:
119 Remove all files under /var/mail and /var/spool/mail
121 remove-user-accounts:
122 Remove all user accounts with id greater than 1000
127 If we want the image to have all normal user accounts and all mail files
128 removed, we can create it specifying *--enable-sysprep* option like this:
130 .. code-block:: console
132 $ snf-image-creator --enable-sysprep cleanup-mail --enable-sysprep remove-user-accounts ...
137 *snf-mkimage* receives the following options:
139 .. code-block:: console
141 $ Usage: snf-mkimage [options] [<input_media>]
144 --version show program's version number and exit
145 -h, --help show this help message and exit
146 -l FILE, --logfile=FILE
147 log all messages to FILE
149 If the input media is not specified in the command line, in the first dialog
150 box the user will be asked to specify it. After the input media is examined and
151 the program is initialized, the user will be given the choice to run
152 *snf-mkimage* in *wizard* or *expert* mode.
157 When *snf-mkimage* runs in *wizard* mode, the user is just asked to provide the
158 following basic information:
160 * Name: A short name for image (ex. "Slackware")
161 * Description: An one-line description for the image (ex. "Slackware Linux 14.0 with KDE")
162 * Account: An *~okeanos* account email
163 * Token: A token corresponding to the account defined previously
165 After confirming, the image will be extracted, uploaded to *pithos+* and
166 registered to *~okeanos*. The user will also be given the choice to keep a local
167 copy of it. For most users the functionality this mode provides should be
173 Expert mode allows the user to have better control on the image creation
174 process. In the picture below the main menu can be seen:
176 .. image:: /snapshots/main_menu.png
178 In the *Customize* sub-menu the user can control:
180 * The system preparation operations that will be applied on the media
181 * Whether the image will be shrunk or not
182 * The properties associated with the image
183 * The configuration tasks that will run during image deployment
185 In the *Register* sub-menu the user can provide:
187 * The credentials to login to *~okeanos*
188 * A pithos filename for the uploaded *diskdump* image
189 * A name for the image to be registered to *~okeanos* with
191 By choosing the *Extract* menu entry the user can dump the image to the local
192 file system and finally, if the user selects *Reset*, the system will ignore
193 all changes made so far and will start the image creation process again.
198 Suppose you want to create a new Ubuntu server image. Download the installation
199 disk from the Internet:
201 .. code-block:: console
203 $ wget http://ubuntureleases.tsl.gr/12.04.1/ubuntu-12.04.1-server-amd64.iso
205 Create a 2G sparce file to host the new system:
207 .. code-block:: console
209 $ truncate -s 2G ubuntu_hd.raw
211 And install the Ubuntu system on this file:
213 .. code-block:: console
215 $ sudo kvm -boot d -drive file=ubuntu_hd.raw,format=raw,cache=none,if=virtio \
216 -cdrom ubuntu-12.04.1-server-amd64.iso
218 After the installation finishes, become root, activate the virtual environment
219 you have installed snf-image-creator in, and use *snf-mkimage* to create and
222 .. code-block:: console
225 $ source /path/to/snf-image-env/bin/activate
226 $ snf-mkimage ubuntu_hd.raw
228 In the first screen you will be asked to choose if you want to run the program
229 in *Wizard* or *Expert* mode. Choose *Wizard*.
231 .. image:: /snapshots/01_wizard.png
233 Then you will be asked to provide a name, a description, an *~okeanos* account
234 and the token corresponding to this account. After that you will be asked to
235 confirm the provided data.
237 .. image:: /snapshots/06_confirm.png
239 Choosing *YES* will create the image and upload it to your *~okeanos* account.
241 Some caveats on image creation
242 ==============================
244 Para-virtualized drivers
245 ------------------------
247 *~Okeanos* uses the *VirtIO* framework. The disk I/O controller and the
248 Ethernet cards on the VM instances are para-virtualized and need special
249 *VirtIO* drivers. Those drivers are included in the Linux Kernel mainline since
250 version 2.6.25 and are shipped with all the popular Linux distributions. The
251 problem is that if the driver for the para-virtualized disk I/O controller is
252 built as module, it needs to be preloaded using an initial ramdisk, otherwise
253 the VM will not be able to boot.
255 In the image creation demonstration above, we initially installed the Ubuntu
256 system on a hard disk (*ubuntu_hd.raw*) that was connected on a
257 para-virtualized interface (pay attention to the *if=virtio* option of the kvm
258 line). Ubuntu and Debian create a generic initial ramdisk file that contains
259 many different modules, including the VirtIO drivers. In many distros this is
260 not the case. In Arch Linux for example, the user needs to manually add
261 *virtio_blk* and *virtio_pci* drivers in */etc/mkinitcpio.conf* and rebuild the
262 initial ramdisk [#f1]_ to make the virtio drivers get preloaded during boot.
263 For now, *snf-image-creator* cannot resolve this kind of problems and it's left
264 to the user to do it.
269 If you want your image to have a swap partitions, make sure this is the last
270 partition on the disk. If snf-image-creator detects a swap partition in the end
271 of the input media, it will remove the partition when shrinking and will save
272 enough information to be able to recreate it during image deployment. This will
273 make the image smaller and will speed up the deployment process.
275 .. rubric:: Footnotes
277 .. [#f1] https://wiki.archlinux.org/index.php/KVM#Paravirtualized_guests_.28virtio.29