ການສ້າງອິມເມຈ Fedora IoT ແບບກຳນົດເອງດ້ວຍ image-builder

image-builder ແມ່ນເຄື່ອງມືແບບຄຳສັ່ງ (command-line) ສຳລັບການສ້າງອິມເມຈລະບົບປະຕິບັດການສຳລັບ Fedora, CentOS, ແລະ RHEL. ຄູ່ມືນີ້ຈະອະທິບາຍວິທີການໃຊ້ image-builder ເພື່ອສ້າງອິມເມຈ Fedora IoT ທີ່ປັບແຕ່ງເອງດ້ວຍການເລືອກແພັກເກດ, ການຕັ້ງຄ່າຜູ້ໃຊ້ ແລະ ການກຳນົດຄ່າຕ່າງໆຂອງທ່ານເອງ.

ສຳລັບອິມເມຈ Fedora IoT ທີ່ສ້າງໄວ້ລ່ວງໜ້າໂດຍບໍ່ມີການປັບແຕ່ງ, ໃຫ້ເບິ່ງທີ່ ການຮັບອິມເມຈ.

ການຕິດຕັ້ງ image-builder

ເພື່ອຕິດຕັ້ງ image-builder ໃນ Fedora:

$ sudo dnf install image-builder ostree

ປະເພດອິມເມຈ Fedora IoT ທີ່ມີໃຫ້

image-builder ຮອງຮັບອິມເມຈຫຼາຍປະເພດທີ່ສະເພາະເຈາະຈົງກັບ IoT ສຳລັບສະຖາປັດຕະຍະກຳ x86_64 ແລະ aarch64:

  • iot-commit - OSTree commit tarball (ພື້ນຖານສຳລັບອິມເມຈທີ່ປັບແຕ່ງເອງ)

  • iot-installer - ຕົວຕິດຕັ້ງ Anaconda ISO ສຳລັບການຕິດຕັ້ງແບບໂຕ້ຕອບ

  • iot-simplified-installer - ຕົວຕິດຕັ້ງແບບ Zero-touch ໂດຍໃຊ້ FDO ຫຼື Ignition

  • iot-raw-xz - ອິມເມຈດິສແບບ raw ທີ່ຖືກບີບອັດ ສຳລັບອຸປະກອນຕົວຈິງ (ເຊັ່ນ: Raspberry Pi)

  • iot-qcow2 - ອິມເມຈດິສ QCOW2 ສຳລັບເຄື່ອງຈຳລອງ (virtual machines)

  • iot-container - OCI container ທີ່ມີ OSTree commit

  • iot-bootable-container - ອິມເມຈຄອນເທນເນີທີ່ສາມາດບູດໄດ້

ເພື່ອສະແດງລາຍການປະເພດອິມເມຈ IoT ທັງໝົດທີ່ມີໃຫ້:

$ image-builder list | grep iot

ການສ້າງອິມເມຈ Fedora IoT ແບບກຳນົດເອງ

ຂັ້ນຕອນການເຮັດວຽກທົ່ວໄປໃນການສ້າງອິມເມຈ Fedora IoT ທີ່ປັບແຕ່ງເອງແມ່ນ:

  1. ສ້າງ blueprint ທີ່ອະທິບາຍການປັບແຕ່ງຂອງທ່ານ

  2. ສ້າງ custom OSTree commit ພ້ອມກັບການປ່ຽນແປງຂອງທ່ານ

  3. ເປີດໃຫ້ບໍລິການ OSTree commit ພາຍໃນເຄື່ອງ (locally)

  4. ສ້າງສື່ການຕິດຕັ້ງ ຫຼື ອິມເມຈດິສຈາກ custom commit ຂອງທ່ານ

ຂັ້ນຕອນທີ 1: ການສ້າງ Blueprint

Blueprint ແມ່ນໄຟລ໌ TOML ທີ່ອະທິບາຍການປັບແຕ່ງສຳລັບອິມເມຈຂອງທ່ານ. ມັນຊ່ວຍໃຫ້ທ່ານສາມາດ:

  • ເພີ່ມ ຫຼື ລົບແພັກເກດ

  • ຕັ້ງຄ່າຜູ້ໃຊ້ ແລະ ກຸ່ມ

  • ຕັ້ງຄ່າ SSH keys

  • ຕັ້ງຄ່າລະບົບ

ສ້າງໄຟລ໌ blueprint (ຕົວຢ່າງ: iot-custom.toml):

name = "iot-custom"
description = "Custom Fedora IoT Image"
version = "0.0.1"

[[packages]]
name = "vim-enhanced"

[[packages]]
name = "htop"

[[packages]]
name = "tmux"

[[customizations.user]]
name = "admin"
description = "Admin User"
password = "$6$rounds=4096$saltsalt$encrypted_password_hash"
groups = ["wheel"]

[[customizations.sshkey]]
user = "admin"
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExample admin@workstation"
ສ້າງລະຫັດຜ່ານທີ່ເຂົ້າລະຫັດດ້ວຍ openssl passwd -6 (ຈະມີການຖາມຫາລະຫັດຜ່ານແບບໂຕ້ຕອບ)

ຂັ້ນຕອນທີ 2: ການສ້າງ Custom OSTree Commit

ສ້າງ OSTree commit tarball ພ້ອມກັບການປັບແຕ່ງຂອງທ່ານ. ໃຊ້ຮູບແບບການຕັ້ງຊື່ ref ຢ່າງເປັນທາງການ (fedora/stable, fedora/devel, ຫຼື fedora/rawhide):

$ sudo image-builder build iot-commit \
  --distro fedora-43 \
  --blueprint iot-custom.toml \
  --ostree-ref fedora/stable/x86_64/iot \
  --output-dir ./iot-commit-output

# ໝາຍເຫດ ສຳລັບ aarch64 ໃຫ້ໃຊ້ `fedora/stable/aarch64/iot`

ນີ້ຈະສ້າງໄຟລ໌ tarball ທີ່ບັນຈຸ custom OSTree commit ຂອງທ່ານ.

ຂັ້ນຕອນທີ 3: ການຕັ້ງຄ່າຄັງເກັບ OSTree ພາຍໃນເຄື່ອງ

ແຕກໄຟລ໌ commit tarball ແລະ ເປີດໃຫ້ບໍລິການຄັງເກັບ OSTree:

$ tar -xf ./iot-commit-output/*.tar
$ mv repo ostree-repo
$ cd ostree-repo
$ python3 -m http.server 8000

ໄຟລ໌ tarball ປະກອບມີໂຟນເດີ repo/ ທີ່ມີຄັງເກັບ OSTree ທີ່ສົມບູນ. ເພື່ອເປີດ HTTP server ໃນພື້ນຫຼັງ, ໃຫ້ເພີ່ມ & ຢູ່ທ້າຍ:

$ python3 -m http.server 8000 &

ຄັງເກັບ custom OSTree ຂອງທ່ານພ້ອມໃຊ້ງານແລ້ວທີ່ http://localhost:8000

ເພື່ອກວດສອບວ່າຄັງເກັບຖືກຕັ້ງຄ່າຢ່າງຖືກຕ້ອງ:

$ ostree --repo=./ostree-repo refs
$ curl http://localhost:8000/refs/heads/fedora/stable/x86_64/iot

ການສ້າງອິມເມຈຈາກ Custom OSTree ຂອງທ່ານ

ເມື່ອມີ custom OSTree commit ທີ່ເປີດໃຫ້ບໍລິການພາຍໃນເຄື່ອງແລ້ວ, ທ່ານສາມາດສ້າງອິມເມຈປະເພດຕ່າງໆໄດ້.

ການສ້າງຕົວຕິດຕັ້ງ ISO

ສ້າງຕົວຕິດຕັ້ງ Anaconda ISO ທີ່ຈະຕິດຕັ້ງ Fedora IoT ທີ່ທ່ານປັບແຕ່ງເອງ:

$ sudo image-builder build iot-installer \
  --distro fedora-43 \
  --ostree-url http://localhost:8000 \
  --ostree-ref fedora/stable/x86_64/iot \
  --output-dir ./images

ການສ້າງຕົວຕິດຕັ້ງແບບ Simplified

ຕົວຕິດຕັ້ງແບບ simplified ໃຫ້ການຕິດຕັ້ງແບບ zero-touch ໂດຍໃຊ້ FDO ຫຼື Ignition:

$ sudo image-builder build iot-simplified-installer \
  --distro fedora-43 \
  --ostree-url http://localhost:8000 \
  --ostree-ref fedora/stable/x86_64/iot \
  --output-dir ./images

ເບິ່ງ ການບູດ Simplified Provisioner ສຳລັບລາຍລະອຽດເພີ່ມເຕີມ.

ການສ້າງ Raw Disk Images

ສຳລັບຄອມພິວເຕີບອດດ່ຽວເຊັ່ນ Raspberry Pi, ໃຫ້ສ້າງອິມເມຈດິສແບບ raw ທີ່ຖືກບີບອັດ:

$ sudo image-builder build iot-raw-xz \
  --distro fedora-43 \
  --arch aarch64 \
  --ostree-url http://localhost:8000 \
  --ostree-ref fedora/stable/aarch64/iot \
  --output-dir ./images

ອິມເມຈເຫຼົ່ານີ້ສາມາດຂຽນລົງໃນ SD cards ຫຼື ສື່ເກັບຂໍ້ມູນອື່ນໆໄດ້ໂດຍກົງ.

ການສ້າງອິມເມຈ QCOW2 ສຳລັບ VMs

ສຳລັບການທົດສອບໃນເຄື່ອງຈຳລອງ (virtual machines):

$ sudo image-builder build iot-qcow2 \
  --distro fedora-43 \
  --ostree-url http://localhost:8000 \
  --ostree-ref fedora/stable/x86_64/iot \
  --output-dir ./images

ການສ້າງ Container Images

ສ້າງ OCI container ດ້ວຍ OSTree commit ຂອງທ່ານ:

$ sudo image-builder build iot-container \
  --distro fedora-43 \
  --ostree-url http://localhost:8000 \
  --ostree-ref fedora/stable/x86_64/iot \
  --output-dir ./images

ສ້າງອິມເມຈຄອນເທນເນີທີ່ສາມາດບູດໄດ້ ສຳລັບຂັ້ນຕອນການເຮັດວຽກແບບ container-native ທີ່ທັນສະໄໝ:

$ sudo image-builder build iot-bootable-container \
  --distro fedora-43 \
  --ostree-url http://localhost:8000 \
  --ostree-ref fedora/stable/x86_64/iot \
  --output-dir ./images

ເບິ່ງ Fedora IoT Bootc ສຳລັບຂໍ້ມູນເພີ່ມເຕີມກ່ຽວກັບບູດຄອນເທນເນີ.

ການເປີດໃຫ້ບໍລິການຄັງເກັບ OSTree ຂອງທ່ານໃຫ້ເຄື່ອງອື່ນໆ

ເພື່ອເຮັດໃຫ້ຄັງເກັບ OSTree ຂອງທ່ານສາມາດໃຊ້ໄດ້ກັບເຄື່ອງອື່ນໆໃນເຄືອຂ່າຍຂອງທ່ານ:

$ cd ostree-repo
$ python3 -m http.server 8000 --bind 0.0.0.0 &
& ໃຊ້ເພື່ອເປີດ server ໃນພື້ນຫຼັງ. ເພື່ອຢຸດມັນໃນພາຍຫຼັງ, ໃຫ້ໃຊ້ pkill -f "http.server 8000"

ຈາກນັ້ນໃຫ້ໃຊ້ IP address ຂອງເຄື່ອງທ່ານເມື່ອສ້າງອິມເມຈໃນລະບົບອື່ນ:

$ sudo image-builder build iot-installer \
  --distro fedora-43 \
  --ostree-url http://192.168.1.100:8000 \
  --ostree-ref fedora/stable/x86_64/iot \
  --output-dir ./images

ທາງເລືອກຂັ້ນສູງ

ການເພີ່ມຄັງເກັບ (Repositories) ເພີ່ມເຕີມ

ເພີ່ມຄັງເກັບແພັກເກດເພີ່ມເຕີມໃນລະຫວ່າງການສ້າງ OSTree commit (ບໍ່ໄດ້ລວມຢູ່ໃນອິມເມຈສຸດທ້າຍ):

$ sudo image-builder build iot-commit \
  --distro fedora-43 \
  --blueprint iot-custom.toml \
  --ostree-ref fedora/stable/x86_64/iot \
  --extra-repo "https://example.com/repo/fedora/43/x86_64" \
  --output-dir ./iot-commit-output
ຄັງເກັບເພີ່ມເຕີມຈະບໍ່ຖືກກວດສອບ GPG ແລະ ຖືກໃຊ້ສະເພາະໃນລະຫວ່າງການສ້າງ commit ເທົ່ານັ້ນ.

ການປັບແຕ່ງຊື່ໄຟລ໌ຜົນອອກ

ປັບແຕ່ງຊື່ໄຟລ໌ຜົນອອກສຳລັບອິມເມຈຂອງທ່ານ:

$ sudo image-builder build iot-installer \
  --distro fedora-43 \
  --ostree-url http://localhost:8000 \
  --ostree-ref fedora/stable/x86_64/iot \
  --output-name my-custom-installer \
  --output-dir ./images

ການສະແດງຜົນແບບ Verbose ເພື່ອກວດສອບຂໍ້ຜິດພາດ

ເປີດໂໝດ verbose ເພື່ອເບິ່ງຂໍ້ມູນການສ້າງແບບລະອຽດ:

$ sudo image-builder build iot-commit \
  --distro fedora-43 \
  --blueprint iot-custom.toml \
  --ostree-ref fedora/stable/x86_64/iot \
  --verbose \
  --output-dir ./iot-commit-output

ການສົ່ງອອກ Build Artifacts

ສົ່ງອອກ OSBuild manifest ແລະ build log ສຳລັບການແກ້ໄຂບັນຫາ:

$ sudo image-builder build iot-commit \
  --distro fedora-43 \
  --blueprint iot-custom.toml \
  --ostree-ref fedora/stable/x86_64/iot \
  --with-manifest \
  --with-buildlog \
  --output-dir ./iot-commit-output

ການເບິ່ງລາຍລະອຽດຂອງປະເພດອິມເມຈ

ເພື່ອເບິ່ງຂໍ້ມູນລະອຽດກ່ຽວກັບອິມເມຈ IoT ປະເພດໃດໜຶ່ງ:

$ image-builder describe iot-installer --distro fedora-43
$ image-builder describe iot-qcow2 --distro fedora-43 --arch aarch64
$ image-builder describe iot-simplified-installer --distro fedora-43

ນີ້ຈະສະແດງແພັກເກດ, pipelines ແລະ ທາງເລືອກການຕັ້ງຄ່າສຳລັບອິມເມຈແຕ່ລະປະເພດ.

ຂໍ້ແນະນຳທີ່ດີທີ່ສຸດ

  1. ທົດສອບດ້ວຍ QCOW2 ກ່ອນ - ສ້າງ ແລະ ທົດສອບອິມເມຈ iot-qcow2 ໃນ VMs ກ່ອນຈະສ້າງສື່ການຕິດຕັ້ງ

  2. ໃຊ້ລະບົບຄວບຄຸມເວີຊັນສຳລັບ Blueprint - ເກັບໄຟລ໌ blueprint ໄວ້ໃນ git ເພື່ອຕິດຕາມການປັບແຕ່ງ

  3. ຫຼຸດຜ່ອນການເພີ່ມແພັກເກດ - ເພີ່ມສະເພາະແພັກເກດທີ່ຈຳເປັນ; ໃຊ້ຄອນເທນເນີສຳລັບແອັບພລິເຄຊັນ

  4. ໃຊ້ລະຫັດຜ່ານທີ່ເຂົ້າລະຫັດ - ຫ້າມໃຊ້ລະຫັດຜ່ານແບບຂໍ້ຄວາມທຳມະດາໃນ blueprint

  5. ເປີດໂໝດ Verbose ເມື່ອມີບັນຫາ - ໃຊ້ --verbose ເມື່ອກວດສອບຫາສາເຫດຂອງບັນຫາການສ້າງ

ການແກ້ໄຂບັນຫາ

ການສ້າງຫຼົ້ມເຫຼວດ້ວຍຂໍ້ຜິດພາດ OSTree

ກວດສອບວ່າຄັງເກັບ OSTree ພາຍໃນເຄື່ອງຖືກຕັ້ງຄ່າຢ່າງຖືກຕ້ອງ ແລະ ມີ ref ຢູ່ຈິງ:

$ ostree --repo=./ostree-repo refs
$ ostree --repo=./ostree-repo show fedora/stable/x86_64/iot

ກວດສອບໃຫ້ແນ່ໃຈວ່າ HTTP server ຂອງທ່ານກຳລັງເຮັດວຽກ ແລະ ສາມາດເຂົ້າເຖິງໄດ້:

$ curl http://localhost:8000/config
$ curl http://localhost:8000/refs/heads/fedora/stable/x86_64/iot

ຂໍ້ຜິດພາດການປະຕິເສດສິດ (Permission Denied)

ການເຮັດວຽກສ່ວນໃຫຍ່ຂອງ image-builder ຕ້ອງການສິດ root:

$ sudo image-builder build iot-installer ...

ພື້ນທີ່ດິສບໍ່ພຽງພໍ

ການສ້າງອິມເມຈຕ້ອງການພື້ນທີ່ດິສພໍສົມຄວນ. ໃຫ້ແນ່ໃຈວ່າມີພື້ນທີ່ຫວ່າງຢ່າງໜ້ອຍ 10GB ໃນ:

  • /var/cache/image-builder/ (build cache)

  • ໂຟນເດີຜົນອອກ (Output directory)

ລຶບ cache ຖ້າຈຳເປັນ:

$ sudo rm -rf /var/cache/image-builder/store/*

ແຫຼ່ງຂໍ້ມູນເພີ່ມເຕີມ