Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Questions about busybox custom initramfs
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
psicopompo
n00b
n00b


Joined: 11 Mar 2018
Posts: 4

PostPosted: Tue Mar 13, 2018 9:57 pm    Post subject: Questions about busybox custom initramfs Reply with quote

I'm thinking in make an custom initramfs to divide /usr partition from the / partition, but i have some question:

Have i to mount all the file systems before switch root and /sbin/init?

How to can i load module options from modprobe.d in the initramfs? (i really don't know if this question make sense)

Do you know where i can find more examples of the init script?

I'm a newbie with initramfs, any advice or proposition (i don't know if this is an stupid work and could be make more easily) will be nice.
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2977
Location: Germany

PostPosted: Tue Mar 13, 2018 10:37 pm    Post subject: Re: Questions about busybox custom initramfs Reply with quote

psicopompo wrote:
I'm thinking in make an custom initramfs to divide /usr partition from the / partition


Some special use cases aside, there is really no point in separating /usr. If you have a partition for everything, / will be an empty filesystem, so might as well stick it together with /usr in the first place.

So unless you have a very good reason (like, I don't know, sharing a single /usr with multiple network clients) it's best to not split them up. It's just asking for unnecessary problems with no benefits at all.

psicopompo wrote:
Have i to mount all the file systems before switch root and /sbin/init?


You have to mount both / and /usr because / by itself is utterly useless: you need /usr to make anything work.

psicopompo wrote:
How to can i load module options from modprobe.d in the initramfs? (i really don't know if this question make sense)


Not sure if I understand your question, but busybox does include depmod, insmod, lsmod, modinfo, modprobe, rmmod, ... and if some specific feature is missing from these you can also opt to include the fully featured standard binaries.

busybox modprobe does read from /etc/modprobe.conf and /etc/modprobe.d so it is a matter of including those files in your initramfs.

You might also go with one of the initramfs generators if they just happen to work for you - Custom Initramfs is wonderful ( I wrote the guide in the Gentoo wiki ) but it might not always be the right choice regardless. It's for people who have basic shell scripting skills, who want to know how it works, and who like to experiment - since it might not work on the first attempt and then you have to debug it yourself, too.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54216
Location: 56N 3W

PostPosted: Tue Mar 13, 2018 10:44 pm    Post subject: Reply with quote

psicopompo,

The initrd/initramfs differ only in their internal structure.
An initrd is a filesystem in a file. Its usually compressed.
An initramfs is a cpio archive of cpio archives.

The term initrd is used to mean either or both.

The initrd is used as a temporary root filesystem. Usually for things needed to mount. root.

In your case, you need the userspace mount command and if its dynamically linked, the loader and and all the libraries.
You need a shell - hence busybox and an init script to describe what you want done.
Its a root filesystem, it can do anything you want in to do.

As my initrd only needs to work on a single system, it is user space tools only.
This means that I don't have to rebuild it to match the kernel. Its like firnware.

The Custom Initramfs page describes how to assemble an initrd in a file.
This approach mean you keep a decompressed copy on your system and are in complete control of the versions of the packages that go into the initrd.

Early Userspace Mounting describes how to provide a list of the content of the initrd to a tool. The tool builds the initrd from the file list by copying files from the live filesystem. This means you get whatever is installed when you build the initrd. It may nat be the same versions as last time.

Old_Fashioned_Gentoo_Install#Making_the_initrd is a hair shirt worked example.
of the second link above.

There is no reason to include kernel modules in the initrd unless you need a boot anywhere kernel and initrd.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2977
Location: Germany

PostPosted: Tue Mar 13, 2018 11:52 pm    Post subject: Reply with quote

NeddySeagoon wrote:
The term initrd is used to mean either or both.


Well, there pretty much is only initramfs these days. It's still referred to as initrd as the bootloader still uses that term.

NeddySeagoon wrote:
The Custom Initramfs page describes how to assemble an initrd in a file.


It also mentions the list https://wiki.gentoo.org/wiki/Custom_Initramfs#External_file_list

But working with an actual filesystem structure feels more natural, especially in the beginning. The advantage of the list is that you can use it to always pull the up to date binaries (although that can also be a downside, when those binaries stop working or change their library dependencies). Other initramfs generators pull the dependencies dynamically every time, something you can't achieve with a static list.

NeddySeagoon wrote:
There is no reason to include kernel modules in the initrd unless you need a boot anywhere kernel and initrd.


That depends, not using modules in initrd requires you to configure all drivers necessary to mount the root-filesystem as built-in.

If you prefer modules over built-in stuff for any reason - you'll also need modules in the initramfs, even if it's just for the one machine.

(My personal preference is to disable the module system altogether - modules are nasty little buggers, they're never loaded when you need them, and I haven't had much success with fixing problems by removing and reloading modules. But yes, I have to compile a new kernel and reboot if I buy a new device tomorrow and need a new driver to go with that.)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum