Score:1

initramfs - customize init script

ru flag

We have a cluster system with master and several nodes. I have set up a PXE netboot of ubuntu kernel 5.4.0-91 from the master. The nodes load the initramfs and end up in the busybox.

Now I want to customize the initramfs to automatically do the following task: the nodes shall mount a directory from the master via nfs and execute a script there.

How to properly implement that?

Martin avatar
kz flag
why do you want to reinvent the wheel? There are pxe-ready images available which work over NFS ... But to answer your question, the init script is a shell script - just place your commands inside this script, and pack it into your initrd.
ru flag
First thing is to learn and understand how things work. I think there are constraints on where to put it in the init script. E.g. for nfs the network interface needs to be up and configured. As I can see there are several stages, like init-top, init-bottom, etc. There is also a nfs-script in /main/scripts...
ru flag
You may as well customize the behavior with the parameters in the initramfs.conf. So what are the best ways?
Martin avatar
kz flag
since you mentioned ubuntu, I recently configured a live-dvd to boot over pxe - all I had to do is append those kernel parameters to the kernel arguments, since the ubuntu init script already has the proper handling of a nfsroot: ```ip=dhcp netboot=nfs nfsroot=<ip-nfs-server>:/path/of/nfsmount```
ru flag
Thanks for the hint. I have done this by using `insmod tftp` and setting the root correctly.
Score:1
ru flag

After some more research and testing, I found the following solution:

  1. In the init script, you can use the function configure_networking (defined in scripts/functions) to activate and configure the network devices via dhcp-client.

  2. to mount an nfs-share use mount -o ro,port=2049,nolock,proto=tcp -t nfs <server-ip>:/nfs-dir /some-dir

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.