I'm using storage section of autoinstal for simple custom /dev/sda disk layout: sda1 (512MB) /boot, sda2 (2GB) swap, sda3 (-1) /. I'm having problem defining swap properly. Curtin docs claim it to be:
- define partition,
- define format with fstype: swap,
- define mount without path with some options: (options: pri=1,discard=pages).
My simple config:
storage:
version: 1
# swap:
# filename: /dev/sda2
# size: 2GB
# maxsize: 2GB
config:
- type: disk
id: sda
path: /dev/sda
ptable: msdos
name: system-disk
wipe: superblock
grub_device: true
- type: partition
id: sda-sda1
number: 1
size: 512MB
device: sda
name: boot-partition
flag: boot
- type: partition
id: sda-sda2
number: 2
size: 2GB
device: sda
name: swap-partition
flag: swap
- type: partition
id: sda-sda3
number: 3
size: -1
device: sda
name: root-partition
- type: format
id: sda-sda1-fs
fstype: ext4
label: boot
volume: sda-sda1
- type: format
id: sda-sda2-fs
fstype: swap
label: swap
volume: sda-sda2
- type: format
id: sda-sda3-fs
fstype: ext4
label: root
volume: sda-sda3
- type: mount
id: sda-sda1-fs-mount1
path: /boot
device: sda-sda1-fs
- type: mount
id: sda-sda2-fs-mount1
options: pri=2,discard=pages
device: sda-sda2-fs
- type: mount
id: sda-sda3-fs-mount1
path: /
device: sda-sda3-fs
At install I get is: "TypeError: __init__() missing 1 required positional argument: 'path'
". If I remove entry with id: sda-sda2-fs-mount1 (the one for swap) and uncomment swap section pointing to /dev/sda2. I get working swap.
How to define swap using only config section. Mixing several solutions is not elegant solution imho.
I'd try adding the argument
path: none
and seeing if that works. Looking at the source for curtin, that appears to be what it does when there is no path value and the file system is 'swap'https://github.com/canonical/curtin/blob/b4f5078663d9cbfd31a7d23b77c458e6a7447226/curtin/commands/block_meta.py#L1107
I have not setup swap like this, but your link is to some guy's four year old gist snippet. The curtin docs are at https://curtin.readthedocs.io/en/latest/topics/storage.html?#mount-command
Quotes from the mount section
I have found the curtin docs to be wrong before, so I found this file that appears to define the schema requirements. I'm not certain how to parse it, but it would seem to me that
path
is not required since you have adevice
argumenthttps://github.com/canonical/curtin/blob/master/curtin/block/schemas.py
There is also the possibility subiquity is what is generating the error. subiquity does its own yaml validation. It uses this schema, but it looks like the
storage
section has no requirements. I'm guessing they rely on curtin for the validationhttps://ubuntu.com/server/docs/install/autoinstall-schema