Howto mkosi: Difference between revisions

From Vidalinux Wiki
Jump to navigation Jump to search
 
(13 intermediate revisions by the same user not shown)
Line 9: Line 9:
  pacman -S debootstrap debian-archive-keyring apt --noconfirm
  pacman -S debootstrap debian-archive-keyring apt --noconfirm
create image:
create image:
  mkosi --distribution debian --release bookworm --format disk --bootable --checksum --root-password password --package linux-image-generic,systemd,systemd-boot,systemd-sysv,udev,dbus --package openssh-client,vim --output debian.img
  mkosi \
--distribution debian \
--release bookworm \
--format disk \
--bootable \
--checksum \
--root-password debian \
--package linux-image-generic,systemd,systemd-boot,systemd-sysv,udev,dbus \
--package openssh-client,vim \
--output debian.img
boot image using systemd:
boot image using systemd:
  systemd-nspawn --boot --image debian.img
  systemd-nspawn --boot --image debian.img
Line 19: Line 28:
  pacman -S  arch-install-scripts --noconfirm
  pacman -S  arch-install-scripts --noconfirm
create image:
create image:
  mkosi --distribution arch --format disk --bootable --checksum --root-password password --package linux,systemd,udev,dbus --package openssh-client,vim --output arch.img
  mkosi \
--distribution arch \
--format disk \
--bootable \
--checksum \
--root-password arch \
--package linux,systemd,udev,dbus \
--package openssh-client,vim \
--output arch.img
boot image using systemd:
boot image using systemd:
  systemd-nspawn --boot --image arch.img
  systemd-nspawn --boot --image arch.img
Line 29: Line 46:
  pacman -S debootstrap ubuntu-keyring apt --noconfirm
  pacman -S debootstrap ubuntu-keyring apt --noconfirm
create image:
create image:
  mkosi --distribution ubuntu --release noble --format disk --bootable --checksum --root-password password --package linux-image-generic,systemd,systemd-boot,systemd-sysv,udev,dbus --package openssh-client,vim --output ubuntu.img
  mkosi \
--distribution ubuntu \
--release noble \
--format disk \
--bootable \
--checksum \
--root-password ubuntu \
--package linux-image-generic,systemd,systemd-boot,systemd-sysv,udev,dbus \
--package openssh-client,vim \
--output ubuntu.img
boot image using systemd:
boot image using systemd:
  systemd-nspawn --boot --image ubuntu.img
  systemd-nspawn --boot --image ubuntu.img
boot image using qemu/kvm:
boot image using qemu/kvm:
  mkosi --output ubuntu.img --qemu-smp 2 qemu
  mkosi --output ubuntu.img --qemu-smp 2 qemu
= create almalinux img =
= create almalinux img =
install the following package using yay:
install the following package using yay:
Line 43: Line 70:
boot image using qemu/kvm:
boot image using qemu/kvm:
  mkosi --output almalinux.img --qemu-smp 2 qemu
  mkosi --output almalinux.img --qemu-smp 2 qemu
= create opensuse img =
= create rhel image =
install the following package using yay:
yay -S zypper-git
create image:
create image:
  mkosi --distribution opensuse --release tumbleweed --format disk --bootable --checksum --root-password password --package bash,coreutils,util-linux,systemd --output opensuse.img
  mkosi \
  --distribution rhel-ubi \
  --release 9 \
  --format disk \
  --bootable \
  --checksum \
  --root-password redhat \
  --package bash,coreutils,util-linux,systemd,rpm \
  --output rhel9.img
boot image using systemd:
systemd-nspawn --boot --image rhel9.img
boot image using qemu/kvm:
mkosi --output rhel9.img --qemu-smp 2 qemu
= build image using mkosi.conf =
create mkosi.conf:
cat >mkosi.conf <<'EOF'
[Output]
Format=disk
Output=centos-stream
ImageVersion=0.0.1
ImageId=centos-stream 
[Distribution]
Distribution=centos
Release=9
Architecture=x86-64
RepositoryKeyCheck=no
[Content]
Packages=kernel-core,bash,coreutils,util-linux,iproute,systemd,systemd-boot,systemd-udev,dnf
Bootable=yes
Bootloader=systemd-boot
WithNetwork=yes
CleanPackageMetadata=yes
Locale=en_US.UTF-8
Timezone=America/Puerto_Rico
Hostname=centos-stream
RootPassword=centos
RootShell=/usr/bin/bash
Autologin=no
WithDocs=no
EOF
create post install script:
cat >mkosi.postinst.chroot <<'EOF'
useradd -c centosuser -G wheel -m centosuser
echo "centosuser:centosuser:" chpasswd
EOF
set file permissions:
chmod +x mkosi.postinst.chroot
check configuration:
mkosi summary
build the image:
mkosi build
boot image using qemu:
mkosi qemu
 
= references =
= references =
* https://github.com/systemd/mkosi
* https://github.com/systemd/mkosi
* http://0pointer.net/blog/mkosi-a-tool-for-generating-os-images.html
* http://0pointer.net/blog/mkosi-a-tool-for-generating-os-images.html
* https://t.co/7WCXbBzaeO
* https://youtu.be/6EelcbjbUa8?si=dkVyul5Yf1E0ysQ4

Latest revision as of 05:21, 15 May 2024

installation

install package on archlinux:

pacman -S mkosi mtools systemd-ukify --noconfirm

create temporary directory to store images:

mkdir mkosimages && cd mkosimages

create debian img

install packages:

pacman -S debootstrap debian-archive-keyring apt --noconfirm

create image:

mkosi \
--distribution debian \
--release bookworm \
--format disk \
--bootable \
--checksum \
--root-password debian \
--package linux-image-generic,systemd,systemd-boot,systemd-sysv,udev,dbus \
--package openssh-client,vim \
--output debian.img

boot image using systemd:

systemd-nspawn --boot --image debian.img

boot image using qemu/kvm:

mkosi --output debian.img --qemu-smp 2 qemu

create arch img

install packages:

pacman -S  arch-install-scripts --noconfirm

create image:

mkosi \
--distribution arch \
--format disk \
--bootable \
--checksum \
--root-password arch \
--package linux,systemd,udev,dbus \
--package openssh-client,vim \
--output arch.img

boot image using systemd:

systemd-nspawn --boot --image arch.img

boot image using qemu/kvm:

mkosi --output arch.img --qemu-smp 2 qemu

create ubuntu img

install packages:

pacman -S debootstrap ubuntu-keyring apt --noconfirm

create image:

mkosi \
--distribution ubuntu \
--release noble \
--format disk \
--bootable \
--checksum \
--root-password ubuntu \ 
--package linux-image-generic,systemd,systemd-boot,systemd-sysv,udev,dbus \
--package openssh-client,vim \
--output ubuntu.img

boot image using systemd:

systemd-nspawn --boot --image ubuntu.img

boot image using qemu/kvm:

mkosi --output ubuntu.img --qemu-smp 2 qemu

create almalinux img

install the following package using yay:

yay -S dnf-legacy-utils 

create image:

mkosi --distribution alma --release 9 --format disk --bootable --checksum --root-password password --package bash,coreutils,util-linux,systemd,rpm --output almalinux.img

boot image using systemd:

systemd-nspawn --boot --image almalinux.img

boot image using qemu/kvm:

mkosi --output almalinux.img --qemu-smp 2 qemu

create rhel image

create image:

mkosi \
 --distribution rhel-ubi \
 --release 9 \
 --format disk \
 --bootable \
 --checksum \
 --root-password redhat \
 --package bash,coreutils,util-linux,systemd,rpm \
 --output rhel9.img

boot image using systemd:

systemd-nspawn --boot --image rhel9.img

boot image using qemu/kvm:

mkosi --output rhel9.img --qemu-smp 2 qemu

build image using mkosi.conf

create mkosi.conf:

cat >mkosi.conf <<'EOF'
[Output]
Format=disk
Output=centos-stream
ImageVersion=0.0.1
ImageId=centos-stream  

[Distribution]
Distribution=centos
Release=9
Architecture=x86-64
RepositoryKeyCheck=no

[Content]
Packages=kernel-core,bash,coreutils,util-linux,iproute,systemd,systemd-boot,systemd-udev,dnf

Bootable=yes
Bootloader=systemd-boot
WithNetwork=yes
CleanPackageMetadata=yes
Locale=en_US.UTF-8
Timezone=America/Puerto_Rico
Hostname=centos-stream
RootPassword=centos
RootShell=/usr/bin/bash
Autologin=no
WithDocs=no
EOF

create post install script:

cat >mkosi.postinst.chroot <<'EOF'
useradd -c centosuser -G wheel -m centosuser
echo "centosuser:centosuser:" chpasswd
EOF

set file permissions:

chmod +x mkosi.postinst.chroot

check configuration:

mkosi summary

build the image:

mkosi build

boot image using qemu:

mkosi qemu

references