Ubuntu – Server autoinstall: How to customise storage section

20.04automatic;cloud-initserver

By following instructionf from here https://wiki.ubuntu.com/FoundationsTeam/AutomatedServerInstalls#Running_a_truly_automatic_autoinstall
When I use for storage:

storage:
  layout:
    name: lvm

It creates root parttition with 4GB and doesn't create swap. When I use direct layout

storage:
  layout:
    name: direct

It creates root partition with full space available on disk and also creates swap. Is there any way to see how it is configured layout direct and modify that configuration to adjust my needs? I mean with action based config like is documented here: https://wiki.ubuntu.com/FoundationsTeam/AutomatedServerInstalls/ConfigReference#storage

I mean something like following:

storage:
  grub:
    install_devices:
      - esp-partition   
  swap:
    filename: swap.img
    size: 4GB
  config:
    - type: disk
      id: disk0
      ptable: gpt
      wipe: superblock
      grub_device: true
      match:
        size: largest

    - id: esp-partition # create partitions on disk (like sda1)
      type: partition
      device: disk0
      size: 512MB
      flag: boot # EFI system partition needs boot flag
    - type: partition
      id: boot-partition
      device: disk0
      size: 1GB
    - type: partition
      device: disk0
      id: root-partition
      size: -1

    - id: esp-partition-fs # format partitions on disk
      type: format
      volume: esp-partition
      fstype: fat32
      label: ESP
    - id: boot-partition-fs
      type: format
      fstype: ext4
      volume: boot-partition
    - id: root-partition-fs
      type: format
      fstype: ext4
      volume: root-partition

    - id: esp-partition-fs-mount # mount partitions
      type: mount
      device: esp-partition-fs
      path: /boot/efi
    - id: root-partition-fs-mount
      type: mount
      path: /
      device: root-partition-fs
    - id: boot-partition-fs-mount
      type: mount
      path: /boot
      device: boot-partition-fs

Above configuration SUCCESS pass FileSystem step but FAIL on initramfs step of cloud-init configuration. Like on screenshot
enter image description here
I would like to know storage configuration for direct layout so I can adjust my configuration above, or if someone know to help me how to fix above configuration so step initramfs pass?

Best Answer

First time through I went through manual install. Then you will find /var/log/installer has yaml files that can be used as a template for the actual autoinstall.yaml that you want. This is what I then constructed to replace Debian installer preseed with aoutinstall.

  storage:
    config:
    - grub_device: true
      id: disk-sda
      path: /dev/sda
      ptable: gpt
      type: disk
      wipe: superblock-recursive
    - device: disk-sda
      flag: bios_grub
      id: partition-0
      number: 1
      size: 1048576
      type: partition
    - device: disk-sda
      id: partition-1
      number: 2
      size: -1
      type: partition
      wipe: superblock
    - fstype: ext4
      id: format-0
      type: format
      volume: partition-1
    - device: format-0
      id: mount-0
      path: /
      type: mount