ONIE:设计规格(3)

3.操作系统设计

3.1.Linux内核配置

ONIE提供了一个网络操作系统(NOS)安装镜像可以运行的环境。因此,内核必须提供对安装程序有用的功能和服务。这对Linux配置提供了很多要求。

每个平台都必须为Linux内核添加平台支持。需要添加的内容取决于具体的平台和CPU架构。

有关于CPU架构的具体细节,请参阅以下章节:

  • U-Boot 平台Linux内核及设备树源码
  • x86 Linux Kernel and Integration

3.1.1.通用内核配置

除了特定于平台的内核代码之外,ONIE还需要许多其他的配置选项来支持有效的安装环境。

  • Kernel特性
    • Kexec – 允许安装程序将kexec(8)放入自己的内核
  • 网络
    • 以太网管理接口的驱动程序
    • IPv4
    • IPv6
  • 文件系统
    • Vfat,允许从USB存储设备中安装
    • ext2, ext3, ext4
    • jffs2
    • squashfs
    • nfs
  • 硬件支持
    • PCIe
    • i2c EEPROMs
    • USB存储设备
    • SDHC
    • SATA

3.2.镜像发现与执行

ONIE的主要功能是找到一个网络操作系统(NOS)安装镜像并执行它。

3.2.1.平台名称及表示

为了表示运行平台,ONIE使用以下定义:

  • arch – CPU架构,目前支持的体系结构是:
    • arm
    • powerpc
    • x86_64
  • machine – 一个字符串<VENDOR>_<MODEL>
  • machine-revision – 一个字符串 r<NUMBER>,用于跟踪机器的不同硬件版本
  • platform – 一个字符串<ARCH>-<MACHINE>-<MACHINE-REVISION>
  • switch-silicon-vendor – 用于跟踪ASIC芯片提供商,当前主要有:
Silicon Vendor String
Broadcom bcm
Cavium cavium
Centec centec
Marvell mvl
Mellanox mlnx
Nephos nephos
Qemu qemu

对上面定义的<ARCH>,<VENDOR>和<MODEL>允许的字符进行了限制。允许用于上述定义的字符串限制如下:

  1. VENDOR – 不能包含_ (下划线) or - (连字符)
  2. MODEL – 不能包含- (连字符),但是_ (下划线)是可以的
  3. ARCH – 不能包含_ (下划线) 或 - (连字符)

在运行时,ONIE提供了onie-sysinfo命令,可以用来打印这些信息。有关onie-sysinfo命令的更多信息,请参阅系统信息章节描述。

如“网络操作系统接口”中描述,平台名称必须在所有ONIE模式中保持一致。

3.2.2.安装镜像发现方法

ONIE通过许多方法尝试定位安装程序镜像位置。第一个成功的方法将用来下载和运行安装程序镜像。

即便找到安装程序镜像,安装也可能失败,在这种情况下,ONIE会转到下一个方法继续。

ONIE将按照以下顺序尝试发现:

  1. 静态配置(bootloader设置)
  2. 本地文件系统(例如USB)
  3. 来自DHCPv4的准确URLs
  4. 基于DHCP响应的非精确URLs
  5. IPv6邻居
  6. TFTP过程

发现方法会一直重复,直到成功完成镜像安装。

一般的镜像发现过程由以下伪代码说明:

while (true) {
  Configure Ethernet management console
  Attempt discovery method 1
  Attempt discovery method 2
  ...
  Attempt discovery method N
  Sleep for 20 seconds
}

接下来的部分将详细介绍这些方法。

3.2.2.1.默认文件名搜索顺序

在后面描述的几种方法中,ONIE以特定顺序搜索默认文件名。所有的方法都使用相同的文件名搜索顺序,这个顺序在本节描述。

按照以下顺序搜索默认安装程序镜像名称:

  1. onie-installer-<arch>-<vendor>_<machine>-r<machine_revision>
  2. onie-installer-<arch>-<vendor>_<machine>-r<machine_revision>.bin *
  3. onie-installer-<arch>-<vendor>_<machine>
  4. onie-installer-<arch>-<vendor>_<machine>.bin *
  5. onie-installer-<vendor>_<machine>
  6. onie-installer-<vendor>_<machine>.bin *
  7. onie-installer-<cpu_arch>-<switch_silicon_vendor>
  8. onie-installer-<cpu_arch>-<switch_silicon_vendor>.bin *
  9. onie-installer-<arch>
  10. onie-installer-<arch>.bin *
  11. onie-installer
  12. onie-installer.bin *

ONIE 2017.08 添加.bin扩展名到所有默认的文件名之后,早期版本的ONIE并不搜索扩展名。

假设设备为x86_64架构,那么默认的安装程序名称将会是:

onie-installer-x86_64-VENDOR_MACHINE-r0
onie-installer-x86_64-VENDOR_MACHINE-r0.bin
onie-installer-x86_64-VENDOR_MACHINE
onie-installer-x86_64-VENDOR_MACHINE.bin
onie-installer-VENDOR_MACHINE
onie-installer-VENDOR_MACHINE.bin
onie-installer-x86_64-SWITCH_SILICON_VENDOR
onie-installer-x86_64-SWITCH_SILICON_VENDOR.bin
onie-installer-x86_64
onie-installer-x86_64.bin
onie-installer
onie-installer.bin

ONIE 2016.05 引入了onie-installer-<cpu_arch>-<switch_silicon_vendor>。所有以前的旧版本不包括这个命名。

在ONIE自更新模式下,文件名前缀是onie-updater而不是onie-installer。

有关特定硬件平台名称的准确描述,请联系NOS厂商或您的硬件供应商。

3.2.2.2.静态配置方法

此方法仅在前期调试中使用,如将ONIE移植到新的平台过程中。在bootloader程序中,用户可以通过设置install_url内核命令参数来静态配置ONIE将使用的安装程序URL。

3.2.2.3.本地文件系统方法

在此方法中,ONIE搜索本地连接的存储器设备的分区,查找ONIE默认安装程序文件名中指定的文件。

请参阅“默认文件名搜索顺序”章节描述获取更多信息。

此方法适用于前面板USB接口上插入设备,且USB设备中存有安装程序的情况。

支持两种文件系统类型,流行的vFAT分区类型(在商用U盘上常见)及Linux's ext2。

OSX的磁盘工具默认会写出不支持的分区类型,请使用diskutil命令行进行格式化:

# Find USB drive

% diskutil list
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *8.1 GB     disk2
   1:               Windows_NTFS ONIE                    8.1 GB     disk2s1

# Write out correctly label (wipes all data on drive)

% sudo diskutil eraseDisk FAT32 ONIE MBRFormat /dev/disk2
Started erase on disk2
Unmounting disk
Creating the partition map
Waiting for the disks to reappear
Formatting disk2s1 as MS-DOS (FAT32) with name ONIE
512 bytes per physical sector
/dev/rdisk2s1: 15697944 sectors in 1962243 FAT32 clusters (4096 bytes/cluster)
bps=512 spc=8 res=32 nft=2 mid=0xf8 spt=32 hds=255 hid=2 drv=0x80 bsec=15728638 bspf=15331 rdcl=2 infs=1 bkbs=6
Mounting disk
Finished erase on disk2

在本地存储设备中查找安装程序的一般算法如下:

foreach $partition in /proc/partitions {
  if able to mount $partition then {
    if default file name exists {
      Add partition to found_list
    }
  }
}

foreach $partition in found_list {
  Run installer from $partition
}

3.2.2.4.以太网管理口配置

为了执行基于网络的安装程序镜像发现,必须先配置以太网管理口。按顺序尝试以下配置方法:

  1. 静态配置—通过ip内核命令行参数配置
  2. DHCPv6 – 尚未实现
  3. DHCPv4
  4. 本地链路IPv4地址(参考RFC-3927)

静态配置使用ip命令Linux kernel command line argument

3.2.2.5.DHCP 请求及响应

DHCP提供了一个强大而灵活的机制来精确指定安装程序镜像的URL。在DHCP请求期间,ONIE设置了许多选项来帮助DHCP服务器确定适当的响应。

请求期间设置的选项如下:DHCP Request Options

Option Name ISC option-name RFC
60 Vendor Class Identifier vendor-class-identifier RFC 2132
77 User Class user-class RFC 2132
125 Vendor-Identifying Vendor-Specific Information vivso RFC 3925
55 Parameter Request List dhcp-parameter-request-list RFC 2132
3.2.2.5.1.供应商分类标识 -- Option 60

供应商分类标识符选项是两个字符串连接,用冒号分隔:

  1. 静态字符串onie_vendor
  2. <arch>-<vendor>_<machine>-r<machine_revision>

例如,使用x86_64架构的设备,这个字符串可能是:

onie_vendor:x86_64-VENDOR_MACHINE-r0

对用于特定硬件平台的精确DHCP Vendor Class Identifier,请联系您的NOS供应商或您的硬件供应商。
有关平台名称的更多信息,参阅平台名称和标识符列表。

3.2.2.5.2.用户类型 -- Option 77

用户类型选项设置为静态字符串:

onie_dhcp_user_class
3.2.2.5.3.供应商标识和供应商特定信息 (VIVSO)

VIVSO选项允许自定义选项namespace,其中namespace由32位IANA私有企业编号标识。ONIE当前使用企业编号42623来标识其自定义的namespace。

ONIE namespace中的选项代码的大小为1个字节。选项的有效载荷长度也是1个字节。
在这个namespace中,定义了如下选项代码:VIVSO Options

Option Code Name Type Example
1 Installer URL string http://10.0.1.205/nos_installer.bin
2 Updater URL string http://10.0.1.205/onie_update.bin
3 Platform Name string VENDOR_MACHINE
4 CPU Architecture string x86_64
5 Machine Revision string 0

有关平台名称的更多信息,参考平台相关环境变量表。

3.2.2.5.4.请求参数列表 -- Option 55

参数请求列表选项对请求的参数列表进行编码。
ONIE请求以下参数:DHCP Parameter Request List Options

Option Name ISC option-name Option Type RFC Example
1 Subnet Mask subnet-mask dotted quad 2132 255.255.255.0
3 Default Gateway routers dotted quad 2132 10.0.1.2
6 Domain Server domain-name-servers dotted quad 2132 10.0.1.2
7 Log Server log-servers dotted quad 2132 10.0.1.2
12 Hostname host-name 2132 switch-19
15 Domain Name domain-name string 2132 cumulusnetworks.com
42 NTP Servers ntp-servers dotted quad 2132 10.0.1.2
54 DHCP Server Identifier dhcp-server-identifier dotted quad 2132 10.0.1.2
66 TFTP Server Name tftp-server-name string 2132 behemoth01 (requires DNS)
67 TFTP Bootfile Name bootfile-name or filename string 2132 tftp/installer.sh
72 HTTP Server IP www-server dotted quad 2132 10.0.1.251
114 Default URL default-url string 3679 http://server/path/installer
150 TFTP Server IP Address next-server dotted quad 5859 10.50.1.200

3.2.2.6.HTTP请求和HTTP头部

ONIE所有的HTTP请求都包括一组标准的HTTP头部,这是CGI自动化系统可以使用的。每个HTTP请求头部是:HTTP Headers

Header Value Example
ONIE-SERIAL-NUMBER: Serial number XYZ123004
ONIE-ETH-ADDR: Management MAC address 08:9e:01:62:d1:93
ONIE-VENDOR-ID: 32-bit IANA Private Enterprise Number in decimal 12345
ONIE-MACHINE: <vendor>_<machine> VENDOR_MACHINE
ONIE-MACHINE-REV: <machine_revision> 0
ONIE-ARCH: CPU architecture x86_64
ONIE-SECURITY-KEY: Security key d3b07384d-ac-6238ad5ff00
ONIE-OPERATION: ONIE mode of operation os-install or onie-update

3.2.2.7.来自DHCPv4的精准安装镜像URLs

前面讨论的DHCP选项提供了许多方法来表达NOS安装程序镜像的确切URL。在解释URL时,ONIE接受如下方案:

以下选项可以用于组织一个精确的URL。Exact DHCP URLs

Option Name Comments
125 VIVSO ONIE VIVSO 中指定的安装程序URL选项 (code = 1)。该选项产生一个精确的URL。请参阅上述“供应商标识 供应商特定信息”章节描述。
114 Default URL 用于HTTP,但是接受其他URLs
150 + 67 TFTP server IP and TFTP bootfile 这两个选项都需要一个精确的URL
66 + 67 TFTP server name and TFTP bootfile 这两选项都需要一个精确的URL,需要DNS

3.2.2.8.部分安装程序镜像URLs

某些情况下,配置DHCP服务器以获取精确的URL可能不切实际。

例如,考虑一个企业方案,其中控制DHCP服务器的企业IT部门与试图建立新的Web服务原型的应用程序开发部门是分开的。应用部门希望尽快采取行动,尽快为新的解决方案建立原型。在这种情况下,等待IT部门进行 DHCP服务器更改需要很长时间。

为了灵活地管理DHCP服务器,ONIE可以使用部分DHCP信息来找到安装程序。ONIE使用默认的URL路径序列和默认的安装程序文件名以及部分DHCP信息来查找安装程序镜像。

请参阅“默认文件名搜索顺序”以获取有关文件名搜索的更多信息。
以下DHCP选项响应用于查找安装程序镜像及默认文件名:Partial DHCP URLs

DHCP Options Name URL
67 TFTP Bootfile Contents of bootfile
72 HTTP Server IP http://$http_server_ip/${onie_default_installer_names}
150 TFTP Server IP http://$tftp_server_ip/${onie_default_installer_names}
54 DHCP Server IP http://$dhcp_server_ip/${onie_default_installer_names}
3.2.2.8.1.Default ONIE image server name onie-server

If the default ONIE server name onie-server is resolvable by DNS it is included in the search for the default installer file names for both http and tftp protocols. The following URLs are attempted:

http://onie-server/${onie_default_installer_names}
tftp://onie-server/${onie_default_installer_names}
3.2.2.8.2.TFTP Waterfall

ONIE includes a classic PXE-like TFTP waterfall. Given a TFTP server address, ONIE attempts to download the installer using a sequence of TFTP paths with decreasing levels of specificity.

The TFTP URL name has this format:

tftp://$tftp_server_ip/$path_prefix/$onie_default_installer_name

The $tftp_server_ip comes from DHCP option 66.
The $path_prefix is determined in the following manner:

  1. First the path_prefix is built using the Ethernet management interface's MAC address using lower case hexadecimal with a dash separator. For example, with address 55:66:AA:BB:CC:DD thepath_prefix would be 55-66-aa-bb-cc-dd.
  2. Next, the path_prefix is built using the Ethernet management interface's IP address in upper case hexadecimal. For example, 192.168.1.178 -> C0A801B2. If the installer is not found at that location, remove the least significant hex digit and try again.
  3. Finally, look for the list of default file names at the root of the TFTP server.

Here is a complete list of the bootfile paths attempted using the example MAC address, IP address and the example x86_64 platform:

55-66-aa-bb-cc-dd/onie-installer-<arch>-<vendor>_<machine>
C0A801B2/onie-installer-<arch>-<vendor>_<machine>
C0A801B/onie-installer-<arch>-<vendor>_<machine>
C0A801/onie-installer-<arch>-<vendor>_<machine>
C0A80/onie-installer-<arch>-<vendor>_<machine>
C0A8/onie-installer-<arch>-<vendor>_<machine>
C0A/onie-installer-<arch>-<vendor>_<machine>
C0/onie-installer-<arch>-<vendor>_<machine>
C/onie-installer-<arch>-<vendor>_<machine>
onie-installer-<arch>-<vendor>_<machine>-<machine_revision>
onie-installer-<arch>-<vendor>_<machine>
onie-installer-<vendor>_<machine>
onie-installer-<arch>
onie-installer

See Default File Name Search Order for more information on the default file names and search order.

3.2.2.8.3.HTTP IPv4 and IPv6 Neighbors

ONIE queries its IPv4 and IPv6 link-local neighbors via HTTP for an installer. The general algorithm follows:

  1. ping the IPv4 broadcast address, 255.255.255.255.
  2. ping6 the "all nodes" link local IPv6 multicast address, ff02::1.
  3. For each responding neighbor, try to download the default file names from the root of the HTTP server.
    Here is an example of the URLs used by this method:
http://203.0.113.14/onie-installer-x86_64-VENDOR_MACHINE-r0
http://203.0.113.14/onie-installer-x86_64-VENDOR_MACHINE
http://203.0.113.14/onie-installer-VENDOR_MACHINE
http://203.0.113.14/onie-installer-x86_64
http://203.0.113.14/onie-installer
http://203.0.113.75/onie-installer-x86_64-VENDOR_MACHINE-r0
http://203.0.113.75/onie-installer-x86_64-VENDOR_MACHINE
http://203.0.113.75/onie-installer-VENDOR_MACHINE
http://203.0.113.75/onie-installer-x86_64
http://203.0.113.75/onie-installer
http://203.0.113.108/onie-installer-x86_64-VENDOR_MACHINE-r0
http://203.0.113.108/onie-installer-x86_64-VENDOR_MACHINE
http://203.0.113.108/onie-installer-VENDOR_MACHINE
http://203.0.113.108/onie-installer-x86_64
http://203.0.113.108/onie-installer
http://fe80::4638:39ff:fe00:139e%eth0/onie-installer-x86_64-VENDOR_MACHINE-r0
http://fe80::4638:39ff:fe00:139e%eth0/onie-installer-x86_64-VENDOR_MACHINE
http://fe80::4638:39ff:fe00:139e%eth0/onie-installer-VENDOR_MACHINE
http://fe80::4638:39ff:fe00:139e%eth0/onie-installer-x86_64
http://fe80::4638:39ff:fe00:139e%eth0/onie-installer
http://fe80::4638:39ff:fe00:2659%eth0/onie-installer-x86_64-VENDOR_MACHINE-r0
http://fe80::4638:39ff:fe00:2659%eth0/onie-installer-x86_64-VENDOR_MACHINE
http://fe80::4638:39ff:fe00:2659%eth0/onie-installer-VENDOR_MACHINE
http://fe80::4638:39ff:fe00:2659%eth0/onie-installer-x86_64
http://fe80::4638:39ff:fe00:2659%eth0/onie-installer
http://fe80::230:48ff:fe9f:1547%eth0/onie-installer-x86_64-VENDOR_MACHINE-r0
http://fe80::230:48ff:fe9f:1547%eth0/onie-installer-x86_64-VENDOR_MACHINE
http://fe80::230:48ff:fe9f:1547%eth0/onie-installer-VENDOR_MACHINE
http://fe80::230:48ff:fe9f:1547%eth0/onie-installer-x86_64
http://fe80::230:48ff:fe9f:1547%eth0/onie-installer

This makes it very simple to walk up to a switch and directly connect a laptop to the Ethernet management port and install from a local HTTP server.

See Default File Name Search Order for more information on the default file names and search order.

3.2.3.执行环境

当ONIE找到并下载安装程序之后,下一步就是执行安装程序。
在执行前,ONIE准备一个执行环境:

  • 在下载的安装程序上执行chmod +x
  • 导出一些安装程序使用的环境变量
  • 运行安装程序

ONIE导出如下环境变量:Installer Core Environment Variables

Variable Name Meaning
onie_exec_url Currently executing URL
onie_platform CPU architecture, vendor and machine name
onie_vendor_id 32-bit IANA Private Enterprise Number in decimal
onie_serial_num Device serial number
onie_eth_addr MAC address for Ethernet management port

此外,任何所有DHCP响应选项都以BusyBox's udhcpc风格输出,这些变量示例如下:Installer DHCP Environment Variables

Variable Name Meaning
onie_disco_dns DNS Server
onie_disco_domain Domain name from DNS
onie_disco_hostname Switch hostname
onie_disco_interface Ethernet management interface, like eth0
onie_disco_ip Ethernet management IP address
onie_disco_router Gateway
onie_disco_serverid DHCP server IP
onie_disco_siaddr TFTP server IP
onie_disco_subnet IP netmask
onie_disco_vivso VIVSO option data

有关NOS安装程序镜像的更多信息请参考“网络操作系统接口”描述。

3.3.网络操作系统接口

ONIE为网络操作系统(NOS)提供了执行系统配置和维护操作的环境,其中包括:

  • 将NOS安装到硬件
  • 重新安装不同的NOS
  • 卸载当前NOS
  • 嵌入ONIE (清除所有东西,只留下ONIE)
  • 更新ONIE (更新当前ONIE到新的版本)
  • 应急和恢复

这个环境构成了ONIE和NOS之间的接口。

3.3.1.NOS安装程序镜像

ONIE对NOS安装程序的唯一要求就是安装程序必须更新引导环境,以便安装程序在下次重新引导时直接启动NOS。

这如何完成取决于具体的CPU架构。请参考如下章节描述:

  • U-Boot平台NOS安装程序
  • X86 NOS安装程序

除此之外,NOS安装程序可以执行任何必要的操作,将操作系统永久安装到硬件中。安装程序有很大的灵活性。安装程序可以实现的一些功能如下:

  • 通过HTTP获取额外的二进制文件
  • 通过HTTP与库存控制系统进行交流
  • 下载一个新的kernel+initramfs and kexec(8)

3.3.1.1.系统信息

在正在运行的ONIE环境中,安装程序通常需要知道关于正在运行的系统的各种信息。ONIE为此提供了onie-sysinfo命令。

有关详细信息,请参阅onie-sysinfo的完整帮助。

ONIE:/ # onie-sysinfo -h
onie-sysinfo [-sevimrpcfdat]
Dump ONIE system information.

COMMAND LINE OPTIONS
        The default is to dump the ONIE platform (-p).
        -h
                Help.  Print this message.
        -s
                Serial Number
        -e
                Management Ethernet MAC address
        -v
                ONIE version string
        -i
                ONIE vendor ID.  Print the ONIE vendor's IANA enterprise number.
        -m
                ONIE machine string
        -r
                ONIE machine revision string
        -p
                ONIE platform string.  This is the default.
        -c
                ONIE CPU architecture
        -f
                ONIE configuration version
        -d
                ONIE build date
        -t
                ONIE partition type
        -S
                ONIE silicon switch vendor
        -a
                Dump all information.

3.3.2.重装或安装一个不同的NOS

在正在运行的NOS中,可以指示ONIE返回最初的发现和安装阶段。这可以用来重新安装当前的NOS或新的NOS。

如何调用安装操作取决于不同的CPU架构,请参阅以下章节获取更多信息:

  • U-Boot平台重装或安装一个新的NOS
  • X86重装或安装一个新的NOS

3.3.3.NOS卸载

ONIE有一个卸载操作,可以清除连接的大容量存储设备(mSATA或USB NAND flash)的未使用的部分。唯一保留的是ONIE本身。这是一个重置出厂设置操作。

如何调用取决于特定的CPU架构。请参阅以下章节了解详细内容:

  • U-Boot平台卸载NOS
  • X86卸载NOS

在卸载操作之后,系统将返回发现和安装阶段。

3.3.4.应急和恢复

ONIE提供了一个应急和恢复模式,这个模式在开发过程中是非常有用的,在尝试恢复损坏的系统时可能有用。

应急模式与发现和安装阶段相同,但是发现机制被禁用。ONIE不尝试查找和安装镜像,它只是等在哪里等待您排除故障。

在这种模式下,您可以通过串行控制台或telnet连接到您的ONIE。您可以使用可用的BusyBox工具来尝试修复问题,或者使用wget下载更多的工具和文件。

ONIE提供的一些有用的命令如下:

  • onie-nos-install – 它需要一个参数,指定NOS安装镜像URL。该命令从URL下载并安装,就像已经发现了一样。
  • onie-self-update – 它需要一个参数,指定ONIE更新镜像URL。该命令下载并更新ONIE。有关ONIE更新的更多信息,请参阅章节“更新ONIE”描述。
  • onie-discovery-stop – 停止发现过程。在发现过程干扰调试的情况下,这很有用。当发现过程被禁用时,系统是安静的,您可以做你想要的事情。

如何调用应急和恢复模式取决于具体的CPU架构,请参阅以下章节获取更多信息:

  • U-Boot平台应急和恢复
  • X86应急和恢复

3.3.5.更新及嵌入ONIE

ONIE提供了一种自我更新的方式,包括bootloader和Linux kernel。除了ONIE发现阶段查找的是自己的更新安装镜像之外,其过程同NOS发现与安装阶段类似。
更新操作有两种:更新和嵌入。

更新操作将升级ONIE,不会破坏当前安装的NOS。

嵌入操作是破坏性的,此操作将清除所有的内容(包括任何已安装的NOS)并安装新的ONIE。
目前,嵌入操作仅在x86平台上提供。

有关更新和嵌入操作的详细信息,请参阅以下章节获取更多信息。

  • U-Boot平台更新和嵌入ONIE
  • X86更新和嵌入ONIE

3.4.更新ONIE

当编译ONIE时,其中有个编译产品是编译ONIE更新程序。参考ONIE编译产品列表。
更新ONIE,请按照安装网络操作系统NOS的步骤进行,但不使用NOS安装程序,而是使用ONIE更新程序。其他不同的细节如下所述。

3.4.1.开始ONIE自更新模式

要启动ONIE自更新模式,请按照“更新及嵌入ONIE”章节描述。

3.4.2.指定更新程序URL

“安装镜像发现方法”中介绍的所有方法也适用于发现ONIE升级程序镜像,但是有一些例外。
ONIE按照如下顺序查找以下默认更新程序文件名称:

  1. onie-updater-<arch>-<vendor>_<machine>-r<machine_revision>
  2. onie-updater-<arch>-<vendor>_<machine>
  3. onie-updater-<vendor>_<machine>
  4. onie-updater-<arch>
  5. onie-updater

假设设备是x86_64架构,那么默认的文件名可能是:

onie-updater-x86_64-VENDOR_MACHINE-r0
onie-updater-x86_64-VENDOR_MACHINE
onie-updater-VENDOR_MACHINE
onie-updater-x86_64
onie-updater

另一个区别是使用VIVSO时,必须设置选项2,更新程序URL指定。
此外,正如“应急和恢复”章节中描述,您可以使用onie-self-update命令指定应急模式下的更新程序的URL。

3.4.3.ONIE更新程序镜像格式 Update Image Format

ONIE更新程序镜像遵循以下格式:

  • 镜像是一个自解压的shell脚本文件
  • 镜像必须包含 ONIE-UPDATER-COOKIE字符串,它将镜像标识为ONIE更新镜像。
    镜像本身是可执行的,并且支持许多命令行选项:
-h
        Help.  Print this message.
-v
        Be verbose.    Print what is happening.
-q
        Be quiet.  Do not print what is happening.
-x
        Extract image to a temporary directory.
-i
        Dump image information.
-f
        Force ONIE update opteration, bypassing any safety
        checks.

3.4.4.使用ONIE提供固件更新

要管理固件更新,请参阅“固件更新”章节。

3.5.硬件诊断选项

有些硬件供应商可能会选择在其硬件中包含永久驻留的诊断镜像。
为了让NOS安装程序与已经安装的诊断镜像协作,需要布置一些基本规则。这与安装NOS和ONIE的整体协作类似。

指定如何提供诊断镜像:

  • 硬件供应商 -- 他们将就如何创建和存储他们的诊断镜像提供指导
  • 软件供应商 -- 他们将就如何调用诊断,以及如何在安装NOS时避免破坏诊断程序

主要思想是硬件供应商像安装NOS一样安装诊断镜像。

本文档的体系结构章节介绍了具体实现这一点的细节。

此外,为了帮助创建诊断镜像,ONIE发行版还提供了一个演示诊断镜像安装程序。有关更多信息,请参阅“诊断OS安装程序”部分。

3.6.固件升级

ONIE项目的目标之一是批量操作。有时硬件供应上需要更新线程硬件平台上的固件。ONIE提供了一种机制,允许用户部署大规模硬件供应商提供的固件更新。

为了这个目的,固件定义如下:

  • ONIE软件(kernel + initramfs)都包含在ONIE更新镜像中
  • BIOS/UEFI固件,大多数x86平台上的数据都位于一个8MB SPI-ROM中
  • CPLD程序,大多数平台都有一些需要更新的CPLD(典型情况是有3个),CPLD通常通过JTAG I/O进行更新,通常连接到CPU的GPIO端口上

3.6.1.在ONIE中进行固件更新

传统上,固件更新镜像通常作为特定操作系统的可执行文件交付给用户。这给硬件提供商带来了很大的负担,需要为许多不同的操作系统接口提供固件更新镜像。

对于启用了ONIE的硬件,在ONIE环境中进行固件更新。换句话说,使用ONIE系统工具在ONIE内核运行时进行固件更新。

支持这一策略的原因是:

  • 硬件厂商提供ONIE,所有他们可以在ONIE中添加必要的驱动和工具
  • 硬件厂商提供固件更新,他们知道固件需要的修订是什么
  • ONIE上下文是NOS不可知的,无需为各种操作系统编写固件更新镜像
  • ONIE环境提供给硬件厂商一个稳定的环境来开发和测试他们的更新

3.6.2.自动固件更新

固件更行镜像与ONIE自更新镜像类似,使用与指定更新镜像URL中所描述的相同镜像发现方式。这允许部署大规模的固件更新。

3.6.3.固件升级流程

ONIE中固件升级流程如下:

  • 从正常的NOS环境中开始处理
  • 重启设备进入ONIE升级模式
  • 在ONIE环境中完成更新
  • 系统重启,恢复到之前的启动状态

固件更新不应该要求重新安装NOS或清除所有的分区。

根据硬件平台和正在更新的固件,有时重启是不够的。例如,需要冷启动才能使得某些固件或CPLD更新生效。

要处理这种情况,通过将可执行文件放在/tmp/reboot-cmd中,固件更新可以指定要使用的重启命令。ONIE固件更新框架将检测到并使用它重新启动机器。例如,可执行文件可能是写CPLD冷启动恢复仅存其位的脚本。

3.6.4.在NOS中初开始固件升级

可以使用现有的DHCP/HTTP及waterfall方式部署ONIE固件更新镜像。“镜像发现和执行”中描述了镜像发现方法。

然而,在实践中,我们发现根据用户的工程部门和业务功能的性质,配置DHCP服务器可能是一项繁重的工作。有时候,一个组负责最初的NOS安装,另一个组负责硬件的日常使用。有时候,所有的机器都安装/配置在一个地方,然后将机架运往世界各地的数据中心。

对于现场更新,应用程序组可能会在第一线。

考虑到这一点,ONIE提供了一种机制来解决具有已安装和配置NOS的多个(如数百个)交换机的最终用户的情况。用户想要使用现有的编排工具对系统进行最小的中断来更新固件。我们不必重新安装NOS,也不必重新配置NOS。

这种机制下的固件更新流程:

  1. [user]从正在运行的NOS下载固件更新镜像
  2. [user]在ONIE磁盘分区中进行固件更新
  3. [user]重启ONIE进入更新模式
  4. ONIE定位并执行固件升级程序
  5. 系统重启回到NOS

上面标有 [user] 的步骤可以使用一个devops编配进行自动化,如Ansible、Puppet、Chef等。

通过现有的编排软件来部署固件升级对程序组来说方便得多,这也是他们如今采用的方式。在这种方式下,他们不需要配置DHCP服务器等。

有关固件升级的更多信息,请参阅onie-fwpkg文档。包括暂存、暂停和查询有关待定固件更新的信息。

只有基于x86_64的系统才支持固件更新分阶段。这些系统有专门用于ONIE的可用磁盘分区,为分阶段更新提供存储位置。

其他CPU类型,如PowerPC和ARM,没有这些分区。对于这些系统,可以使用传统的DHCP/HTTP ONIE更新方法进行固件更新,或使用onie-self-update命令。

3.6.5.执行分阶段固件更新(仅x86_64)

如上述,一旦进行分阶段固件更新,ONIE运行时必须在更新镜像发现阶段找到他。

在x86系统中,ONIE使用由GUID 7412F7D5-A156-4B13-81DC-867174929325标志的大容量存储介质上持久的GPT分区。当ONIE运行时,这个分区被挂载为/mnt/onie-boot。
持久性ONIE分区中的目录用于分阶段ONIE更新目录。

更新镜像发现机制在ONIE更新目录中搜索挂起的固件更新镜像,并处理以字典顺序找到的所有镜像。允许一次处理多个更新镜像。

每次尝试安装更新时,都会创建一个“结果记录”来跟踪更新结果。该记录包含有关更新版本的信息以及更新是否成功。这些记录永久存储在ONIE分区中。

onie-fwpkg命令可以打印结果记录个更新状态的信息。

3.6.5.1.示例:分阶段更新固件

以下是用于在NOS开始进行固件更新的步骤:

root@nos:/tmp# wget http://10.0.2.2/onie/onie-firmware-update
root@nos:/tmp# mkdir -p /mnt/onie-boot
root@nos:/tmp# mount LABEL=ONIE-BOOT /mnt/onie-boot
root@nos:/tmp# /mnt/onie-boot/onie/tools/bin/onie-fwpkg add onie-firmware-update
Staging firmware update: /tmp/onie-updater-x86_64-kvm_x86_64-r0
root@nos:/tmp# /mnt/onie-boot/onie/tools/bin/onie-fwpkg show
** Pending firmware update information:
Name                              | Version                    | Attempts |Size (Bytes)  | Date
==================================+============================+==========+==============+====================
onie-firmware-update              | firmware-demo-201605031508 |        0 |     11470711 | 2016-05-03 22:29:27
==================================+============================+==========+==============+====================
root@nos:/tmp# /mnt/onie-boot/onie/tools/bin/onie-boot-mode -q -o update
root@nos:/tmp# umount /mnt/onie-boot
root@nos:/tmp# reboot

This example shows:

  • mounting the ONIE-BOOT partition, where the ONIE tools reside.
  • executing the onie-fwpkg command with the add sub-command. This stages the update in the ONIE-BOOT partition.
  • executing the onie-fwpkg command with the add sub-command. This displays any currently pending firmware updates.
  • executing the onie-boot-mode command to set the system into ONIE Update mode for the next boot.

Next the system reboots in ONIE Update mode and the update is applied.

3.6.6.Format of Firmware Update Image

The firmware update image is created just like an ONIE update image. The image itself is an executable, traditionally written as a self-extracting shell archive. The additional requirement on the firmware update image, same as the ONIE update image, is that the image must include the string ONIE-UPDATER-COOKIEwithin the first 100 lines of the image.

For an example of how to create a self-extracting shell archive, see the code for the DEMO OS installer. In this case, instead of the install.sh script "installing an OS", the firmware update install.sh script would update the firmware.

In is the responsibility of the hardware vendor to include any necessary utilities in the firmware update image. For example any custom programs for updating firmware would need to either be present in the base ONIE system or provided by the installer itself.

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 159,290评论 4 363
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,399评论 1 294
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 109,021评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,034评论 0 207
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,412评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,651评论 1 219
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,902评论 2 313
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,605评论 0 199
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,339评论 1 246
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,586评论 2 246
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,076评论 1 261
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,400评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,060评论 3 236
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,083评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,851评论 0 195
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,685评论 2 274
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,595评论 2 270

推荐阅读更多精彩内容

  • 4.x86 CPU架构设计 4.1.x86硬件需求 对于通用交换机硬件需求,请参阅“交换机硬件需求”章节描述。 x...
    半天妖阅读 5,173评论 0 1
  • ONIE支持多种查找网络操作系统(NOS)镜像的方法,从简单到相对复杂。简单的方法适合在少量交换机上安装NOS,作...
    半天妖阅读 6,267评论 0 1
  • 1. 概述 1.1. 项目概述 Open Network Install Environment (ONIE...
    半天妖阅读 3,348评论 0 2
  • NAME dnsmasq - A lightweight DHCP and caching DNS server....
    ximitc阅读 2,652评论 0 0
  • 满满的亏欠 越来越浑浑噩噩,我在做什么? 糊里糊涂,深陷泥沼 对父母
    撒雅米阅读 185评论 0 0