cloud init – autoinstall encrypt disk on Ubuntu 24.04 Automated Desktop

How can I add encryption in the autoinstall

 storage:
config:
  - ptable: gpt
    path: /dev/nvme0n1
    wipe: superblock-recursive
    preserve: false
    grub_device: true
    type: disk
    id: disk-nvme
  # EFI System Partition (512MB) - Required for UEFI
  - device: disk-nvme
    size: 536870912  # 512MB EFI Partition
    flag: boot  # ✅ Fix: Changed from list [boot, esp] to a single string
    wipe: superblock-recursive
    preserve: false
    grub_device: true
    type: partition
    id: partition-efi
  - fstype: vfat
    volume: partition-efi
    preserve: false
    type: format
    id: format-efi
  - path: /boot/efi
    device: format-efi
    type: mount
    id: mount-efi
  # Boot Partition (2GB)
  - device: disk-nvme
    size: 2147483648  # 2GB Boot Partition
    wipe: superblock
    preserve: false
    grub_device: false
    type: partition
    id: partition-boot
  - fstype: ext4
    volume: partition-boot
    preserve: false
    type: format
    id: format-boot
  - path: /boot
    device: format-boot
    type: mount
    id: mount-boot
  # Root Partition (LVM)
  - device: disk-nvme
    size: -1  # ✅ Takes all remaining space
    wipe: superblock
    preserve: false
    type: partition
    id: partition-root
  # LVM Volume Group
  - volume: partition-root
    preserve: false
    type: lvm_volgroup
    id: vg-root
    name: vg-root
    devices:
      - partition-root
  # Logical Volume for Swap (8GB)
  - volgroup: vg-root
    name: lv-swap
    size: 8G
    type: lvm_partition
    id: lv-swap
  # Logical Volume for Root
  - volgroup: vg-root
    name: lv-root
    size: -1
    type: lvm_partition
    id: lv-root
  # Format and Mount Root Filesystem
  - fstype: ext4
    volume: lv-root
    preserve: false
    type: format
    id: format-root
  - path: /
    device: format-root
    type: mount
    id: mount-root
  # Format and Mount Swap
  - fstype: swap
    volume: lv-swap
    preserve: false
    type: format
    id: format-swap
  - path: ''
    device: format-swap
    type: mount
    id: mount-swap

Read more here: Source link