Ubuntu – Diskless Boot with IPv6


At our work we are using around 80 diskless machines running Ubuntu. We want to make the transition to IPv6, so now I'm trying to get our diskless system to work with IPV6. The transmission of the kernel and initramfs can be still over a IPv4 connection, but once the machine is fully booted I want all network connections to be over IPv6.

This means that the nfsroot has to be mounted via IPv6. My research of this has shown that initramfs-tools (1.18.5-1ubuntu4.1) does NOT support IPv6. That means that neither ipconfig, that's used for interface configuration at early boot time, nor the mount mounting procedure for the nfs root are IPv6 capable.

To circumvent this I added two binaries to the initramfs (/etc/initramfs-tools/hooks/ipv6):

. /usr/share/initramfs-tools/hook-functions
copy_exec /sbin/dhclient /sbin
copy_exec /sbin/mount.nfs4 /sbin

I use these to (a) request a DHCPv6 at early boot time with

/sbin/dhclient -6 -1 -cf /tmp/dhclient.conf -pf /tmp/dhclient6.eth0.pid -lf /tmp/dhclient6.eth0.leases eth0

and (b) to configure the interface with the address I attained by executing:

ipv6=$(cat /tmp/dhclient6.eth0.leases | grep iaaddr | egrep -o "([a-f0-9]{1,4}:){3}([a-f0-9]{0,4}:){0,4}[a-f0-9]{1,4}")
ip -6 addr add $ipv6/112 dev eth0

Usually the nfs root is mounted with the following command in/usr/share/initramfs-tools/scripts/nfs:

nfsmount -o nolock ${roflag} ${NFSOPTS} ${NFSROOT} ${rootmnt}

But this doesn't seem to accept IPv6 addresses.

So I changed it to:

mount ${roflag} -t nfs4 ${NFSROOT} ${rootmnt}

$NFSROOT in this case is [2001:4ca0:2218:1::1:2]:/lb/diskless/rootfs/ubuntu_1204_ipv6.

The interface configuration seems to work as well as the root mounting, but when /sbin/init is executed (I think), the IPv6 is dropped again, and therefore the system freezes (because it cannot access the ubuntu root anymore).

The /etc/network/interfaces file looks like this:

auto lo
iface lo inet loopback

iface eth0 inet manual
iface eth0 inet6 manual

Is there a way to keep the interface configuration from the initramfs? Or am I doing something wrong when I configure the interface with ip?

Best Answer

maybe it's off topic to you but I think that your specific problem can be avoided by rethink the service :

why bother booting with NFS ?

You can try to boot with iscsi (in a read only mode to allow more than one connection to the image) and then use iscsi or nfs (ipv4) for the user shares if you need to. You can achieve this with the ipxe project.

Another way is to use squashfs+tmpfs and not to bother so much with shares during the booting process of the system and then do remounts depending on the user authentifications (however this have a higher memory consumption on the client side).

Hopes that helps you.

Related Question