Import appending kernel parameters to advanced section. Change-Id: Id688a06ddcdcdfd7dae98e48381f92894825bff8 Partial-bug: #1612278
2.3 KiB
Appending kernel parameters to boot instances
The Bare Metal service supports passing custom kernel parameters to boot instances to fit users' requirements. The way to append the kernel parameters is depending on how to boot instances.
Network boot
Currently, the Bare Metal service supports assigning unified kernel parameters to PXE booted instances by:
Modifying the
[pxe]/pxe_append_params
configuration option, for example:[pxe] pxe_append_params = quiet splash
Copying a template from shipped templates to another place, for example:
https://git.openstack.org/cgit/openstack/ironic/tree/ironic/drivers/modules/pxe_config.template
Making the modifications and pointing to the custom template via the configuration options:
[pxe]/pxe_config_template
and[pxe]/uefi_pxe_config_template
.
Local boot
For local boot instances, users can make use of configuration drive
(see configdrive
) to
pass a custom script to append kernel parameters when creating an
instance. This is more flexible and can vary per instance. Here is an
example for grub2 with ubuntu, users can customize it to fit their use
case:
#!/usr/bin/env python import os # Default grub2 config file in Ubuntu = '/etc/default/grub' grub_file # Add parameters here to pass to instance. = ['quiet', 'splash'] kernel_parameters = 'GRUB_CMDLINE_LINUX' grub_cmd = grub_file+'~' old_grub_file os.rename(grub_file, old_grub_file)= False cmdline_existed with open(grub_file, 'w') as writer, \ open(old_grub_file, 'r') as reader: for line in reader: = line.split('=')[0] key if key == grub_cmd: #If there is already some value: if line.strip()[-1] == '"': = line.strip()[:-1] + ' ' + ' '.join(kernel_parameters) + '"' line = True cmdline_existed writer.write(line)if not cmdline_existed: = grub_cmd + '=' + '"' + ' '.join(kernel_parameters) + '"' line writer.write(line) os.remove(old_grub_file)'update-grub') os.system('reboot') os.system(