You are not logged in.

#1 2023-08-11 13:10:59

xuanyao
Member
Registered: 2023-08-11
Posts: 6

How to generate initramfs on a non-arch linux platform?

My arch is running on a KVM. I am using the host to compile vmlinux no problem (using arch's /proc/config.gz).

but if I try to do qemu direct kernel boot, I am dropped into the emergency shell with no modules loaded, so it won't mount /.

I also tried copying the initramfs.img from the guest but modules won't load either. I get either " Unknown symbol" or some BTF errors.


At this point I believe that the modules have to come from the same build from the kernel tree. and I saw the kernel doc mention the use of "usr/gen_init_cpio" where you can supply a file that includes modules you want to package.

So the question is, how do I get such a list from arch?

Offline

#2 2023-08-11 18:27:06

3beb6e7c46a615a
Member
Registered: 2021-03-27
Posts: 165

Re: How to generate initramfs on a non-arch linux platform?

A list of modules alone wouldn't do, you'll also need a few basic userspace utilities, e.g. udev, systemd/busybox, etc.  You can do that manually, but it's a non-trivial amount of work; to a point where this becomes a "if you have to ask, don't" thing.

I presume you have a reason to try all this, but you'll have an easier life if you just use a standard tool to generate an initramfs.  Most Linux distributions these days include dracut.

Offline

#3 2023-08-12 00:40:49

xuanyao
Member
Registered: 2023-08-11
Posts: 6

Re: How to generate initramfs on a non-arch linux platform?

lunaryorn wrote:

A list of modules alone wouldn't do, you'll also need a few basic userspace utilities, e.g. udev, systemd/busybox, etc.  You can do that manually, but it's a non-trivial amount of work; to a point where this becomes a "if you have to ask, don't" thing.

I presume you have a reason to try all this, but you'll have an easier life if you just use a standard tool to generate an initramfs.  Most Linux distributions these days include dracut.


I was looking at https://wiki.gentoo.org/wiki/Custom_Initramfs -> FILE /usr/src/initramfs.listcpio list example

It looks like in the cpio manifest you can supply modules and userspace etc.
The question is how I can extract this manifest from a running arch vm

Offline

#4 2023-08-12 01:57:27

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,570

Re: How to generate initramfs on a non-arch linux platform?

If you have a running Arch VM, why not just use it?

Offline

#5 2023-08-12 02:03:08

xuanyao
Member
Registered: 2023-08-11
Posts: 6

Re: How to generate initramfs on a non-arch linux platform?

Scimmia wrote:

If you have a running Arch VM, why not just use it?


trying to run gdb on kernel. so I have to get a matching vmlinux--initramfs--source_files

Offline

#6 2023-08-12 02:37:13

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,570

Re: How to generate initramfs on a non-arch linux platform?

That doesn't answer the question, why can't you just use the VM?

Offline

#7 2023-08-12 10:18:35

xuanyao
Member
Registered: 2023-08-11
Posts: 6

Re: How to generate initramfs on a non-arch linux platform?

Scimmia wrote:

That doesn't answer the question, why can't you just use the VM?

because you have to copy out the kernel tree including the objects to the host OS everytime you rebuild the kernel

Last edited by xuanyao (2023-08-12 10:18:57)

Offline

#8 2023-08-12 14:25:35

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 14,779

Re: How to generate initramfs on a non-arch linux platform?

I am using the host to compile vmlinux no problem

Why are you trying to compile the kernel on the host instead of on the guest ?


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#9 2023-08-14 06:32:46

xuanyao
Member
Registered: 2023-08-11
Posts: 6

Re: How to generate initramfs on a non-arch linux platform?

Ok, I guess I found a way around this.

mkinitcpio -k $(uname -r) -g /dev/null -s  and then copy out the /tmp/mkinitcpio.XXXXX and replace all of the modules with those built alone with the kernel. Have not tested that but I hope it works

Last edited by xuanyao (2023-08-14 06:33:14)

Offline

Board footer

Powered by FluxBB