@@ -137,15 +137,22 @@ Boot Kernel With a Boot Config
137137==============================
138138
139139Since the boot configuration file is loaded with initrd, it will be added
140- to the end of the initrd (initramfs) image file with size, checksum and
141- 12-byte magic word as below.
140+ to the end of the initrd (initramfs) image file with padding, size,
141+ checksum and 12-byte magic word as below.
142142
143- [initrd][bootconfig][size(u32)][checksum(u32)][#BOOTCONFIG\n ]
143+ [initrd][bootconfig][padding][size(u32)][checksum(u32)][#BOOTCONFIG\n ]
144+
145+ When the boot configuration is added to the initrd image, the total
146+ file size is aligned to 4 bytes. To fill the gap, null characters
147+ (``\0 ``) will be added. Thus the ``size `` is the length of the bootconfig
148+ file + padding bytes.
144149
145150The Linux kernel decodes the last part of the initrd image in memory to
146151get the boot configuration data.
147152Because of this "piggyback" method, there is no need to change or
148- update the boot loader and the kernel image itself.
153+ update the boot loader and the kernel image itself as long as the boot
154+ loader passes the correct initrd file size. If by any chance, the boot
155+ loader passes a longer size, the kernel feils to find the bootconfig data.
149156
150157To do this operation, Linux kernel provides "bootconfig" command under
151158tools/bootconfig, which allows admin to apply or delete the config file
@@ -176,7 +183,8 @@ up to 512 key-value pairs. If keys contains 3 words in average, it can
176183contain 256 key-value pairs. In most cases, the number of config items
177184will be under 100 entries and smaller than 8KB, so it would be enough.
178185If the node number exceeds 1024, parser returns an error even if the file
179- size is smaller than 32KB.
186+ size is smaller than 32KB. (Note that this maximum size is not including
187+ the padding null characters.)
180188Anyway, since bootconfig command verifies it when appending a boot config
181189to initrd image, user can notice it before boot.
182190
0 commit comments