Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by nld3-dev1.alpinelinux.org (Postfix) with ESMTPS id 3D054781408 for <~alpine/users@lists.alpinelinux.org>; Thu, 5 May 2022 23:30:01 +0000 (UTC) Received: by mail-pf1-f171.google.com with SMTP id v11so4867116pff.6 for <~alpine/users@lists.alpinelinux.org>; Thu, 05 May 2022 16:30:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xwb+74bUFoalTx8SOTRndSUQLH0gKp5LWRnH6V+3oio=; b=hRr4y6PpXFJE7h1Q5GF61KqImjgZGVPodLWdhMmfhG8V9OU/8ySwuXYCO2AAEwaFMA YrZ9jjTUHSEM3U7EJQo0Lbk3bvLvjYFt0aj6GH4nlwS8vAyevnTNY/UQ7Jl8DBiyhKB8 dadG4vjrY8ZeoER0fuV3RQtQq4q/OmpUksmOkg+wK2G1UqwTTsVKPSN8fGX6ZoEyWgPy B2UYtpfVb0WsKLpK1D+bKZnGyXKYkIyMJSiuS6OLDwz1f7MIWZ3oB+CiOzWTrzKeutOh On5GxgEpk/Ub7o5+rRA1GE7LaiKTWfFQi3WAdSTxI6iY2HWE1KLjSr6BSdthh6uSWsUW Ae8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xwb+74bUFoalTx8SOTRndSUQLH0gKp5LWRnH6V+3oio=; b=nNZhOKdr2bz/g9nMNcbf7zH5VCGq+jRBgBfvxKKvVbIdqEMXFF7fv7upg2GwWV57Lu i1jImsoh4+47pOdh1L71SIqBQVX/i3pEp3malkmZTo73GlhSUpX7YGfh35atN2j+9QCI yeUH8M1u/Xjg9usUX6imYH57QX/W9BTFLe22rKmatay0DYXUQvbVxBEXcO0NEzqmL3cO uPWoVqTd06Gfuhj/CYWyyNp602jwSROiR82UNWeqtr9wc+A/282tOmPSSSuEliAowwl5 OvViPMojkvXEOKc9FP+LylzCgRRHCZkazgJ72F3SvHHdhwEBdvC7x02k5mgtZV63cqn3 oaUA== X-Gm-Message-State: AOAM531Shav663fxfzsnVm6ID785QlJMfw22nuge7Tb8Wy0Mrmusedvj U9tCsvdybd8y+zWPu6uoWhPjUb6cynO2t2pbgBE= X-Google-Smtp-Source: ABdhPJy6b71dr2QY+SdLRv3/O4CC4nJw+DRXWy3cg+MaABjX0nTBwezzFJivqDpjh0fP55r04LeKGS7B2WbgQjjobVk= X-Received: by 2002:a63:a512:0:b0:3c6:d89:1021 with SMTP id n18-20020a63a512000000b003c60d891021mr450893pgf.126.1651793399198; Thu, 05 May 2022 16:29:59 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Hokus Pokus Date: Fri, 6 May 2022 01:29:48 +0200 Message-ID: Subject: Re: Custom Alpine Linux build To: Konstantin Kulikov Cc: ~alpine/users@lists.alpinelinux.org Content-Type: multipart/alternative; boundary="000000000000cd37c605de4c1eed" --000000000000cd37c605de4c1eed Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Konstantin, pt., 6 maj 2022 o 00:25 Hokus Pokus napisa=C5=82= (a): > Hi Konstantin, > > Thank you for the fast answer. > > =C5=9Br., 4 maj 2022 o 20:45 Konstantin Kulikov > napisa=C5=82(a): > >> You've basically described initramfs. Take a look at mkinitfs, which >> is what alpine uses. >> > > Correct me if I am wrong (as I lack experience in playing with initramfs > etc.): > 1) I download this repo on top of my normal Alpine Edge install > 2) During build it will create initramfs image based on binaries, kernel, > kernel modules and firmware of host operating system > 3) I can "steal" this built result initramfs file together with kernel > vmlinuz from /boot > 4) Instead of starting normal /sbin/init (which is OpenRC for Alpine) > I can use this kernel + initramfs combo to start my script which I want > to become init process instead of OpenRC > 5) As this initramfs is created from the live system it will inherit all > the > installed firmware blobs so my final "init-like" script will be running o= n > top > of fully working hardware (as long this hardware was working with Alpine > Edge install I used to build this initramfs). > > Sorry for putting this as a short list but it is easier for me to > understand it > steep by steep. > Please skip my stupid questions above - I just checked the repo again and now I think I understand how it works: 1) mkinitfs collects binaries, kernel modules and firmware from the host and creates initramfs file out of it ("mkinitfs -l" shows the full list of used files) 2) When kernel boots it loads initramfs file which inside has all needed directories, binaries, configs, kernel modules and firmware file= s 3) Now it starts "initramfs stage" init which is "initramfs-init" script (from the repo) 4) This script is responsible for final phase - mount real filesystem, switch_root and start final /sbin/init (which is OpenRC in case of Alpine). > > >> >> https://git.alpinelinux.org/mkinitfs/tree >> >> On Wed, May 4, 2022 at 6:12 PM Hokus Pokus >> wrote: >> > >> > Hi all, >> > >> > I have a question related to custom OS based on Alpine Linux. >> > >> > First let me describe the current state: >> > Hardware environment: >> > - Dell server (PowerEdge R630) >> > - 4 PCI Ethernet cards (QLogic 577xx/578xx 10Gb Ethernet BCM57800) >> > - 16G RAM >> > - 120G SSD >> > ISO image I use: alpine-extended-3.15.4-x86_64.iso >> > Everything is working fine, I am able to configure network cards, >> > communicate with the world, update system etc. >> > Those PCI network cards uses bnx2x modules and closed source >> > firmware blobs from /lib/firmware (bnx2x package) if I am correct. >> > It is working fine so far. >> > >> > Now the target: I want to make this install even smaller. >> > The purpose of this new OS will be to: >> > 1) Boot from hard drive >> > 2) Load this new minimal "alpine based OS" rootfs >> > with only needed set of binaries / libraries >> > 3) Replace the whole init and /etc/init.d with single script >> > which become new init process >> > 4) This script-init will initialize all the hardware >> > 5) This script-init will download encrypted disk image >> > 6) This script-init will unpack encrypted disk image >> > 7) This script-init will mount encrypted disk image >> > 8) This script-init will chroot to encrypted disk image >> > and continue there after pivot will be completed. >> > >> > So the new Alpine based OS I want to make will be sort of >> > bootstrap for another OS (linux) and as such needs only >> > minimum set of functions. I plan to remove all binaries and libraries >> > which are not needed as only purpose of this OS will be >> > to start hardware, get network working and download file >> > from remote server. From the same reason I would like to replace >> > the whole init and init.d scripts with single init.sh script called >> > by kernel after boot. >> > >> > If someone has done something similar already and can point me which >> > part of the Alpine system are core for the system functionality? >> > >> > Alpine is using mdev for device management. What else I need to have >> > for binary blobs drivers working with linux kernel? Just /etc/mdev.con= f >> in place >> > and call "mdev -s" in the init script? Or there is more complicated >> > hardware initialization procedure which I need to reproduce in my >> "init.sh" >> > script? Should I just copy-paste some of /etc/init.d scripts and put >> > them in one file in the right order? >> > >> > If I can go even further - replace the kernel with it modules by the >> monolithic >> > kernel which has all needed modules compiled inside? This way if I wil= l >> still >> > need mdev for loading external firmware blobs? >> > >> > I was trying to find similar question on mailing lists and general >> forums >> > but I failed. >> > >> > Best regards, >> > Pawel >> > >> > -- >> > Pozdrawiam >> > >> > Pawe=C5=82 Po=C5=82awski >> > > > -- > Pozdrawiam > > Pawe=C5=82 Po=C5=82awski > --=20 Pozdrawiam Pawe=C5=82 Po=C5=82awski --000000000000cd37c605de4c1eed Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Konstantin,

pt., 6 maj 2022 o 00:25= =C2=A0Hokus Pokus <pawel.pol= awski@gmail.com> napisa=C5=82(a):
Hi Konstantin,
Thank you for the fast answer.

=C5=9Br., 4 maj 2022 o 20:45= =C2=A0Konstantin Kulikov <k.kulikov2@gmail.com> napisa=C5=82(a):
You've basically described in= itramfs. Take a look at mkinitfs, which
is what alpine uses.

Correct me if I am= wrong (as I lack experience in playing with initramfs etc.):
1) = I download this repo on top of my normal Alpine Edge install
2) D= uring build it will create initramfs image based on binaries, kernel,
=
kernel modules and firmware of host operating system
3) I ca= n "steal" this built result initramfs file together with kernel v= mlinuz from /boot
4) Instead of starting normal /sbin/init (which= is OpenRC for Alpine)
I can use this kernel + initramfs combo to= start my script which I want
to become init process instead of O= penRC
5) As this initramfs is created from the live system it wil= l inherit all the
installed firmware blobs so my final "init= -like" script will be running on top
of fully working hardwa= re (as long this hardware was working with Alpine
Edge install I = used to build this initramfs).

Sorry for putting t= his as a short list but it is easier for me to understand it
stee= p by steep.

Please sk= ip my stupid questions above - I just checked the repo again and
= now I think I understand how it works:
1) mkinitfs collects binar= ies, kernel modules and firmware from the host
and creates initra= mfs file out of it ("mkinitfs -l" shows the full list of used fil= es)
2) When kernel boots it loads initramfs file which insid= e has
all needed directories, binaries, configs, kernel modules a= nd firmware files
3) Now it starts "initramfs stage"= ; init which is "initramfs-init" script (from the repo)
=
4) This script is responsible for final phase - mount real filesystem,= switch_root
and start final /sbin/init (which is OpenRC in c= ase of Alpine).

=C2=A0
=C2=A0

https://git.alpinelinux.org/mkinitfs/tree

On Wed, May 4, 2022 at 6:12 PM Hokus Pokus <pawel.polawski@gmail.com> wrote: >
> Hi all,
>
> I have a question related to custom OS based on Alpine Linux.
>
> First let me describe the current state:
> Hardware environment:
> - Dell server (PowerEdge R630)
> - 4 PCI Ethernet cards (QLogic 577xx/578xx 10Gb Ethernet BCM57800)
> - 16G RAM
> - 120G SSD
> ISO image I use: alpine-extended-3.15.4-x86_64.iso
> Everything is working fine, I am able to configure network cards,
> communicate with the world, update system etc.
> Those PCI network cards uses bnx2x modules and closed source
> firmware blobs from /lib/firmware (bnx2x package) if I am correct.
> It is working fine so far.
>
> Now the target: I want to make this install even smaller.
> The purpose of this new OS will be to:
> 1) Boot from hard drive
> 2) Load this new minimal "alpine based OS" rootfs
> with only needed set of binaries / libraries
> 3) Replace the whole init and /etc/init.d with single script
> which become new init process
> 4) This script-init will initialize all the hardware
> 5) This script-init will download encrypted disk image
> 6) This script-init will unpack encrypted disk image
> 7) This script-init will mount encrypted disk image
> 8) This script-init will chroot to encrypted disk image
> and continue there after pivot will be completed.
>
> So the new Alpine based OS I want to make will be sort of
> bootstrap for another OS (linux) and as such needs only
> minimum set of functions. I plan to remove all binaries and libraries<= br> > which are not needed as only purpose of this OS will be
> to start hardware, get network working and download file
> from remote server. From the same reason I would like to replace
> the whole init and init.d scripts with single init.sh script called > by kernel after boot.
>
> If someone has done something similar already and can point me which > part of the Alpine system are core for the system functionality?
>
> Alpine is using mdev for device management. What else I need to have > for binary blobs drivers working with linux kernel? Just /etc/mdev.con= f in place
> and call "mdev -s" in the init script? Or there is more comp= licated
> hardware initialization procedure which I need to reproduce in my &quo= t;init.sh"
> script? Should I just copy-paste some of /etc/init.d scripts and put > them in one file in the right order?
>
> If I can go even further - replace the kernel with it modules by the m= onolithic
> kernel which has all needed modules compiled inside? This way if I wil= l still
> need mdev for loading external firmware blobs?
>
> I was trying to find similar question on mailing lists and general for= ums
> but I failed.
>
> Best regards,
> Pawel
>
> --
> Pozdrawiam
>
> Pawe=C5=82 Po=C5=82awski


--
Pozdrawiam=

Pawe=C5=82 Po=C5=82awski


--
Pozdrawiam

Pawe=C5=82 Po=C5=82awski
--000000000000cd37c605de4c1eed--