Skip to content

[question] Dockerfile arch example #190

Description

@gertcuykens

Hi not sure if this is the right place to ask for help but i am stuck building a particleos

This is my builder

FROM archlinux:latest AS builder

WORKDIR /root

RUN pacman-key --init && \
    pacman-key --populate archlinux && \
    pacman -Syu --noconfirm && \
    pacman -S --noconfirm \
    git \
    python-uv \
    python-pefile \
    bubblewrap \
    qemu-img \
    systemd \
    binutils \
    ca-certificates \
    openssl \
    cpio \
    erofs-utils \
    dosfstools

RUN git clone --recurse-submodules https://github.com/systemd/particleos osi
RUN rm -f osi/mkosi.bump osi/mkosi.clean
# osi/mkosi.postinst.chroot

RUN mkdir -p osi
WORKDIR /root/osi

RUN uv run --with git+https://github.com/systemd/mkosi.git mkosi genkey

RUN echo "hashed:$(openssl passwd -6 -salt 'mk' 'osi')" > mkosi.rootpw && chmod 0600 mkosi.rootpw

RUN cat << 'EOF' > mkosi.conf
[Distribution]
Distribution=arch

[Build]
ToolsTree=yes

[Content]
Packages=
    linux
    systemd
    openssh
    curl
    iproute2
    nftables
KernelCommandLine=video=1920x1080 console=tty1 console=ttyS0
Bootable=yes
Bootloader=systemd-boot

[Output]
Format=disk
EOF

RUN mkdir -p mkosi.repart/

RUN cat << 'EOF' > mkosi.repart/10-esp.conf
[Partition]
Type=esp
Label=esp
Format=vfat
SizeMinBytes=512M
Weight=0
EOF

RUN cat << 'EOF' > mkosi.repart/20-usr.conf
[Partition]
Type=usr
Label=usr
Format=erofs
SizeMinBytes=512M
Weight=0
EOF

RUN cat << 'EOF' > mkosi.repart/30-root.conf
[Partition]
Type=root
Label=root
Format=ext4
SizeMinBytes=2G
Weight=1000
EOF

RUN mkdir -p mkosi.extra/etc/systemd/system-preset
RUN cat << 'EOF' > mkosi.extra/etc/systemd/system-preset/00-image-defaults.preset
enable systemd-networkd.service
enable systemd-resolved.service
enable sshd.service
EOF

RUN mkdir -p mkosi.extra/etc/systemd/network
RUN cat << 'EOF' > mkosi.extra/etc/systemd/network/20-wired.network
[Match]
Name=en* eth*

[Network]
DHCP=yes
EOF

RUN mkdir -p mkosi.extra/etc
RUN cat << 'EOF' > mkosi.extra/etc/vconsole.conf
KEYMAP=us
FONT=latarcyrheb-sun32
EOF

RUN mkdir -p mkosi.extra/etc/ssh/sshd_config.d
RUN cat << 'EOF' > mkosi.extra/etc/ssh/sshd_config.d/development.conf
PermitRootLogin yes
EOF

RUN mkdir -p /root/out
RUN --security=insecure uv run --with git+https://github.com/systemd/mkosi.git mkosi -B -f -O /root/out build

# RUN echo "Checking out $(date +%s):" && ls -la /root/out/ && false
RUN qemu-img convert -f raw -O qcow2 /root/out/*.raw /root/out/arch.qcow2
RUN qemu-img resize /root/out/arch.qcow2 25G
# RUN echo "Checking img $(date +%s):" && qemu-img info /root/out/arch.qcow2 && false

FROM scratch AS export
COPY --from=builder /root/out/arch.qcow2 /arch.qcow2

This is my qemu launcher

qemu-system-x86_64 \
    -cpu max \
    -m 2G \
    -smp 2 \
    -machine q35 \
    -device virtio-blk-pci,drive=hd0,bootindex=1 \
    -drive if=none,format=qcow2,id=hd0,cache=unsafe,discard=on,file="$IMAGE"\
    -drive if=pflash,format=raw,readonly=on,file="$OVMF_CODE" \
    -drive if=pflash,format=raw,file="$OVMF_LOCAL" \
    -device virtio-net-pci,netdev=net0 \
    -netdev user,id=net0,hostfwd=tcp::2222-:22 \
    -nodefaults \
    -serial mon:stdio \
    -display none

It starts but fails at sysroot-usr.mount and systemd-repart.service that can't see the complete qcow 25G space available

[root@archlinux ~]# lsblk
NAME    MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS
vda     254:0    0    25G  0 disk
├─vda1  254:1    0     1G  0 part
├─vda2  254:2    0   512M  0 part
├─vda3  254:3    0    16K  0 part
├─vda4  254:4    0   400M  0 part
│ └─usr 253:0    0 674.9M  1 crypt /sysusr/usr
├─vda5  254:5    0 674.9M  0 part
│ └─usr 253:0    0 674.9M  1 crypt /sysusr/usr
├─vda6  254:6    0   512M  0 part
└─vda7  254:7    0     2G  0 part  /sysroot
systemctl status sysroot-usr.mount
/sysroot/usr: mount point does not exist

systemctl status systemd-repart.service
Starting Repartition Root Disk...
No machine ID set, using randomized partition UUIDs.
Can't fit requested partitions into available free space (19.9G), refusing
Automatically determined minimal disk image size as 19.2G, current block device/image size is 5G.

Thanks for your help

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions