I created my own initramfs script (based on live-initramfs) and I need set up network connection (using DHCP) to get remote file. So what do I need to add to initramfs hook file (ifconfig, dhclient?). And how to write my initramfs script? Now I am trying something like this:

mkdir -p /var/run/network  # needed by ifup
modprobe af_packet         # for DHCP?
udevadm trigger            
udevadm settle  
ifup eth0                  #???            

for ifup I need /etc/network/interfaces file to have:

auto eth0
iface eth0 inet dhcp

But generally I don't know what exactly need to be done for network device to work properly in initramfs.

Any idea or help?


The simplest solution is to use ipconfig via the kernel's ip= command-line option in grub.cfg (or pxelinux.cfg or however you boot your kernel). I'm not aware of a man page for it, but there is a README.ipconfig file in the klibc Git repository and installed at /usr/share/doc/klibc-utils/README.ipconfig.gz. So your /etc/default/grub might have a line such as the following:


You may need to make a simple script in /etc/initramfs-tools/scripts/local-top that sources the functions file and then calls the configure_networking function, like so:

. /scripts/functions

(I had mistakenly thought configure_networking was called by default, but something has to explicitly call it—either your own script or one from a package. In my case, it was called from open-iscsi.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.