{"id":531,"date":"2023-08-06T07:18:59","date_gmt":"2023-08-06T07:18:59","guid":{"rendered":"http:\/\/192.168.0.142\/?p=531"},"modified":"2023-08-10T06:49:14","modified_gmt":"2023-08-10T06:49:14","slug":"composing-a-customized-fedora-image-using-image-builder","status":"publish","type":"post","link":"http:\/\/192.168.0.142\/composing-a-customized-fedora-image-using-image-builder\/","title":{"rendered":"Composing a customized Fedora image using Image Builder"},"content":{"rendered":"\n
Image Builder is a tool that allows you to create custom Fedora OS images. You can use the command line or a Cockpit plugin to work with Image Builder.<\/p>\n\n\n\n
Install Image Builder using below command<\/strong><\/p>\n\n\n\n Enable osbuild-composer.socket<\/strong><\/p>\n\n\n\n To run the composer-cli commands as non-root, user must be in the weldr or root groups.<\/p>\n\n\n\n The newgrp command changes a user’s real group identification. When you run the command, the system places you in a new shell and changes the name of your real group to the group specified with the Group parameter<\/p>\n\n\n\n The first step in using Image Builder is to create the blueprint of the image. The blueprint includes everything the image needs to run. Blueprint files are .toml files<\/p>\n\n\n\n Create file hyrule-os.toml and add below contents<\/strong><\/p>\n\n\n\n Password hash generation<\/strong><\/p>\n\n\n\n Push blueprint<\/strong><\/p>\n\n\n\n Resolve dependencies in the blueprint<\/strong><\/p>\n\n\n\n List blueprints<\/strong><\/p>\n\n\n\n Terminal output for reference<\/strong><\/p>\n\n\n\n List the available image types<\/strong><\/p>\n\n\n\n Terminal output for reference<\/em><\/p>\n\n\n\n Start a compose. It may take several minutes to finish the compose process<\/strong><\/p>\n\n\n\n List all composes and their status<\/strong><\/p>\n\n\n\n Terminal output for reference<\/em><\/p>\n\n\n\n Create the image using below command<\/strong><\/p>\n\n\n\n Terminal output for reference<\/em><\/p>\n\n\n\n Test the image by running below command<\/strong><\/p>\n\n\n\n <\/p>\n\n\n\nsudo dnf install -y osbuild-composer composer-cli cockpit-composer<\/code><\/pre>\n\n\n\n
sudo systemctl enable --now osbuild-composer.socket<\/code><\/pre>\n\n\n\n
sudo usermod -a -G weldr $USER\nnewgrp weldr<\/code><\/pre>\n\n\n\n
Image Blueprint<\/h3>\n\n\n\n
mkdir blueprints && cd blueprints<\/code><\/pre>\n\n\n\n
name = \"hyrule-os\"\ndescription = \"\"\nversion = \"1.0.0\"\nmodules = []\ngroups = []\ndistro = \"\"\n\n[[packages]]\nname = \"ansible-core\"\nversion = \"*\"\n\n[[packages]]\nname = \"podman\"\nversion = \"*\"\n\n[[packages]]\nname = \"skopeo\"\nversion = \"*\"\n\n[customizations]\n\n[[customizations.user]]\nname = \"link\"\npassword = \"$6$st3tG34hIMT10Zrb$WzU\/4OSYY6IqASjpnA0wGNIzemI13pYYqDleQPjLgILE1Gi2HS71fETX2wVkiOg8S.uFnRC9.tYkjCOd8O0a2.\"\ngroups = [\"wheel\"]<\/code><\/pre>\n\n\n\n
python3 -c 'import crypt,getpass;pw=getpass.getpass();print(crypt.crypt(pw) if (pw==getpass.getpass(\"Confirm: \")) else exit())'<\/code><\/pre>\n\n\n\n
composer-cli blueprints push hyrule-os.toml<\/code><\/pre>\n\n\n\n
composer-cli blueprints depsolve hyrule-os<\/code><\/pre>\n\n\n\n
composer-cli blueprints list<\/code><\/pre>\n\n\n\n
$ composer-cli blueprints list\nhyrule-os<\/code><\/pre>\n\n\n\n
composer-cli compose types<\/code><\/pre>\n\n\n\n
$ composer-cli compose types\nami\ncontainer\nimage-installer\niot-commit\niot-container\niot-installer\niot-raw-image\nlive-installer\nminimal-raw\noci\nopenstack\nova\nqcow2\nvhd\nvmdk\nwsl<\/code><\/pre>\n\n\n\n
composer-cli compose start BLUEPRINT COMPOSE-TYPE<\/code><\/pre>\n\n\n\n
$ composer-cli compose start hyrule-os qcow2\nCompose 00d2ec3d-4086-45b6-838c-bd1b8f86f797 added to the queue<\/code><\/pre>\n\n\n\n
composer-cli compose status<\/code><\/pre>\n\n\n\n
$ composer-cli compose status\nID Status Time Blueprint Version Type Size\naa3d9568-4eba-43fc-b653-3c77b6be8e0a FINISHED Wed Aug 9 18:15:59 2023 hyrule-os 1.0.0 qcow2 5368709120<\/code><\/pre>\n\n\n\n
composer-cli compose image UUID<\/code><\/pre>\n\n\n\n
$ composer-cli compose image aa3d9568-4eba-43fc-b653-3c77b6be8e0a \naa3d9568-4eba-43fc-b653-3c77b6be8e0a-disk.qcow2<\/code><\/pre>\n\n\n\n
sudo qemu-kvm --name hyrule-os -m 1024 -hda aa3d9568-4eba-43fc-b653-3c77b6be8e0a-disk.qcow2 <\/code><\/pre>\n\n\n\n