From owner-freebsd-questions@FreeBSD.ORG Sun Mar 21 14:26:32 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 117C316A4CE for ; Sun, 21 Mar 2004 14:26:32 -0800 (PST) Received: from metroplex.netnation.com (metroplex.netnation.com [204.174.223.60]) by mx1.FreeBSD.org (Postfix) with ESMTP id DD77C43D1D for ; Sun, 21 Mar 2004 14:26:31 -0800 (PST) (envelope-from soekris@house.org) Received: from [64.251.74.14] (helo=[192.168.32.62]) by metroplex.netnation.com with asmtp (Exim 4.24) id 1B5BOp-000115-Fo; Sun, 21 Mar 2004 14:26:31 -0800 In-Reply-To: <9E8C857C-7AA0-11D8-A650-000A95791556@house.org> References: <9E8C857C-7AA0-11D8-A650-000A95791556@house.org> Mime-Version: 1.0 (Apple Message framework v612) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Chris Roehrig Date: Sun, 21 Mar 2004 14:25:56 -0800 To: freebsd-questions@freebsd.org X-Mailer: Apple Mail (2.612) cc: soekris-tech@lists.soekris.com Subject: Re: Diskless PXE clients: switching FreeBSD kernels based on MAC address X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Mar 2004 22:26:32 -0000 I'm following up on my original question and cross-posting it to the Soekris list in case this is useful for anyone else. If there's an easier way to do this, I'd like to know! Here's a bootloader script I wrote that works for me (FreeBSD 4.9_RELEASE). ================== kern_switch.4th ============================================= \ \ kern_switch.4th \ -- MAC-based kernel switching for PXE clients \ \ Allows PXE booting of different kernels for different MAC addresses \ using a shared NFS root partition. \ Will use the default kernel if not booting from PXE or no HW MAC \ addresses are matched. \ \ USAGE: \ 1. Place this in /boot on the NFS server. \ 2. Include this from /boot/loader.conf using the following line: \ exec="include /boot/kern_switch.4th" \ 3. Edit the MAC address and kernel definitions below. \ 4. Make sure you have an alternate boot device handy when installing \ so you can undo things if you make a mistake! \ \ v 1.0; Mar_21_2004; Chris Roehrig : switch_kernel ( kern_addr kern_n -- ) 2dup ." kern_switch DBG: switching kernel to " type cr s" kernel" setenv ; \ Check environment for loaddev... s" loaddev" getenv dup -1 = [if] drop \ the -1 retval .( kern_switch: no loaddev present in environment!) cr [else] 2dup .( kern_switch: loaddev = ) type cr s" pxe0:" compare 0= [if] \ PXE Boot; get the hardware MAC address... s" boot.netif.hwaddr" getenv dup -1 = [if] drop \ the -1 retval .( kern_switch: no boot.netif.hwaddr present in environment!) cr [else] 2dup .( kern_switch: boot.netif.hwaddr = ) type cr \ switch on HW address... \ =================================================== \ ENTER YOUR MAC ADDRESSES AND KERNEL NAMES HERE \ Pad all MAC bytes to 2-digit, lower-case. \ Be careful to preserve the space after s" ! 2dup s" 00:00:24:c1:2a:64" compare 0= [if] s" /kernel.NET4501" switch_kernel [then] 2dup s" 00:00:24:c1:35:50" compare 0= [if] s" /kernel.NET4801" switch_kernel [then] \ =================================================== 2drop \ environment HW string [then] [then] [then] \ Display the kernel to be used... s" kernel" getenv dup -1 <> [if] .( kern_switch: using kernel = ) type cr [else] drop .( kern_switch: no kernel present in environment!) cr [then] ======================================================================== ==== On Mar 20, 2004, at 10:58, Chris Roehrig wrote: > I'm running FreeBSD 4.9_RELEASE and I'd like to share my server's root > partition as the root partition for some diskless PXE clients, but I > need different kernels for the server and clients. The /conf > structure works great for providing different /etc environments for > each machine, but I can't figure out how to boot a different kernel > for my PXE clients.