参照先 https://www.molnar-peter.hu/ubuntu-jammy-netinstall-pxe-en.html

ubuntuで自動OSインストールが行えるもの. RHEL系のkickstart同等品かな.

google先生に伺うとOSを手動でインストールすると
RHEL系は「/root/anaconda-ks.cfg」に、ubuntuは「/var/log/installer/autoinstall-user-data」に自動インストール時のヒントがある
と言われるが、、「ubuntu-22.04.2-desktop-amd64.iso」を使ったら出てこなかった...

root@n3:~# cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
 
root@n3:~# ls /var/log/installer/
casper.log            debug              media-info  syslog     version
casper-md5check.json  initial-status.gz  partman     telemetry
 
root@n3:~#

一応「ubuntu-22.04.2-live-server-amd64.iso」を使ったら「/var/log/installer/autoinstall-user-data」が現れた.

root@n3:~# cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
 
root@n3:~# ls -CF /var/log/installer/
autoinstall-user-data  media-info                       subiquity-server-debug.log@
block/                 subiquity-client-debug.log@      subiquity-server-debug.log.2448
casper-md5check.json   subiquity-client-debug.log.2395  subiquity-server-info.log@
curtin-install/        subiquity-client-info.log@       subiquity-server-info.log.2448
curtin-install.log     subiquity-client-info.log.2395
installer-journal.txt  subiquity-curtin-apt.conf
root@n3:~#

っでこの中身ですが。長大で下記のようになってます.

root@n3:~# cat /var/log/installer/autoinstall-user-data
#cloud-config
autoinstall:
  apt:
    disable_components: []
    geoip: true
    preserve_sources_list: false
    primary:
    - arches:
      - amd64
      - i386
      uri: http://jp.archive.ubuntu.com/ubuntu
    - arches:
      - default
      uri: http://ports.ubuntu.com/ubuntu-ports
  drivers:
    install: false
  identity:
    hostname: n3
    password: XXXXXXXXXX
    realname: saber
    username: saber
  kernel:
    package: linux-generic
  keyboard:
    layout: jp
    toggle: null
    variant: ''
  locale: en_US.UTF-8
  network:
    ethernets:
      ens192:
        dhcp4: true
    version: 2
  source:
    id: ubuntu-server-minimal
    search_drivers: false
  ssh:
    allow-pw: true
    authorized-keys: []
    install-server: true
  storage:
    config:
    - ptable: gpt
      path: /dev/sda
      preserve: false
      name: ''
      grub_device: false
      type: disk
      id: disk-sda
    - device: disk-sda
      size: 800063488
      wipe: superblock
      flag: boot
      number: 1
      preserve: false
      grub_device: true
      offset: 1048576
      type: partition
      id: partition-0
    - fstype: fat32
      volume: partition-0
      preserve: false
      type: format
      id: format-0
    - device: disk-sda
      size: 2147483648
      wipe: superblock
      number: 2
      preserve: false
      grub_device: false
      offset: 801112064
      type: partition
      id: partition-1
    - fstype: ext4
      volume: partition-1
      preserve: false
      type: format
      id: format-1
    - device: disk-sda
      size: 134217728
      wipe: superblock
      flag: swap
      number: 3
      preserve: false
      grub_device: false
      offset: 2948595712
      type: partition
      id: partition-2
    - fstype: swap
      volume: partition-2
      preserve: false
      type: format
      id: format-2
    - path: ''
      device: format-2
      type: mount
      id: mount-2
    - device: disk-sda
      size: 14096007168
      wipe: superblock
      number: 4
      preserve: false
      grub_device: false
      offset: 3082813440
      type: partition
      id: partition-3
    - fstype: ext4
      volume: partition-3
      preserve: false
      type: format
      id: format-3
    - path: /
      device: format-3
      type: mount
      id: mount-3
    - path: /boot
      device: format-1
      type: mount
      id: mount-1
    - path: /boot/efi
      device: format-0
      type: mount
      id: mount-0
    swap:
      size: 0
  updates: security
  version: 1
root@n3:~#

「user-data」の作成

autoinstallでは「user-data」と「meta-data」「vendor-data」の3つのファイルで必要で、
前段の「/var/log/installer/autoinstall-user-data」は「user-data」に該当する. 「meta-data」と「vendor-data」は空ファイルでいいみたい.

参照先を元にして作ってみる. 配置場所はwebでデータを取らせるので「/var/www/html/os/ubuntu-22.04.2-live-server-amd64/user-data」とします.
webからは「http://192.168.0.3/os/ubuntu-22.04.2-live-server-amd64/user-data」で読まれます.

[root@c ~]# mkdir /var/www/html/os/ubuntu-22.04.2-live-server-amd64/user-data
[root@c ~]# touch /var/www/html/os/ubuntu-22.04.2-live-server-amd64/{meta-data,vendor-data}
[root@c ~]# vi    /var/www/html/os/ubuntu-22.04.2-live-server-amd64/user-data/user-data
#cloud-config
autoinstall:
  version: 1
  apt:
    disable_components: []
    geoip: true
    preserve_sources_list: false
    primary:
    - arches: [amd64,i386]
      uri: http://jp.archive.ubuntu.com/ubuntu
    - arches:
      - default
      uri: http://ports.ubuntu.com/ubuntu-ports
  drivers:
    install: false
  kernel:
    package: linux-generic
  keyboard:
    layout: jp
    toggle: null
    variant: ''
  source:
    id: ubuntu-server-minimal
    search_drivers: false
  keyboard:
    layout: jp
  storage:
    config:
    - { ptable: gpt, path: /dev/sda, wipe: superblock, preserve: false, name: '', grub_device: false, type: disk, id: disk-sda }
# /boot/efi向け 50MB
    - { device: disk-sda, size: 50M, wipe: superblock, flag: boot, number: 1, preserve: false, grub_device: true, type: partition, id: partition-0 }
    - { fstype: fat32, volume: partition-0, preserve: false, type: format, id: format-0 }
# /boot向け 2GB
    - { device: disk-sda, size: 2G, wipe: superblock, flag: '', number: 2, preserve: false, grub_device: false, type: partition, id: partition-1 }
    - { fstype: ext4, volume: partition-1, preserve: false, type: format, id: format-1 }
# swap向け 128MB
    - { device: disk-sda, size: 128M, wipe: superblock, flag: 'swap', number: 3, preserve: false, grub_device: false, type: partition, id: partition-2 }
    - { fstype: swap, volume: partition-2, preserve: false, type: format, id: format-2 }
# /(root)向け残り全部
    - { device: disk-sda, size: -1, wipe: superblock, flag: '', number: 4, preserve: false, grub_device: false, type: partition, id: partition-3 }
    - { fstype: ext4, volume: partition-3, preserve: false, type: format, id: format-3 }
#
    - { path: /, device: format-3, type: mount, id: mount-3 }
    - { path: /boot, device: format-1, type: mount, id: mount-1 }
    - { path: /boot/efi, device: format-0, type: mount, id: mount-0 }
    swap:
      size: 0
# インストールパッケージ.
  packages: [dnsutils,build-essential,less,vim]
# sshdを有効にして、パスワードログインを許可
  ssh:
    install-server: yes
    allow-pw: yes
  user-data:
    locale: en_US.UTF-8
    timezone: Asia/Tokyo
    users:
    - name: illya
      gecos: 'sample user'
      groups: fgo, users, sudo
      lock_passwd: false
      plain_text_passwd: illya    # 平文のパスワード
      shell: /bin/bash
      ssh_authorized_keys: "ssh-ed25519 xxxxxxxxxxxxxxxxxxx"   # ~/.ssh/authorized_keysに入れてくれます.
      uid: 5000
  late-commands:
    - hostname -A > /target/etc/hostname
    - echo `hostname -I` `hostname -A` >> /target/etc/hosts
[root@c ~]#

メモ:
「user-data:」の中にgroupsを置いてgroupを作ろうとしたが無理だった.

あとはこれをPXEbootの「/var/lib/tftpboot/grub.cfg」に仕込む

menuentry '4) Install ubuntu-22.04.2-live-server-amd64' {
 set gfxpayload=keep
 linuxefi  /ubuntu-22.04.2-live-server-amd64/vmlinuz ip=dhcp url=http://192.168.0.3/os/ubuntu-22.04.2-live-server-amd64.iso autoinstall ds="nocloud-net;s=http://192.168.0.3/os/ubuntu-22.04.2-live-server-amd64/"
 initrdefi /ubuntu-22.04.2-live-server-amd64/initrd
}

bios向け

[root@c ~]# mkdir /var/www/html/os/ubuntu-22.04.2-live-server-amd64-bios
[root@c ~]# touch /var/www/html/os/ubuntu-22.04.2-live-server-amd64-bios/{meta-data,vendor-data}
[root@c ~]# vi /var/lib/tftpboot/pxelinux.cfg/default
 :
 :
label 4
menu label ^4) Install ubuntu 22.04.2 server
  menu default
  kernel ubuntu-22.04.2-live-server-amd64/vmlinuz
  append initrd=ubuntu-22.04.2-live-server-amd64/initrd ip=dhcp autoinstall url=http://192.168.0.3/os/ubuntu-22.04.2-live-server-amd64.iso  ds=nocloud-net;s=http://192.168.0.3/os/ubuntu-22.04.2-live-server-amd64-bios/ ---
 
[root@c ~]#
[root@c ~]# vi /var/www/html/os/ubuntu-22.04.2-live-server-amd64-bios/user-data
#cloud-config
autoinstall:
  version: 1
  apt:
    disable_components: []
    geoip: true
    preserve_sources_list: false
    primary:
    - arches: [amd64,i386]
      uri: http://jp.archive.ubuntu.com/ubuntu
    - arches:
      - default
      uri: http://ports.ubuntu.com/ubuntu-ports
  drivers:
    install: false
  kernel:
    package: linux-generic
  keyboard:
    layout: jp
    toggle: null
    variant: ''
  source:
    id: ubuntu-server-minimal
    search_drivers: false
  keyboard:
    layout: jp
  storage:
    config:
# bios向け変更箇所 「grub_device: true」
    - { ptable: gpt, path: /dev/sda, wipe: superblock-recursive, name: '',                   preserve: false, grub_device: true,  type: disk,      id: disk-sda }
    - { device: disk-sda, size: 1M,                              flag: bios_grub, number: 1, preserve: false, grub_device: false, type: partition, id: partition-0 , partition_type: EF02 }
    - { device: disk-sda, size: 2G,  wipe: superblock,                            number: 2, preserve: false, grub_device: false, type: partition, id: partition-1 }
    - { device: disk-sda, size: 128M,wipe: superblock,           flag: 'swap',    number: 3, preserve: false, grub_device: false, type: partition, id: partition-2 }
    - { device: disk-sda, size: -1,  wipe: superblock,           flag: '',        number: 4, preserve: false, grub_device: false, type: partition, id: partition-3 }
    - { fstype: ext4, volume: partition-1, preserve: false, type: format, id: format-0 }
    - { fstype: swap, volume: partition-2, preserve: false, type: format, id: format-1 }
    - { fstype: ext4, volume: partition-3, preserve: false, type: format, id: format-2 }
#
    - { path: /,     device: format-2, type: mount, id: mount-2 }
    - { path: /boot, device: format-0, type: mount, id: mount-0 }
    swap:
      size: 0
# インストールパッケージ.
  packages: [dnsutils,build-essential,less,vim]
# sshdを有効にして、パスワードログインを許可
  ssh:
    install-server: yes
    allow-pw: yes
  user-data:
    locale: en_US.UTF-8
    timezone: Asia/Tokyo
    users:
    - name: illya
      gecos: 'sample user'
      groups: fgo, users, sudo
      lock_passwd: false
      plain_text_passwd: illya    # 平文のパスワード
      shell: /bin/bash
      ssh_authorized_keys: "ssh-ed25519 xxxxxxxxxxxxxxxxxxx"   # ~/.ssh/authorized_keysに入れてくれます.
      uid: 5000
  late-commands:
    - hostname -A > /target/etc/hostname
    - echo `hostname -I` `hostname -A` >> /target/etc/hosts

ubuntu-desktopは?

むりっぽい. ISOファイルで自動インストールはあるようですが、PXEbootを使うようなのはないっぽい.

最新の60件
2026-09-05 2026-08-31 2026-08-27 2026-08-24 2026-08-20 2026-08-18 2026-08-17 2026-08-16 2026-08-15 2026-08-13 2026-08-12 2026-08-11 2026-08-09 2026-07-30 2026-07-25 2026-07-24 2026-07-20 2026-07-18 2026-07-17 2026-07-16 2026-07-08 2026-07-07 2026-07-06 2026-07-04 2026-07-02 2026-06-27 2026-06-24 2026-06-21 2026-06-17 2026-06-14 2026-06-13 2026-06-09 2026-06-08 2026-06-05 2026-06-04 2026-06-03

edit


トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2023-07-17 (月) 20:14:35