README.iscsi 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. iSCSI booting with U-Boot and iPXE
  2. ==================================
  3. Motivation
  4. ----------
  5. U-Boot has only a reduced set of supported network protocols. The focus for
  6. network booting has been on UDP based protocols. A TCP stack and HTTP support
  7. are expected to be integrated in 2018 together with a wget command.
  8. For booting a diskless computer this leaves us with BOOTP or DHCP to get the
  9. address of a boot script. TFTP or NFS can be used to load the boot script, the
  10. operating system kernel and the initial file system (initrd).
  11. These protocols are insecure. The client cannot validate the authenticity
  12. of the contacted servers. And the server cannot verify the identity of the
  13. client.
  14. Furthermore the services providing the operating system loader or kernel are
  15. not the ones that the operating system typically will use. Especially in a SAN
  16. environment this makes updating the operating system a hassle. After installing
  17. a new kernel version the boot files have to be copied to the TFTP server
  18. directory.
  19. The HTTPS protocol provides certificate based validation of servers. Sensitive
  20. data like passwords can be securely transmitted.
  21. The iSCSI protocol is used for connecting storage attached networks. It
  22. provides mutual authentication using the CHAP protocol. It typically runs on
  23. a TCP transport.
  24. Thus a better solution than DHCP/TFTP/NFS boot would be to load a boot script
  25. via HTTPS and to download any other files needed for booting via iSCSI from the
  26. same target where the operating system is installed.
  27. An alternative to implementing these protocols in U-Boot is to use an existing
  28. software that can run on top of U-Boot. iPXE[1] is the "swiss army knife" of
  29. network booting. It supports both HTTPS and iSCSI. It has a scripting engine for
  30. fine grained control of the boot process and can provide a command shell.
  31. iPXE can be built as an EFI application (named snp.efi) which can be loaded and
  32. run by U-Boot.
  33. Boot sequence
  34. -------------
  35. U-Boot loads the EFI application iPXE snp.efi using the bootefi command. This
  36. application has network access via the simple network protocol offered by
  37. U-Boot.
  38. iPXE executes its internal script. This script may optionally chain load a
  39. secondary boot script via HTTPS or open a shell.
  40. For the further boot process iPXE connects to the iSCSI server. This includes
  41. the mutual authentication using the CHAP protocol. After the authentication iPXE
  42. has access to the iSCSI targets.
  43. For a selected iSCSI target iPXE sets up a handle with the block IO protocol. It
  44. uses the ConnectController boot service of U-Boot to request U-Boot to connect a
  45. file system driver. U-Boot reads from the iSCSI drive via the block IO protocol
  46. offered by iPXE. It creates the partition handles and installs the simple file
  47. protocol. Now iPXE can call the simple file protocol to load GRUB[2]. U-Boot
  48. uses the block IO protocol offered by iPXE to fulfill the request.
  49. Once GRUB is started it uses the same block IO protocol to load Linux. Via
  50. the EFI stub Linux is called as an EFI application::
  51. +--------+ +--------+
  52. | | Runs | |
  53. | U-Boot |========>| iPXE |
  54. | EFI | | snp.efi|
  55. +--------+ | | DHCP | |
  56. | |<===|********|<========| |
  57. | DHCP | | | Get IP | |
  58. | Server | | | Address | |
  59. | |===>|********|========>| |
  60. +--------+ | | Response| |
  61. | | | |
  62. | | | |
  63. +--------+ | | HTTPS | |
  64. | |<===|********|<========| |
  65. | HTTPS | | | Load | |
  66. | Server | | | Script | |
  67. | |===>|********|========>| |
  68. +--------+ | | | |
  69. | | | |
  70. | | | |
  71. +--------+ | | iSCSI | |
  72. | |<===|********|<========| |
  73. | iSCSI | | | Auth | |
  74. | Server |===>|********|========>| |
  75. | | | | | |
  76. | | | | Loads | |
  77. | |<===|********|<========| | +--------+
  78. | | | | GRUB | | Runs | |
  79. | |===>|********|========>| |======>| GRUB |
  80. | | | | | | | |
  81. | | | | | | | |
  82. | | | | | | Loads | |
  83. | |<===|********|<========|********|<======| | +--------+
  84. | | | | | | Linux | | Runs | |
  85. | |===>|********|========>|********|======>| |=====>| Linux |
  86. | | | | | | | | | |
  87. +--------+ +--------+ +--------+ +--------+ | |
  88. | |
  89. | |
  90. | ~ ~ ~ ~|
  91. Security
  92. --------
  93. The iSCSI protocol is not encrypted. The traffic could be secured using IPsec
  94. but neither U-Boot nor iPXE does support this. So we should at least separate
  95. the iSCSI traffic from all other network traffic. This can be achieved using a
  96. virtual local area network (VLAN).
  97. Configuration
  98. -------------
  99. iPXE
  100. ^^^^
  101. For running iPXE on arm64 the bin-arm64-efi/snp.efi build target is needed::
  102. git clone http://git.ipxe.org/ipxe.git
  103. cd ipxe/src
  104. make bin-arm64-efi/snp.efi -j6 EMBED=myscript.ipxe
  105. The available commands for the boot script are documented at:
  106. http://ipxe.org/cmd
  107. Credentials are managed as environment variables. These are described here:
  108. http://ipxe.org/cfg
  109. iPXE by default will put the CPU to rest when waiting for input. U-Boot does
  110. not wake it up due to missing interrupt support. To avoid this behavior create
  111. file src/config/local/nap.h::
  112. /* nap.h */
  113. #undef NAP_EFIX86
  114. #undef NAP_EFIARM
  115. #define NAP_NULL
  116. The supported commands in iPXE are controlled by an include, too. Putting the
  117. following into src/config/local/general.h is sufficient for most use cases::
  118. /* general.h */
  119. #define NSLOOKUP_CMD /* Name resolution command */
  120. #define PING_CMD /* Ping command */
  121. #define NTP_CMD /* NTP commands */
  122. #define VLAN_CMD /* VLAN commands */
  123. #define IMAGE_EFI /* EFI image support */
  124. #define DOWNLOAD_PROTO_HTTPS /* Secure Hypertext Transfer Protocol */
  125. #define DOWNLOAD_PROTO_FTP /* File Transfer Protocol */
  126. #define DOWNLOAD_PROTO_NFS /* Network File System Protocol */
  127. #define DOWNLOAD_PROTO_FILE /* Local file system access */
  128. Links
  129. -----
  130. * [1](https://ipxe.org) https://ipxe.org - iPXE open source boot firmware
  131. * [2](https://www.gnu.org/software/grub/) https://www.gnu.org/software/grub/ -
  132. GNU GRUB (Grand Unified Bootloader)