Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Aug 2014 19:30:40 +0000
From:      "Pokala, Ravi" <rpokala@panasas.com>
To:        "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>
Subject:   Re: automatically nfs-boot different systems for 32 and 64 bit machine
Message-ID:  <D024D170.11DE58%rpokala@panasas.com>

next in thread | raw e-mail | index | archive | help
> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?D024D170.11DE58%rpokala>