Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by nld3-dev1.alpinelinux.org (Postfix) with ESMTPS id 27C687813E6 for <~alpine/users@lists.alpinelinux.org>; Thu, 5 May 2022 22:25:43 +0000 (UTC) Received: by mail-pl1-f176.google.com with SMTP id x18so5681798plg.6 for <~alpine/users@lists.alpinelinux.org>; Thu, 05 May 2022 15:25:42 -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=k3gHFgWMkhOLIwq+fvGXGg4D0xPsAb/hmWgUoO3yfAk=; b=g78zBuDceXN9xpQPSB1Sy7/yzyOmMITWGbRNJa/gycyPbQMpksNsA6znfDtR/juqL5 ZeN14A6i+OXoggtcldIi1oPuPU21+MyyAd5ZHabUhKF9EQ3jVocbh01uobtmrur9lTGw mYTNU4IasWhWRsH18NRCte5lvnCod+S9ONJZgPIgr/luDpXyqM/5yGU54oTkDNER1Itm I1tzX9n+yf9CUqZoZxhRdIrJkhynYIaAO3E/mNISeyMaAA9JUypwJa66c+9iRrhzcESy u6lJCUZUSiAiE8gn5DLDhQxPkqJe9Mo3Ky5xVornVuurO4SuW2BIDq6wbDN3u/P8LZVq A3Uw== 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=k3gHFgWMkhOLIwq+fvGXGg4D0xPsAb/hmWgUoO3yfAk=; b=jIMjPfYHN12oZww0C4xaWenkB8t909UrtJTHRV0CLlJveLkurowxDPru5JdmPIAIJc aEalfdWB2Sr1wyMMu6Cb+Vcec8txF0+HgzgVFOUZqjBryLx2sS9hO/w+rqqQWW5as/ry 4ZLKGp2U9nyLaMMpwgsOahTpwAhQUebrITfqNlSyxoMOnWSn0J164UXVg7FLOCFr/IM9 5u2GW7mMyJx+F/SdMNrJ/qmXynL/AEe+mknDv+x3hg2grHqRzkCtGxiXb7QEReppbssd OeJed3lg5NsRcDX3tMFWQPthImmbkZNFDn856x3JPcBmdnG3mPQWd4tuGYtjkoeTLBRI vofQ== X-Gm-Message-State: AOAM530f5ulaNdPw1xuPJd66t2boq0FIJ31WpG6QkjOZVPRogeF6hpke 4bb2MXGp0vAN5aRA/fDa6rFR8NyPmc489JXNROg= X-Google-Smtp-Source: ABdhPJyoh4qdp89tHBXwMIjMnzp0qQ5a4pT6SRjLu8SJyRIZeOIyT63Z0pZD3DuNJZyIkf0grTHOyLZeWrtY0lEbNg4= X-Received: by 2002:a17:902:f708:b0:153:839f:bf2c with SMTP id h8-20020a170902f70800b00153839fbf2cmr374414plo.113.1651789541081; Thu, 05 May 2022 15:25:41 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Hokus Pokus Date: Fri, 6 May 2022 00:25:29 +0200 Message-ID: Subject: Re: Custom Alpine Linux build To: Konstantin Kulikov Cc: ~alpine/users@lists.alpinelinux.org Content-Type: multipart/alternative; boundary="000000000000d7078905de4b389d" --000000000000d7078905de4b389d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 th= e installed firmware blobs so my final "init-like" script will be running on 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. > > 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.conf > 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 will > still > > need mdev for loading external firmware blobs? > > > > I was trying to find similar question on mailing lists and general foru= ms > > but I failed. > > > > Best regards, > > Pawel > > > > -- > > Pozdrawiam > > > > Pawe=C5=82 Po=C5=82awski > --=20 Pozdrawiam Pawe=C5=82 Po=C5=82awski --000000000000d7078905de4b389d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Konstantin,

Thank you for= the fast answer.

=C5=9Br., 4 maj 2022 o 20:45=C2=A0Konstantin Kulikov &= lt;k.kulikov2@gmail.com> nap= isa=C5=82(a):
Yo= u'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) 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.
=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
--000000000000d7078905de4b389d--