From owner-freebsd-hackers@FreeBSD.ORG Fri Aug 29 02:06:38 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7832880E for ; Fri, 29 Aug 2014 02:06:38 +0000 (UTC) Received: from mon-colo.panasas.com (mon-colo.panasas.com [209.166.131.137]) by mx1.freebsd.org (Postfix) with ESMTP id 1F6651075 for ; Fri, 29 Aug 2014 02:06:37 +0000 (UTC) Received: from zenyatta.panasas.com ([172.17.28.63]) by mon-colo.panasas.com with Microsoft SMTPSVC(7.0.6001.18000); Thu, 28 Aug 2014 15:30:41 -0400 Received: from ZENYATTA.int.panasas.com ([fe80::44ca:f0e1:b97e:bf79]) by zenyatta.int.panasas.com ([fe80::44ca:f0e1:b97e:bf79%15]) with mapi id 14.03.0181.006; Thu, 28 Aug 2014 15:30:40 -0400 From: "Pokala, Ravi" To: "freebsd-hackers@freebsd.org" Subject: Re: automatically nfs-boot different systems for 32 and 64 bit machine Thread-Topic: automatically nfs-boot different systems for 32 and 64 bit machine Thread-Index: AQHPwvaM81/ZwU2QsEenpDwo2BP7tw== Date: Thu, 28 Aug 2014 19:30:40 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Microsoft-MacOutlook/14.4.3.140616 x-originating-ip: [172.17.133.77] Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginalArrivalTime: 28 Aug 2014 19:30:41.0127 (UTC) FILETIME=[8DA66770:01CFC2F6] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Aug 2014 02:06:38 -0000 > how can i boot different systems automatically depending if 32 or 64 bit >machine netboots? >=20 > ideal would be simple PXE program that would check CPU architecture and >then load different files by TFTP. i already took care about the rest. We had a similar problem several years ago. Because the number of 32-bit models was relatively small, we implemented a lookup table based on the SMBIOS product names: sys/boot/forth/loader.4th: \ checks if string specified by c-addr2 u2 is contained \ in the string specified by c-addr1 u1. : substring ( c-addr1 u1 c-addr2 u2 -- c-addr1 u1 flag ) 2 pick 1 pick - dup 0 < if drop drop drop false exit else 1 + 0 do 2over drop I + 1 pick 2over compare 0=3D if drop drop unloop true exit then loop drop drop false then ; \ tests if any of the known 32-bit SMBIOS substrings are present \ return true flag if yes : test32bit ( -- flag ) s" smbios.planar.product" getenv dup -1 =3D if s" BIOS version not present" type cr drop true exit else s" BIOS version: " type 2dup type cr \ Run "kenv smbios.planar.product" on the 32-bit machines, and \ add their strings to this list c" 32-bit plat1" count substring if 2drop true exit then c" plat2-32" count substring if 2drop true exit then then \ we'll call it 64-bit 2drop false ; sys/boot/i386/loader/loader.rc test32bit [if] \ Path to 32-bit kernel load /kernel boot [else] \ Path to 64-bit kernel load /boot/kernel/kernel boot [then] NB: I modified this a bit to remove some proprietary details; what's listed above might not actually work, but it should be relatively close, and should point you in the right direction. -Ravi