Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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:

GRUB_CMDLINE_LINUX="ip=:::::eth0:dhcp"

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:

#!/bin/sh
. /scripts/functions
configure_networking

(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.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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