如何使用自动安装进行最小安装?

thi*_*ybk 7 20.04

我正在尝试使用 Ubuntu 服务器 20.04 LTS AMD64 iso 映像构建具有自动安装功能的自定义 Ubuntu 映像。我必须如何配置才能user-data执行最小安装?

小智 0

抱歉,没有答案(如果您找到答案,请回复),但一个丑陋的解决方法是在自动安装用户数据中使用后期命令来删除尽可能多的内容,以便在安装后进行缩小。文档中似乎没有任何内容,源代码中只有一个引用,在我无法破译的示例文件中:https: //github.com/canonical/subiquity/blob/206b7ae678bc1993e1eef46c74efb12f30dbbb43/examples/install-来源.yaml


小智 0

我会用这样的东西。

用户数据:

#cloud-config
autoinstall:
  instance-id: iid-auto-default
  version: 1
  refresh-installer:
    update: yes
    channel: edge
  early-commands:
    - ping -c1 8.8.8.8
    - ip -br -4  -c addr show | head -n 3
    - systemctl stop ssh # otherwise packer tries to connect and exceed max attempt
  apt:
    geoip: true
    preserve_sources_list: false
    primary:
      - arches:
          - amd64
        uri: 'http://nl.archive.ubuntu.com/ubuntu'
      - arches:
          - default
        uri: 'http://ports.ubuntu.com/ubuntu-ports'
  identity:
    hostname: ubuntu
    password: >-
      $6$h.zoLndLImptklKU$RQVTwlPvXno7Zw0f1NpTkoRemOZckpHx3TkMZDc5hC5pZJQoDFwUZPsJnm5bbhxTqmhwu6oDuP.bLH0qDtXON/
    realname: ubuntu
    username: ubuntu
  user-data:
    disable_root: false
  keyboard:
    layout: us
    toggle: null
    variant: ''
  locale: en_US
  ssh:
    allow-pw: true
    authorized-keys: []      
    install-server: false
  packages:
    - ubuntu-desktop-minimal #if you want desktop UI
  late-commands:
    - cp /cdrom/nocloud/post_install.sh /target/opt/
    - curtin in-target --target=/target -- /opt/post_install.sh
  updates: security
  storage: 
    config: 
      - id: disk-sda
        type: disk
        ptable: gpt
        match:
          size: largest
        wipe: superblock
        preserve: false
        name: ''
        grub_device: false
      - id: partition-0
        type: partition
        device: disk-sda
        size: 512M
        wipe: superblock
        flag: boot
        number: 1
        preserve: false
        grub_device: true
      - id: format-0
        type: format
        fstype: fat32
        volume: partition-0
        preserve: false
      - id: partition-1
        type: partition
        device: disk-sda
        size: 1G
        wipe: superblock
        flag: ''
        number: 2
        preserve: false
        grub_device: false
      - id: format-1
        type: format
        fstype: ext4
        volume: partition-1
        preserve: false
      - id: partition-2
        type: partition
        device: disk-sda
        size: -1
        wipe: superblock
        flag: ''
        number: 3
        preserve: false
        grub_device: false
      - id: dm_crypt-0
        type: dm_crypt
        volume: partition-2
        key: ThisIsASecretKey
        preserve: false
      - id: lvm_volgroup-0
        type: lvm_volgroup
        name: ubuntu-vg
        devices:
          - dm_crypt-0
        preserve: false
      - id: lvm_partition-0
        type: lvm_partition
        name: ubuntu-lv
        volgroup: lvm_volgroup-0
        size: -1
        preserve: false
      - id: format-2
        type: format
        fstype: ext4
        volume: lvm_partition-0
        preserve: false
      - id: mount-2
        type: mount
        device: format-2
        path: /
      - id: mount-1
        type: mount
        device: format-1
        path: /boot
      - id: mount-0
        type: mount
        device: format-0
        path: /boot/efi
  system_upgrade:
    enabled: False
  error-commands:
    - tail -n 500 /var/log/syslog | grep -E 'subiquity/Error' -B 100
Run Code Online (Sandbox Code Playgroud)

仅供参考:我目前正在开发具有几种不同配置文件/变体的通用用户数据。现在我正在与持久的环境变量和迟到的命令作斗争