How to autoinstall config "fill disk" option on Ubuntu 20.04 Automated Server Insall?
Solution 1:
I have not tried this, but the docs suggest a negative value will 'fill'.
Source: https://wiki.ubuntu.com/FoundationsTeam/AutomatedServerInstalls/ConfigReference#storage
the server installer allows sizes to be specified as percentages of the containing device. Also, a negative size can be used for the final partition to indicate that the partition should use all the remaining space.
edit
I tried this out. Using size: -1
for the final partition did fill the disk. I tried using size: 100%
and size: -1
for an LVM Logical Volume to use all the available space and it did not work. The installer errored in align_down
in subiquity/models/filesystem.py
.
I also tried 100%FREE
but subiquity errored on dehumanize_size
I also tried removing the size property for the lvm_partition
because the curtin docs say (at https://curtin.readthedocs.io/en/latest/topics/storage.html)
If the size key is omitted then all remaining space on the volgroup will be used for the logical volume.
This does not work as subiquity errors if there is no size
property
This is unfortunate as using a percentage for an LVM Volume would be a pretty basic use case
The full storage config I tried.
storage:
grub:
reorder_uefi: False
swap:
size: 0
config:
- {ptable: gpt, path: /dev/sda, preserve: false, name: '', grub_device: false,
type: disk, id: disk-sda}
- {device: disk-sda, size: 512M, wipe: superblock, flag: boot, number: 1,
preserve: false, grub_device: true, type: partition, id: partition-sda1}
- {fstype: fat32, volume: partition-sda1, preserve: false, type: format, id: format-2}
- {device: disk-sda, size: 1G, wipe: superblock, flag: linux, number: 2,
preserve: false, grub_device: false, type: partition, id: partition-sda2}
- {fstype: ext4, volume: partition-sda2, preserve: false, type: format, id: format-0}
- {device: disk-sda, size: -1, flag: linux, number: 3, preserve: false,
grub_device: false, type: partition, id: partition-sda3}
- name: vg-0
devices: [partition-sda3]
preserve: false
type: lvm_volgroup
id: lvm-volgroup-vg-0
- {name: lv-root, volgroup: lvm-volgroup-vg-0, size: 100%, preserve: false,
type: lvm_partition, id: lvm-partition-lv-root}
- {fstype: ext4, volume: lvm-partition-lv-root, preserve: false, type: format,
id: format-1}
- {device: format-1, path: /, type: mount, id: mount-2}
- {device: format-0, path: /boot, type: mount, id: mount-1}
- {device: format-2, path: /boot/efi, type: mount, id: mount-3}
edit 2
I kept digging into this and it seems that sometimes subiquity stores disk sizes as a float, which led to the uncaught exception. I was actually able to work around this by not using human readable format. E.g. instead of size: 512M
, use size: 536870912
.
This is a sample storage
config that uses the autofill option with property size: -1
and also configures a logical volume to fill a volume group with the property size: 100%
storage:
grub:
reorder_uefi: False
swap:
size: 0
config:
- {ptable: gpt, path: /dev/sda, preserve: false, name: '', grub_device: false,
type: disk, id: disk-sda}
- {device: disk-sda, size: 536870912, wipe: superblock, flag: boot, number: 1,
preserve: false, grub_device: true, type: partition, id: partition-sda1}
- {fstype: fat32, volume: partition-sda1, preserve: false, type: format, id: format-2}
- {device: disk-sda, size: 1073741824, wipe: superblock, flag: linux, number: 2,
preserve: false, grub_device: false, type: partition, id: partition-sda2}
- {fstype: ext4, volume: partition-sda2, preserve: false, type: format, id: format-0}
- {device: disk-sda, size: -1, flag: linux, number: 3, preserve: false,
grub_device: false, type: partition, id: partition-sda3}
- name: vg-0
devices: [partition-sda3]
preserve: false
type: lvm_volgroup
id: lvm-volgroup-vg-0
- {name: lv-root, volgroup: lvm-volgroup-vg-0, size: 100%, preserve: false,
type: lvm_partition, id: lvm-partition-lv-root}
- {fstype: ext4, volume: lvm-partition-lv-root, preserve: false, type: format,
id: format-1}
- {device: format-1, path: /, type: mount, id: mount-2}
- {device: format-0, path: /boot, type: mount, id: mount-1}
- {device: format-2, path: /boot/efi, type: mount, id: mount-3}
It looks like the float bug may have been fixed with this commit and might be avoided if the automatic installer update feature is used
https://github.com/CanonicalLtd/subiquity/commit/8a84e470c59e292138482a0b1bd7144fbb4644db#diff-1ca44bce35f59e931cbe850119e630db
Solution 2:
Negative size does work. 2nd partition is set to size -1 and uses all available space.
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