1

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?

stephanp
  • 21
  • 3
  • 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. – Martin Jan 11 '22 at 11:02
  • 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... – stephanp Jan 11 '22 at 12:50
  • You may as well customize the behavior with the parameters in the initramfs.conf. So what are the best ways? – stephanp Jan 11 '22 at 13:02
  • 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=:/path/of/nfsmount``` – Martin Jan 11 '22 at 13:07
  • Thanks for the hint. I have done this by using `insmod tftp` and setting the root correctly. – stephanp Jan 11 '22 at 13:23

1 Answers1

1

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

stephanp
  • 21
  • 3