Skip to content

Instantly share code, notes, and snippets.

@allenap
Last active February 18, 2016 16:42
Show Gist options
  • Save allenap/49252ff25768b2f72e65 to your computer and use it in GitHub Desktop.
Save allenap/49252ff25768b2f72e65 to your computer and use it in GitHub Desktop.

How MAAS describes swap to curtin

Swap is a bit special, and must be special-cased in both MAAS and curtin:

  1. Swap can exist:

    • on a whole disk,
    • on a partition with the type 0x82 ("Linux swap / Solaris"),
    • in a file without holes (created with fallocate or dd for example).
  2. Swap must be created with mkswap, not mkfs.${fstype}.

  3. Swap is mounted with swapon, not mount.

  4. Swap is not a filesystem and so is not mounted to a directory.

It would appear that swap more closely resembles a special-case of a block device than of a filesystem. Nevertheless, MAAS models it as a filesystem; the special-cases to handle it thus are fewer and will be more familiar to end-users.

MAAS will support swap on a disk, on a partition, or in a swap file. The latter is already supported; setting Node.swap_size = 1234 will result in {"swap": {"size": "1234B"}} being passed to curtin. This document therefore discusses only swap on a disk or partition.

In the storage configuration that MAAS passes to curtin it may include stanzas like:

- id: sda-part3
  name: sda-part3
  type: partition
  number: 3
  uuid: 53f88413-0568-44cc-b7db-4378bdba7f6e
  size: 1073741824B
  device: sda
  wipe: superblock

- id: sda-part3_format
  type: format
  fstype: swap
  label: swap
  uuid: 0f523f74-e657-4c5d-a11b-b50c4c6b0c73
  volume: sda-part3

- id: sda-part3_mount
  device: sda-part3_format
  options: pri=1,discard=pages
  type: mount

The type: parititon stanza describes the partition on which the swap will be created. This is identical in form to other type: partition stanzas. Note that there is no partition type information; this must be inferred from the fstype in the related type: format stanza.

The type: format stanza describes how the partition will be prepared. In this case, curtin will presumably format using mkswap and may set the partition type to 0x82, but these are implementation details for curtin. This stanza takes the same form as other type: format stanzas.

The type: mount stanza describes mounting (strictly: enabling) the swap area. It differs in form from other type: mount stanzas in that it does not provide a path.

If a type: format stanza for swap is given to curtin without a corresponding type: mount stanza, the swap area should be created but not enabled. It should not be rendered into fstab(5). This is consistent with existing behaviour for other filesystems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment