Image Format

Version 33 (Nikos Skalkotos, 12/12/2011 04:52 pm)

1 1 Nikos Skalkotos
h1. Image Format
2 1 Nikos Skalkotos
3 9 Constantinos Venetsanopoulos
The image format (@img_format@) is a required OS Provider parameter and snf-image will complain if not found
4 13 Nikos Skalkotos
Right now we support 4 different types of image formats:
5 8 Constantinos Venetsanopoulos
* @extdump@
6 8 Constantinos Venetsanopoulos
* @ntfsdump@
7 1 Nikos Skalkotos
* @diskdump@
8 13 Nikos Skalkotos
* @custom@ _(unstable)_
9 1 Nikos Skalkotos
10 13 Nikos Skalkotos
h2. extdump & ntfsdump image formats
11 4 Nikos Skalkotos
12 4 Nikos Skalkotos
Those two formats are raw copies (using dd) of partitions hosting Linux systems on ext{2,3,4} and Windows systems on ntfs filesystems respectively.
13 4 Nikos Skalkotos
14 5 Nikos Skalkotos
Partitions hosting a Windows or Linux system that are suitable for dumping should have the following properties:
15 1 Nikos Skalkotos
* Be the first partition in the filesystem
16 5 Nikos Skalkotos
* The OS they host should not depend on any other partitions
17 1 Nikos Skalkotos
* Start at sector 2048
18 13 Nikos Skalkotos
* Have a bootloader installed in the boot sector of the partition (not MBR)
19 5 Nikos Skalkotos
* Have the root device in /etc/fstab specified in a persistent way, using UUID or LABEL (for extdump only)
20 3 Nikos Skalkotos
21 4 Nikos Skalkotos
h3. Known Issues
22 1 Nikos Skalkotos
23 1 Nikos Skalkotos
* For linux systems, having grub installed in the partition is fragile and things can go wrong when resizing the partitions, especially when shrinking.
24 3 Nikos Skalkotos
* Swap space is not supported.
25 3 Nikos Skalkotos
* More complicated partition schemes are not supported.
26 3 Nikos Skalkotos
27 13 Nikos Skalkotos
h2. diskdump image format
28 1 Nikos Skalkotos
29 7 Nikos Skalkotos
Diskdump is a newer format that overcomes most of the aforementioned issues. This format is a raw copy (dd) of a whole disk.
30 1 Nikos Skalkotos
31 7 Nikos Skalkotos
This design decision has the following benefits:
32 5 Nikos Skalkotos
* Swap partitions are supported
33 5 Nikos Skalkotos
* The system may use multiple partitions:
34 5 Nikos Skalkotos
** dedicated partitions for /boot, /home etc in linux
35 5 Nikos Skalkotos
** system and boot partition in Windows
36 7 Nikos Skalkotos
* There are no restrictions on starting sectors of partitions
37 5 Nikos Skalkotos
38 8 Constantinos Venetsanopoulos
Although diskdump is a lot more flexible than the older formats, there are still some rules to follow:
39 5 Nikos Skalkotos
* All devices in fstab should be specified by persistent names (UUID or LABEL)
40 1 Nikos Skalkotos
* LVMs and extended partitions should be avoided.
41 6 Nikos Skalkotos
** The support for extended partitions is partial. snf-image does not support resizing logical partitions.
42 1 Nikos Skalkotos
** Logical volumes are not supported at all
43 1 Nikos Skalkotos
* In Linux disks only ext{2,3,4} filesystems are supported
44 1 Nikos Skalkotos
45 19 Nikos Skalkotos
h2. custom image format
46 6 Nikos Skalkotos
47 24 Nikos Skalkotos
For now, a custom image is a diskdump image whose @img_id@ OS Parameter (see [[:#Ganeti-OS-Interface|Ganeti OS Interface]]) is a URL that points to the image file. *For now, the use of this format is discouraged because it may change in the near future.*
48 13 Nikos Skalkotos
49 13 Nikos Skalkotos
h2. Image Properties
50 13 Nikos Skalkotos
51 23 Nikos Skalkotos
In order for snf-image to be able to properly configure an image, it may make use of a set of image properties. Those image properties are passed to snf-image by Ganeti through the @img_poroperties@ OS parameter (see [[:#Ganeti-OS-Interface|Ganeti OS Interface]]). For the @diskdump@ format some properties are *mandatory*. For {ext,ntfs}dump formats all image properties are optional.
52 1 Nikos Skalkotos
53 10 Nikos Skalkotos
A list of mandatory and optional properties follows:
54 16 Nikos Skalkotos
* Mandatory properties (@diskdump@ only)
55 1 Nikos Skalkotos
** *OSFAMILY={linux,windows}*
56 1 Nikos Skalkotos
This specifies whether the image is a Linux or a Windows Image. {ext,ntfs}dump formats are self descriptive regarding this property.
57 1 Nikos Skalkotos
** *ROOT_PARTITION={1,2,3,4}*
58 13 Nikos Skalkotos
This specifies the partition number of the root partition. As mentioned earlier, for now, only primary partitions are supported. This property is trivial for {ext,ntfs}dump formats (they only host one partition).
59 10 Nikos Skalkotos
* Optional properties
60 10 Nikos Skalkotos
** *USERS="username1 username2...."*
61 30 Nikos Skalkotos
This is a space-seperated list of users, whose password will be reset by snf-image. The use of this property is optional, but highly recommended. For now, if this property is missing, the users are chosen according to a set of rules, but those rules may change or even be dropped in the future. The rules we currently use are listed below:
62 13 Nikos Skalkotos
*** For Windows images, the @Administrator@'s password is reset.
63 13 Nikos Skalkotos
*** For Linux images, the root password is reset for all distribution. If @snf-image@ detects the system as a Fedora or an Ubuntu Linux, then it also resets the password of the user with username @user@.
64 21 Nikos Skalkotos
** *EXCLUDE_ALL_TASKS*
65 28 Nikos Skalkotos
If this property is defined with a value other than _null_, then during the deployment, the image will not be configured at all. This is really handy because it gives the ability to deploy images hosting operating systems whose configuration is not supported by @snf-image@.
66 33 Nikos Skalkotos
** *EXCLUDE_TASK_<task_name>*
67 33 Nikos Skalkotos
This family of properties gives the ability to exclude individual configuration tasks from running. Hence, if the property @EXCLUDE_TASK_DeleteSSHKeys@ with a value other than _null_ is passed to @snf-image@, the aforementioned configuration step will not be executed, and the SSH Keys found in the image will not be removed during the deployment. Task exclusion provides great flexibility, but it needs to be used with great care. Tasks depend on each other and although those dependencies are well documented, automatic task dependency resolution isn't yet supported in @snf-image@. If you exclude task A but not task B which depends on A, you will probably end up with an unsuccessful deployment because B will fail and exit in an abnormal way. You can read more about configuration tasks [[Configuration Tasks|here]].
68 8 Constantinos Venetsanopoulos
69 29 Nikos Skalkotos
h3. OS parameter (img_properties)
70 29 Nikos Skalkotos
71 29 Nikos Skalkotos
Image properties are passed to snf_image through the @img_properties@ OS parameter as a simple json string like the one below:
72 29 Nikos Skalkotos
<pre>
73 29 Nikos Skalkotos
{
74 29 Nikos Skalkotos
     "PROPERTY1": "VALUE1",
75 29 Nikos Skalkotos
     "PROPERTY2": "VALUE2",
76 29 Nikos Skalkotos
     "PROPERTY3": "VALUE3",
77 29 Nikos Skalkotos
     ...
78 29 Nikos Skalkotos
     ...
79 29 Nikos Skalkotos
     ...
80 31 Nikos Skalkotos
     "PROPERTYn": "VALUEn"
81 29 Nikos Skalkotos
 }
82 29 Nikos Skalkotos
</pre>
83 29 Nikos Skalkotos
84 29 Nikos Skalkotos
A real life example for creating a new ganeti instance and passing image properties to @snf-image@ would probably look more like this:
85 29 Nikos Skalkotos
<pre>
86 32 Nikos Skalkotos
gnt-instance add -O img_properties='{"OSFAMILY":"linux"\,"ROOT_PARTITION":"2"\,"USERS":"root guest"}',img_format=diskdump...
87 29 Nikos Skalkotos
</pre>