README.iscsi 6.9 KB

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