学习了一下 PXE,有时间搭建一个 PXE 服务器玩玩,以下仅为我的理解

关于 PXE

PXE 是一种系统引导方式,由 Intel 提出(文末有 PDF 文档下载)。PXE 的客户端已经内置在网卡中,服务端需要搭建(需要保证搭建网络环境安全,PXE 服务是不安全的),一般用于企业大量机器的系统安装

BIOS 启动选项中经常见到的 通过网络 (IPv4、IPv6) 启动就是 PXE 服务

PXE 服务端的搭建需要 DHCP(或 proxyDHCP,详见后文) 和 TFTP 服务,其中

  • DHCP 服务用来分配 IP 地址并发放 PXE 的 TFTP 地址等信息
  • TFTP 服务向客户端传输文件(引导文件、安装文件等)

也就是说在 PXE 中,一般启动方式中的从存储介质(U盘、硬盘)读取文件改为从远程服务器下载——省去了装系统时一个个拔插U盘的动作,在给大量机器装系统的场景下更高效

PXE 的启动过程

  1. 客户端(PC 网卡)向网络广播包含了 PXE 标签(表示要从网络启动,区分于一般的DHCP请求)的扩展 DHCP 包
  2. DHCP服务捕获到这些包,向客户端发送 IP 地址信息
  3. 客户端再向 DHCP 服务器请求 TFTP 服务器地址
  4. DHCP 服务器返回 TFTP 服务器地址
  5. 客户端再向 DHCP 服务器请求 TFTP 服务器中启动镜像的路径(包含文件名称)
  6. DHCP 服务器返回启动镜像的路径
  7. 客户端连接 TFTP 服务器,请求启动镜像
  8. TFTP 服务器发送启动镜像,客户端将启动镜像下载到内存中

之后的启动过程与 PXE 无关,可见 PXE 只负责系统引导部分

关于 proxyDHCP

proxyDHCP 是为非 PXE 的 DHCP 环境提供 PXE 服务的软件

非八股文版本:上文提到的 DHCP 服务默认包含了 PXE,而在家庭网络中,DHCP服务一般内置在路由器(或网络运营商送的带路由功能的光猫)中,这些设备的 DHCP 服务一般是不支持 PXE 的,这时就可以在网络中专门用一个电脑搭建 PXE 服务,来接管网络中的 PXE 请求

proxyDHCP 的启动过程:

与上文相同,只是拆分了 IP 分配和 TFTP 信息获取——DHCP 负责 IP 分配,proxyDHCP 负责返回 TFTP 信息

文档下载

Intel 的 PXE PDF 文档:pxe spec

I just tried NiceHash OS on MacBook and didn’t test the main mining function. This article only talks about how to install the OS then has a slight glimpse of it.

Before anything happens, it’s necessary to clarify that the whole public Beta thing does not contain real money transfer. In other words, if you set the mining address to the Beta wallet address, you will receive TBTC(Test BTC) instead of real BTC, you will not get any profit from it. For more information, check the official announcement here.

Requirements

Reference

Steps

  1. First, burn the image into the flash drive.
    • Plug the flash drive in.
    • Open Etcher, select NiceHash OS, then select the USB drive, start burning.
    • This is quite like burning Raspberry Pi OS to a SD card, I think Win32DiskImager in Windows can do the same job.
  2. Before we boot from the flash drive, we need to configure the OS.
    • Open the “configuration.txt” file in the “NHOS” drive.
    • Modify “btc”, “worker” and “group” value in the “rig” section.
    • If you want to get access to the mining machine through SSH, you need to modify the “access” section.
    • If you are using wifi network, you also need to fill your wifi ssid and password into the “network” section.
    • All of these are optional except the “btc” value.
  3. Reboot your computer, then enter the Boot menu(Different motherboards have different ways, generally, you can press F2, F11, F12 or Del key to enter the menu. For my situation(MacBook), it’s pressing the option/alt key.).
  4. Select the USB device, then enter the OS.The big logo shows up.
  5. It takes a few minutes for the system to load files, then you enter the CLI, type “nhos” to login(no password needed).
  6. The NiceHash OS is based on TinyCore Linux distro, you can use basic commands that inherited from Linux, such as “ls”, “cat”, “cd”, etc.
    Another thing to mention, NiceHash OS is running from computer’s memory, it’s like all the other Linux distros’ live CD mode. Nothing will last if you reboot the system, except ones in /mnt/nhos directory.

    • The system log is in /var/log/nhos directory.

I didn’t do further operation in the system, the user guide shows that there’s a config file if you want to OC your GPU and choose the proper mining algorithm. Also, if you want to report bug to NiceHash, you can use nhos_system_dump_save to generate system dump file and nhos_system_dump_push to generate dump file and push it to NiceHash.