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 forums
but I failed.
Best regards,
Pawel
--
Pozdrawiam
Paweł Poławski
You've basically described initramfs. Take a look at mkinitfs, which
is what alpine uses.
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> 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 forums> but I failed.>> Best regards,> Pawel>> --> Pozdrawiam>> Paweł Poławski
Hi Konstantin,
Thank you for the fast answer.
śr., 4 maj 2022 o 20:45 Konstantin Kulikov <k.kulikov2@gmail.com>
napisał(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 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 <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> > 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 forums> > but I failed.> >> > Best regards,> > Pawel> >> > --> > Pozdrawiam> >> > Paweł Poławski>
--
Pozdrawiam
Paweł Poławski
Hi Konstantin,
pt., 6 maj 2022 o 00:25 Hokus Pokus <pawel.polawski@gmail.com> napisał(a):
> Hi Konstantin,>> Thank you for the fast answer.>> śr., 4 maj 2022 o 20:45 Konstantin Kulikov <k.kulikov2@gmail.com>> napisał(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 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.>
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 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 case of Alpine).
>>>>>> 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>> > 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>> forums>> > but I failed.>> >>> > Best regards,>> > Pawel>> >>> > -->> > Pozdrawiam>> >>> > Paweł Poławski>>>>> --> Pozdrawiam>> Paweł Poławski>
--
Pozdrawiam
Paweł Poławski