1*b989648cSHeinrich Schuchardt# iSCSI booting with U-Boot and iPXE 229a8a282SHeinrich Schuchardt 3*b989648cSHeinrich Schuchardt## Motivation 429a8a282SHeinrich Schuchardt 529a8a282SHeinrich SchuchardtU-Boot has only a reduced set of supported network protocols. The focus for 629a8a282SHeinrich Schuchardtnetwork booting has been on UDP based protocols. A TCP stack and HTTP support 729a8a282SHeinrich Schuchardtare expected to be integrated in 2018 together with a wget command. 829a8a282SHeinrich Schuchardt 929a8a282SHeinrich SchuchardtFor booting a diskless computer this leaves us with BOOTP or DHCP to get the 1029a8a282SHeinrich Schuchardtaddress of a boot script. TFTP or NFS can be used to load the boot script, the 1129a8a282SHeinrich Schuchardtoperating system kernel and the initial file system (initrd). 1229a8a282SHeinrich Schuchardt 1329a8a282SHeinrich SchuchardtThese protocols are insecure. The client cannot validate the authenticity 1429a8a282SHeinrich Schuchardtof the contacted servers. And the server cannot verify the identity of the 1529a8a282SHeinrich Schuchardtclient. 1629a8a282SHeinrich Schuchardt 1729a8a282SHeinrich SchuchardtFurthermore the services providing the operating system loader or kernel are 1829a8a282SHeinrich Schuchardtnot the ones that the operating system typically will use. Especially in a SAN 1929a8a282SHeinrich Schuchardtenvironment this makes updating the operating system a hassle. After installing 2029a8a282SHeinrich Schuchardta new kernel version the boot files have to be copied to the TFTP server 2129a8a282SHeinrich Schuchardtdirectory. 2229a8a282SHeinrich Schuchardt 2329a8a282SHeinrich SchuchardtThe HTTPS protocol provides certificate based validation of servers. Sensitive 2429a8a282SHeinrich Schuchardtdata like passwords can be securely transmitted. 2529a8a282SHeinrich Schuchardt 2629a8a282SHeinrich SchuchardtThe iSCSI protocol is used for connecting storage attached networks. It 2729a8a282SHeinrich Schuchardtprovides mutual authentication using the CHAP protocol. It typically runs on 2829a8a282SHeinrich Schuchardta TCP transport. 2929a8a282SHeinrich Schuchardt 3029a8a282SHeinrich SchuchardtThus a better solution than DHCP/TFTP/NFS boot would be to load a boot script 3129a8a282SHeinrich Schuchardtvia HTTPS and to download any other files needed for booting via iSCSI from the 3229a8a282SHeinrich Schuchardtsame target where the operating system is installed. 3329a8a282SHeinrich Schuchardt 3429a8a282SHeinrich SchuchardtAn alternative to implementing these protocols in U-Boot is to use an existing 3576a472dcSHeinrich Schuchardtsoftware that can run on top of U-Boot. iPXE[1] is the "swiss army knife" of 3629a8a282SHeinrich Schuchardtnetwork booting. It supports both HTTPS and iSCSI. It has a scripting engine for 3729a8a282SHeinrich Schuchardtfine grained control of the boot process and can provide a command shell. 3829a8a282SHeinrich Schuchardt 3929a8a282SHeinrich SchuchardtiPXE can be built as an EFI application (named snp.efi) which can be loaded and 4029a8a282SHeinrich Schuchardtrun by U-Boot. 4129a8a282SHeinrich Schuchardt 42*b989648cSHeinrich Schuchardt## Boot sequence 4329a8a282SHeinrich Schuchardt 4429a8a282SHeinrich SchuchardtU-Boot loads the EFI application iPXE snp.efi using the bootefi command. This 4529a8a282SHeinrich Schuchardtapplication has network access via the simple network protocol offered by 4629a8a282SHeinrich SchuchardtU-Boot. 4729a8a282SHeinrich Schuchardt 4829a8a282SHeinrich SchuchardtiPXE executes its internal script. This script may optionally chain load a 4929a8a282SHeinrich Schuchardtsecondary boot script via HTTPS or open a shell. 5029a8a282SHeinrich Schuchardt 5129a8a282SHeinrich SchuchardtFor the further boot process iPXE connects to the iSCSI server. This includes 5229a8a282SHeinrich Schuchardtthe mutual authentication using the CHAP protocol. After the authentication iPXE 5329a8a282SHeinrich Schuchardthas access to the iSCSI targets. 5429a8a282SHeinrich Schuchardt 5529a8a282SHeinrich SchuchardtFor a selected iSCSI target iPXE sets up a handle with the block IO protocol. It 5629a8a282SHeinrich Schuchardtuses the ConnectController boot service of U-Boot to request U-Boot to connect a 5729a8a282SHeinrich Schuchardtfile system driver. U-Boot reads from the iSCSI drive via the block IO protocol 5829a8a282SHeinrich Schuchardtoffered by iPXE. It creates the partition handles and installs the simple file 5976a472dcSHeinrich Schuchardtprotocol. Now iPXE can call the simple file protocol to load GRUB[2]. U-Boot 6076a472dcSHeinrich Schuchardtuses the block IO protocol offered by iPXE to fulfill the request. 6129a8a282SHeinrich Schuchardt 6276a472dcSHeinrich SchuchardtOnce GRUB is started it uses the same block IO protocol to load Linux. Via 6376a472dcSHeinrich Schuchardtthe EFI stub Linux is called as an EFI application:: 6429a8a282SHeinrich Schuchardt 6529a8a282SHeinrich Schuchardt +--------+ +--------+ 6629a8a282SHeinrich Schuchardt | | Runs | | 6776a472dcSHeinrich Schuchardt | U-Boot |========>| iPXE | 6829a8a282SHeinrich Schuchardt | EFI | | snp.efi| 6929a8a282SHeinrich Schuchardt +--------+ | | DHCP | | 7076a472dcSHeinrich Schuchardt | |<===|********|<========| | 7129a8a282SHeinrich Schuchardt | DHCP | | | Get IP | | 7229a8a282SHeinrich Schuchardt | Server | | | Address | | 7376a472dcSHeinrich Schuchardt | |===>|********|========>| | 7429a8a282SHeinrich Schuchardt +--------+ | | Response| | 7529a8a282SHeinrich Schuchardt | | | | 7629a8a282SHeinrich Schuchardt | | | | 7729a8a282SHeinrich Schuchardt +--------+ | | HTTPS | | 7876a472dcSHeinrich Schuchardt | |<===|********|<========| | 7929a8a282SHeinrich Schuchardt | HTTPS | | | Load | | 8029a8a282SHeinrich Schuchardt | Server | | | Script | | 8176a472dcSHeinrich Schuchardt | |===>|********|========>| | 8229a8a282SHeinrich Schuchardt +--------+ | | | | 8329a8a282SHeinrich Schuchardt | | | | 8429a8a282SHeinrich Schuchardt | | | | 8529a8a282SHeinrich Schuchardt +--------+ | | iSCSI | | 8676a472dcSHeinrich Schuchardt | |<===|********|<========| | 8729a8a282SHeinrich Schuchardt | iSCSI | | | Auth | | 8876a472dcSHeinrich Schuchardt | Server |===>|********|========>| | 8929a8a282SHeinrich Schuchardt | | | | | | 9029a8a282SHeinrich Schuchardt | | | | Loads | | 9176a472dcSHeinrich Schuchardt | |<===|********|<========| | +--------+ 9276a472dcSHeinrich Schuchardt | | | | GRUB | | Runs | | 9376a472dcSHeinrich Schuchardt | |===>|********|========>| |======>| GRUB | 9429a8a282SHeinrich Schuchardt | | | | | | | | 9529a8a282SHeinrich Schuchardt | | | | | | | | 9629a8a282SHeinrich Schuchardt | | | | | | Loads | | 9776a472dcSHeinrich Schuchardt | |<===|********|<========|********|<======| | +--------+ 9829a8a282SHeinrich Schuchardt | | | | | | Linux | | Runs | | 9976a472dcSHeinrich Schuchardt | |===>|********|========>|********|======>| |=====>| Linux | 10029a8a282SHeinrich Schuchardt | | | | | | | | | | 10129a8a282SHeinrich Schuchardt +--------+ +--------+ +--------+ +--------+ | | 10229a8a282SHeinrich Schuchardt | | 10329a8a282SHeinrich Schuchardt | | 10429a8a282SHeinrich Schuchardt | ~ ~ ~ ~| 10529a8a282SHeinrich Schuchardt 106*b989648cSHeinrich Schuchardt## Security 10729a8a282SHeinrich Schuchardt 10829a8a282SHeinrich SchuchardtThe iSCSI protocol is not encrypted. The traffic could be secured using IPsec 10929a8a282SHeinrich Schuchardtbut neither U-Boot nor iPXE does support this. So we should at least separate 11029a8a282SHeinrich Schuchardtthe iSCSI traffic from all other network traffic. This can be achieved using a 11129a8a282SHeinrich Schuchardtvirtual local area network (VLAN). 11229a8a282SHeinrich Schuchardt 113*b989648cSHeinrich Schuchardt## Configuration 11429a8a282SHeinrich Schuchardt 115*b989648cSHeinrich Schuchardt### iPXE 11629a8a282SHeinrich Schuchardt 11776a472dcSHeinrich SchuchardtFor running iPXE on arm64 the bin-arm64-efi/snp.efi build target is needed:: 11829a8a282SHeinrich Schuchardt 11929a8a282SHeinrich Schuchardt git clone http://git.ipxe.org/ipxe.git 12029a8a282SHeinrich Schuchardt cd ipxe/src 12129a8a282SHeinrich Schuchardt make bin-arm64-efi/snp.efi -j6 EMBED=myscript.ipxe 12229a8a282SHeinrich Schuchardt 12329a8a282SHeinrich SchuchardtThe available commands for the boot script are documented at: 12429a8a282SHeinrich Schuchardt 12529a8a282SHeinrich Schuchardthttp://ipxe.org/cmd 12629a8a282SHeinrich Schuchardt 12729a8a282SHeinrich SchuchardtCredentials are managed as environment variables. These are described here: 12829a8a282SHeinrich Schuchardt 12929a8a282SHeinrich Schuchardthttp://ipxe.org/cfg 13029a8a282SHeinrich Schuchardt 13129a8a282SHeinrich SchuchardtiPXE by default will put the CPU to rest when waiting for input. U-Boot does 13229a8a282SHeinrich Schuchardtnot wake it up due to missing interrupt support. To avoid this behavior create 13376a472dcSHeinrich Schuchardtfile src/config/local/nap.h:: 13429a8a282SHeinrich Schuchardt 13529a8a282SHeinrich Schuchardt /* nap.h */ 13629a8a282SHeinrich Schuchardt #undef NAP_EFIX86 13729a8a282SHeinrich Schuchardt #undef NAP_EFIARM 13829a8a282SHeinrich Schuchardt #define NAP_NULL 13929a8a282SHeinrich Schuchardt 14029a8a282SHeinrich SchuchardtThe supported commands in iPXE are controlled by an include, too. Putting the 14176a472dcSHeinrich Schuchardtfollowing into src/config/local/general.h is sufficient for most use cases:: 14229a8a282SHeinrich Schuchardt 14329a8a282SHeinrich Schuchardt /* general.h */ 14429a8a282SHeinrich Schuchardt #define NSLOOKUP_CMD /* Name resolution command */ 14529a8a282SHeinrich Schuchardt #define PING_CMD /* Ping command */ 14629a8a282SHeinrich Schuchardt #define NTP_CMD /* NTP commands */ 14729a8a282SHeinrich Schuchardt #define VLAN_CMD /* VLAN commands */ 14829a8a282SHeinrich Schuchardt #define IMAGE_EFI /* EFI image support */ 14929a8a282SHeinrich Schuchardt #define DOWNLOAD_PROTO_HTTPS /* Secure Hypertext Transfer Protocol */ 15029a8a282SHeinrich Schuchardt #define DOWNLOAD_PROTO_FTP /* File Transfer Protocol */ 15129a8a282SHeinrich Schuchardt #define DOWNLOAD_PROTO_NFS /* Network File System Protocol */ 15229a8a282SHeinrich Schuchardt #define DOWNLOAD_PROTO_FILE /* Local file system access */ 15329a8a282SHeinrich Schuchardt 154*b989648cSHeinrich Schuchardt### Open-iSCSI 155*b989648cSHeinrich Schuchardt 156*b989648cSHeinrich SchuchardtWhen the root file system is on an iSCSI drive you should disable pings and set 157*b989648cSHeinrich Schuchardtthe replacement timer to a high value [3]: 158*b989648cSHeinrich Schuchardt 159*b989648cSHeinrich Schuchardt node.conn[0].timeo.noop_out_interval = 0 160*b989648cSHeinrich Schuchardt node.conn[0].timeo.noop_out_timeout = 0 161*b989648cSHeinrich Schuchardt node.session.timeo.replacement_timeout = 86400 162*b989648cSHeinrich Schuchardt 163*b989648cSHeinrich Schuchardt## Links 16429a8a282SHeinrich Schuchardt 16576a472dcSHeinrich Schuchardt* [1](https://ipxe.org) https://ipxe.org - iPXE open source boot firmware 16676a472dcSHeinrich Schuchardt* [2](https://www.gnu.org/software/grub/) https://www.gnu.org/software/grub/ - 16776a472dcSHeinrich Schuchardt GNU GRUB (Grand Unified Bootloader) 168*b989648cSHeinrich Schuchardt* [3](https://github.com/open-iscsi/open-iscsi/blob/master/README) 169*b989648cSHeinrich Schuchardt https://github.com/open-iscsi/open-iscsi/blob/master/README - 170*b989648cSHeinrich Schuchardt Open-iSCSI README 171