Add a custom disk layout per node in the MCP model

Add a custom disk layout per node in the MCP model

In MAAS, you can define the disk layout, either flat or Logical Volume Manager (LVM), as well as the partitioning schema per server. This section describes how to define these parameters in the MAAS section of the MCP model. The disk configuration applies during the deployment process. If you want to define the disk configuration after deployment, you can use salt-formula-linux that also has a capability to set up LVM partitioning. But the whole definition for each Volume Group must be either in the maas or linux section, since the linux state cannot override or extend an existing Volume Group created using MAAS but can create a new one.

Caution

You can define the disk configuration in the model before the deployment starts. But be aware that enforcing of this configuration to MAAS using the salt state must be done after servers are commissioned and before they are deployed. Basically, maas.machines.storage works only if a server is in the READY state.

Caution

The maas.machines.storage state overlaps with the linux.storage state. Therefore, we recommend using only one of them. If your deployment requires both, be aware that:

  • The linux.storage configuration must match the maas.machines.storage configuration.

  • MAAS may use an inexplicit mapping. For example, the following MAAS configuration will create an inexplicit mapping to sda1. And this specific sda1 device must be defined in the linux.storage configuration.

    maas:
    ...
         vg0:
           type: lvm
           devices:
             - sda
    ...
    

You can use several options to design the disk layout in a deployment depending on specific use cases. This section includes three most common examples that can be combined to get your desired configuration.

To define a different disk layout with custom parameters

The default layouts used by MAAS are flat and Logical Volume Manager (LVM). Flat layout creates a root partition on the first disk of a server. LVM creates a Volume Group on this partition with one volume per root. By default, in both types of disk layout, the entire space on the first disk is used. If you want to change this behavior, redefine the disk layout parameters.

The following examples illustrate a modified configuration of the default values for partition size as well as LVM names for Volume Group and Logical Volume:

  • Flat layout:

    maas:
      region:
        machines:
          server1:
            disk_layout:
              type: flat
              root_size: 10G    #sda disk has more then 10G
              root_device: sda
              bootable_device: sda
    
  • LVM layout:

    maas:
      region:
        machines:
          server1:
            disk_layout:
              type: lvm
              root_size: 20G    #sda disk has more then 20G
              root_device: sda
              bootable_device: sda
              volume_group: vg0
              volume_name: root
              volume_size: 10G    #If not defined, whole root partition is used.
    

Caution

When defining the disk layout in the model, do not modify the rest of the disk using the MAAS dashboard. Each run of maas.machines.storage deletes and recreates the disk configuration of a server. Currently, this state is not idempotent.

To define a custom partitioning schema

To define a more complex configuration for disks, use the disk section under the disk_layout parameter.

The following example illustrates how to create partitions on the sda disk and a Volume Group with Logical Volumes on the sdb disk. Be aware that sdb is also defined without any partitioning schema. Therefore, you can enforce no partition to be present on sdb. Also, due to the volume_group1 dependency on this device, it must be defined with some configuration in the model. In the example below, it has no partitioning schema.

Example of creating partitions and Logical Volumes:

maas:
  region:
    machines:
      server3:
        disk_layout:
          type: custom
          bootable_device: sda
          disk:
            sda:
              type: physical
              partition_schema:
                part1:
                  size: 10G
                  type: ext4
                  mount: '/'
                part2:
                  size: 2G
                part3:
                  size: 3G
            sdb:
              type: physical
            volume_group1:
              type: lvm
              devices:
                - sdb
              volume:
                tmp:
                  size: 5G
                  type: ext4
                  mount: '/tmp'
                log:
                  size: 7G
                  type: ext4
                  mount: '/var/log'

Caution

The naming convention for partition in MAAS does not allow using custom names. Therefore, key names in YAML for partition are always part1, part2, …, partN.

To define the software RAID

Using the disk section from the previous example, you can create the software RAID on servers. You can use this device for LVM or you can define a partitioning schema directly on this device.

The following example illustrates how to create raid 1 on sda and sdb with the partitioning schema. In this example, we use flat layout that creates a root partition on sda, but this partition is eventually deleted because sda is defined without any partitioning schema.

Example of creating the software RAID disks:

maas:
  region:
    machines:
      server3:
        disk_layout:
          type: custom
          bootable_device: sda
          disk:
            sda:
              type: physical
            sdb:
              type: physical
            md0:
              type: raid
              level: 1
              devices:
                - sda
                - sdb
              partition_schema:
                part1:
                  size: 10G
                  type: ext4
                  mount: '/'
                part2:
                  size: 5G
                part3:
                  size: 25G

To apply changes to MAAS

To enforce the disk configuration on servers in MAAS, run the maas state on a node where the MAAS model is included. Usually, this is the cfg01 node.

salt-call state.sls maas.machines.storage

Now, proceed with the MCP deployment depending on your use case as described in Provision physical nodes using MAAS.