GenVM - Partitioning

The partitioning support was implemented on GenVM. This page describe the usage of this new feature.

There are 4 possibilities to partition your future system :

  • use a default schema
  • describe partitions in file(s)
  • describe partitions from command line
  • merge files and command line

During a run, GenVM :

  • calculate the feasibility (the size of partitions cumulate compared to the disk image size),
  • make partitions,
  • create filesystems,
  • mount them to install system
  • finally wrote “/etc/fstab” (using UUID) on disk image.

The order of partitions try to be coherent:

  • partitions 1-3 are primary ones
  • if there is more than 3 partitions, the fourth one is extended and all other partitions are created on it.

Use default schema

This is a default comportment so nothing to do to use this schema. An unique partition (numeroted 1), using all space of disk image and created on an msdos table is generate by GenVM.

The partition is formated as extended 4 filesystem.

root@vm:~# fdisk -l

Disk /dev/sda: 5 GiB, 5368709120 bytes, 10485760 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x86c052eb

Device     Boot Start      End  Sectors Size Id Type
/dev/sda1  *     2048 10485757 10483710   5G 83 Linux

root@vm:~# df -h /dev/sda1
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       4.8G  465M  4.1G  11% /

The fstab generated use UUIDs:

root@vm:~# cat /etc/fstab 
# <file system> <dir>   <type>  <options>       <dump>  <pass>
# /dev/sda1
UUID="91900e7a-fa56-449d-af8f-37641c7c4859"     /       ext4    defaults        0       1

Personalized partitioning

In GenVM, partitioning schema is composed of suite of partitions descriptions. The order of partitions descriptions is the order of partitions on disk.

A partition description is a line describing all parameters of partition, on specific order, separate by “:”.

Partition description

As we mention higher, a partition description is a list of parameters ordered and separated by “:”.

Data composing partitions descriptions are :

 <mount point>:<size>:<filesystem>:<options>:<dump>:<checks>:<label>
<mount point>
Absolute path of the directory that is the mount point in the future virtual machine.
If empty, the partition is set has root filesystem “/”. Obviously only one root partition is authorized.
If set to sw or swap the partition is considered as swap one (so filesystem is swap).
First slash could be omit so “srv” is equivalent as “/srv” or “/srv/” (that’s why nothing and “/” are equivalent)
The mount point could be anywhere on your future system (example: /srv/httpd/mysite). The mount order is managed by GenVM.
(Space are authorized in mount points)
Default: /
This is the size of described partition.
If empty, the rest of space available is used, so, only the size of lastest partition could be omit.
The size could be set in Kilo (K), Mega (M), Giga (G), Tera (T) or Peta (P) bits.
Default: All available space
Nothing special here, this describe a filesystem used on this partition.
As you can imagine, tools to format partitions with the chosen filesystem should be available on the machine.
Remember installing appropriate tools on the generate VM (have look on [GenVM - Install additional packages]). Default: ext4
Options to mount partitions. If omit, value is set to “defaults”. All classical values could be used as comma-separated list (no space).
Default: defaults
Value 0 or 1 depending on whether the filesystem should be backed up using the (older) dump utility. The dump utility is seldom used on current systems.
Default: 0
Value 0, 1, or 2 to indicate the order in which the filesystem should be checked (by fsck) at boot time. If 0 appears in this field, the filesystem will not be checked. Normally he root filesystem must be indicated with a 1, to be checked first and other filesystems should have value 2. Default: 1
Currently unused, but design to label (user frendly name) of partitions. Default: empty

Partition description examples

Just some examples of partition description

  • root filesystem on ext4 with “noatime” mount option
  • 100M to “/boot” on xfs
  • 3G on ext4 monted on “/srv/http/my website”
 srv/http/my website:3G

Describe partitions in file

To reproduce the same partitions schema on different virtual machines, you can consign it on a file passed to “genvm” by the command line:

fhh@aaricia ~ $ su -c "genvm -P partitions.txt vm.img"

A file syntax respects some rules :

  • all blank line are ignored
  • all blank at the beginning or end of line are ignored
  • you can use comment, begining by ‘#’ or ‘//’
  • syntax of partition description is describe higher
  • order of partitions description is the order on disk

Using multiple files to partition your system is possible:

fhh@aaricia ~ $ su -c "genvm -P partitions.base.txt -P partitions.webserver.txt vm.img"

result is a same as simple concatenation of partitions files passed to “genvm” like:

fhh@aaricia ~ $ cat partitions.base.txt partitions.webserver.txt > partwebserver.sfdik
fhh@aaricia ~ $ su -c "genvm -P partwebserver.sfdik vm.img"

Example of file

###  Partitions schema ###
# First partition :

# Second one :
 /srv/:100M # Online comment 

:4G:ext4:noatime # root filesystem


# First swap partition :
/var/lib:100 M
# Mount point with space(s) :
/srv/http/my website:3G
# Second swap space with rest of disk

Partitioning from command line

For simples partitioning schema, you can pass partitions descriptions directly from command line :

fhh@aaricia ~ $ su -c "genvm -P :4G:xfs -P swap:512M -P /srv vm.img"

As you can see partitions descriptions are always the same. Oder of descriptions on command line is the same as order on disk.

Example from command line

genvm ... -P /var/:2G:btrfs:defaults:::var -P /srv/:100M \
  -P :4G:ext4:noatime -P swap myvm.vmdk

Partitioning from command line and file

You can combine command line and file to partition your schema. File respect format describe higher in Describe partitions in file.

genvm ... -P boot:200M:ext4 -P partitions.base.txt \
 -P /srv/httpd:10G:xfs -P srv/mysqld:10G -P swap vm.vmdk

This method is equivalent as adding partitions definitions at the beginning or end of partitions files.