如何在 Ubuntu 20.04 自动服务器安装上自动安装配置“填充磁盘”选项?

43T*_*cts 4 partitioning cloud-init system-installation 20.04

我正在尝试使用这样的自动安装配置文件安装 20.04 :

用户数据文件:

version: 1
identity:
    hostname: hostname
    username: username
    password: $crypted_pass
Run Code Online (Sandbox Code Playgroud)

但是自动安装过程(将所有内容保留为默认值)不会对磁盘​​进行分区以使用所有空间,即使这似乎是我手动运行安装程序时的默认设置。

手动选择所有默认值后,我storage/var/log/installer/autoinstall-user-data

  storage:
    config:
    - {ptable: gpt, serial: INTEL SSDPEKKF256G8L_BTHH85121P8H256B, wwn: eui.5cd2e42c81a42d1d,
      path: /dev/nvme0n1, wipe: superblock-recursive, preserve: false, name: '', grub_device: true,
      type: disk, id: disk-nvme0n1}
    - {device: disk-nvme0n1, size: 1048576, flag: bios_grub, number: 1, preserve: false,
      type: partition, id: partition-0}
    - {device: disk-nvme0n1, size: 256057016320, wipe: superblock, flag: '', number: 2,
      preserve: false, type: partition, id: partition-1}
    - {fstype: ext4, volume: partition-1, preserve: false, type: format, id: format-0}
    - {device: format-0, path: /, type: mount, id: mount-0}
Run Code Online (Sandbox Code Playgroud)

但是,我不清楚从这里开始我需要在我的用户数据文件中包含什么才能选择“填充磁盘”选项?

And*_*her 6

我没有试过这个,但文档表明负值将“填充”。

来源:https : //wiki.ubuntu.com/FoundationsTeam/AutomatedServerInstalls/ConfigReference#storage

服务器安装程序允许将大小指定为包含设备的百分比。此外,负大小可用于最终分区以指示该分区应使用所有剩余空间。

编辑

我试过了。使用size: -1的最后分区做填充磁盘。我尝试使用size: 100%,并size: -1为LVM逻辑卷使用所有可用空间,它确实没有工作。安装程序align_downsubiquity/models/filesystem.py.

我也尝试过,100%FREEsubiquity出错了dehumanize_size

我还尝试删除 size 属性,lvm_partition因为curtin文档说(在https://curtin.readthedocs.io/en/latest/topics/storage.html

如果省略 size 键,则 volgroup 上的所有剩余空间都将用于逻辑卷。

这并不能作为工作subiquity如果没有错误,size财产

这很不幸,因为对 LVM 卷使用百分比将是一个非常基本的用例

我尝试过的完整存储配置。

  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}
Run Code Online (Sandbox Code Playgroud)

编辑 2

我一直在深入研究这个问题,似乎有时subiquity将磁盘大小存储为浮点数,这导致了未捕获的异常。我实际上能够通过不使用人类可读的格式来解决这个问题。例如,不要size: 512M使用size: 536870912

这是一个示例storage配置,它使用带有属性的自动填充选项,size: -1并且还配置了一个逻辑卷以使用该属性填充卷组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}
Run Code Online (Sandbox Code Playgroud)

看起来浮动错误可能已通过此提交修复,如果使用自动安装程序更新功能可能会避免

https://github.com/CanonicalLtd/subiquity/commit/8a84e470c59e292138482a0b1bd7144fbb4644db#diff-1ca44bce35f59e931cbe850119e630db