[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#593284: live-initramfs: add functionlity for using BOOTIF param



Package: live-initramfs
Version: 1.236.2-1

Hi there,

last weekend I was testing something with fai, initramfs-tools and
live-initramfs, because I had trouble with netbooting a via vb8001 mb
with a second pcie e1000e card.

The problem is, that one time the onboard via-velocity becomes eth1 next time eth0 (mostly eth1). Therefore it's not enough to specify live-netdev=eth1 as kernel param.

My idea is to work with the BOOTIF param which pxelinux set's as kernel param when you specify

ipappend 2

in the pxelinux boot config of your machine. It includes the MAC of the nic the kernel was booted from (or so o:). You can also specify BOOTIF as a kernel param manually.

live-initramfs should simply acquire the ip(dhcp) through the same ip the kernel was loaded from.

I find this useful, because most of the people that do a pxe/netboot and mount a nfsroot (like fai does), want to get the ip address for the nfsroot (which will be mountes through/by live-initramfs) through the same device/ip/... the kernel was loaded from.

My current solution is:

- take live-initramfs=1.236.2-1 source code from http://live.debian.net/archive/packages/live-boot/1.236.2-1 This is the last version of the old 1.x series. I took that one, because I have trouble using latest version of live-initramfs based on live-boot with fai (will file this as a separat bug). - change scripts/live-premount/select_eth_device that it takes live-netdev=BOOTIF as a parameter and that it set's the live-netdev to the interface that matches the MAC given in BOOTIF when done so.

@M.Attems: Thanx for writing the mac-nic-translator in initramfs-tools - I could easily use that one here (o:

- revert patch "5de51fc8b4f8e80f1ff1e734c971755c0c223150 - Using minimized rules file" from live.debian.net (live-boot) that package builds against plain lenny repo and sources.

- use initramfs-tools package as I described in bug #593276

I don't know much about the work of a debian package maintainer and possibly it need's some extra work to make this "debian-clean", that's my idea and it works so far for me.

Attached is a diff.gz + dsc against http://live.debian.net/archive/packages/live-boot/1.236.2-1/live-initramfs_1.236.2.orig.tar.gz.

Here's also a patch for scripts/live-premount/select_eth_device which I primarily changed:

--- select_eth_device.orig    2010-05-18 06:53:40.000000000 +0200
+++ select_eth_device    2010-08-13 10:47:27.000000000 +0200
@@ -56,11 +56,80 @@ if [ $(echo $l_interfaces | wc -w) -lt 2
    exit 0
fi

+for ARGUMENT in $(cat /proc/cmdline); do
+    case "${ARGUMENT}" in
+        BOOTIF=*)
+        BOOTIF="${ARGUMENT#BOOTIF=}"
+        echo "Found BOOTIF parameter in /proc/cmdline."
+        echo "Setting BOOTIF=$BOOTIF."
+        ;;
+    esac
+done
+
+# taken from git.kernel.org - initramfs-tools
+# commit 673abb77821433a67add61ac79d739c6cee9eee0
+# and bugfix commit 5db5becc85059e56075de5a331ed7c5a4cc2de0c
+# and changed it a bit for this purpose
+# thx maximilian attems
+if [ -n "${BOOTIF}" ]; then
+    # pxelinux sets BOOTIF to a value based on the mac address of the
+    # network card used to PXE boot, so use this value for DEVICE rather
+    # than a hard-coded device name from initramfs.conf. this facilitates
+    # network booting when machines may have multiple network cards.
+    # pxelinux sets BOOTIF to 01-$mac_address
+
+    # strip off the leading "01-", which isn't part of the mac
+    # address
+    temp_mac=${BOOTIF#*-}
+ + # convert to typical mac address format by replacing "-" with ":"
+    bootif_mac=""
+    IFS='-'
+    for x in $temp_mac ; do
+        if [ -z "$bootif_mac" ]; then
+            bootif_mac="$x"
+        else
+            bootif_mac="$bootif_mac:$x"
+        fi
+    done
+    unset IFS
+
+    # look for devices with matching mac address, and set DEVICE to
+    # appropriate value if match is found.
+    for device in /sys/class/net/* ; do
+        if [ -f "$device/address" ]; then
+            current_mac=$(cat "$device/address")
+            if [ "$bootif_mac" = "$current_mac" ]; then
+                BOOTIF_DEVICE=${device##*/}
+                break
+            fi
+        fi
+    done
+ [ -n "$BOOTIF_DEVICE" ] && echo "Found matching dev to BOOTIF MAC. Setting BOOTIF_DEVICE=$BOOTIF_DEVICE"
+fi
+
# If user force to use specific device, write it
for ARGUMENT in $(cat /proc/cmdline); do
    case "${ARGUMENT}" in
        live-netdev=*)
-        NETDEV="${ARGUMENT#live-netdev=}"
+        LIVE_NETDEV="${ARGUMENT#live-netdev=}"
+        if [ "$LIVE_NETDEV" = "BOOTIF" ]; then
+            if [ -n "$BOOTIF_DEVICE" ]; then
+                NETDEV="$BOOTIF_DEVICE"
+ echo "Found live-netdev=BOOTIF in /proc/cmdline. Setting NETDEV=$BOOTIF_DEVICE"
+            else
+                echo "Found live-netdev=BOOTIF in /proc/cmdline."
+                echo "No BOOTIF_DEVICE was found, try inserting line:"
+                echo "ipappend 2"
+                echo "to PXELINUX boot config (device not supported?)"
+                echo "or add BOOTIF kernel parameter with a correct MAC."
+                # live-netdev will not work here - leave the for loop
+                break
+            fi
+        else
+            NETDEV="$LIVE_NETDEV"
+        fi
+
        echo "DEVICE=$NETDEV" >> /conf/param.conf
echo "Found live-netdev parameter in /proc/cmdline. Force to use network device $NETDEV."
        exit 0


Cheers

Holger Fischer

Attachment: live-initramfs_1.236.2-1~hbpo01.diff.gz
Description: application/gzip

Format: 1.0
Source: live-initramfs
Binary: live-initramfs
Architecture: all
Version: 1.236.2-1~hbpo01
Maintainer: Debian Live Project <debian-live@lists.debian.org>
Uploaders: Daniel Baumann <daniel@debian.org>
Homepage: http://live.debian.net/devel/live-initramfs/
Standards-Version: 3.8.4
Vcs-Browser: http://live.debian.net/gitweb/?p=live-initramfs.git
Vcs-Git: git://live.debian.net/git/live-initramfs.git
Build-Depends: debhelper (>= 7)
Build-Depends-Indep: asciidoc, docbook-xsl, xsltproc
Checksums-Sha1: 
 8393790f00b8c324d1f666e4fb07759039ebf649 109935 live-initramfs_1.236.2.orig.tar.gz
 03e5fcdddf66d18e3e250aed0a823f838590db7c 16702 live-initramfs_1.236.2-1~hbpo01.diff.gz
Checksums-Sha256: 
 ab960f9523653bba651f74f8df671037503ff9bb9c8b11aca7cd61889632e5e5 109935 live-initramfs_1.236.2.orig.tar.gz
 be1dd3e07ecdb7f12a08c7b1aa4006c78625c2d05bd24bdf61612f2183edba66 16702 live-initramfs_1.236.2-1~hbpo01.diff.gz
Files: 
 cf4d591adcd0e1b01b5708e4a3911e65 109935 live-initramfs_1.236.2.orig.tar.gz
 ae6286be83e69752d1b665afe7595354 16702 live-initramfs_1.236.2-1~hbpo01.diff.gz

Reply to: