Can I set boot parameters for the kernel through the #cloud-config

I would like to set kernel parameters through the droplet’s initialization script #cloud-config.

I saw your tutorials to set user related configuration , but I have been unable to find information about to pass configuration setting for the kernel through the #cloud-config script

If this is possible, could you provide me with an example that shows how I would pass boot loader command parameters equivalent to "ignore_loglevel debug log_buf_len=100M "

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Site Moderator
Site Moderator badge
June 19, 2023

Heya @cybertrapped,

You can set the Kernel parameters in the GRUB configuration file and then reboot your Droplet to make the changes take effect.

With that said, yes, you can use cloud-config to update Grub and then reboot your Droplet.

The kernel parameters are typically added in the line starting with GRUB_CMDLINE_LINUX_DEFAULT in the /etc/default/grub file.

Here’s an example cloud-config that would append “ignore_loglevel debug log_buf_len=100M” to your kernel command line:

-   path: /etc/default/grub.d/50-cloudimg-settings.cfg
    content: |
        GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT ignore_loglevel debug log_buf_len=100M"
-   update-grub

This script will create a new file under /etc/default/grub.d/ with the name 50-cloudimg-settings.cfg. The content of the file is GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT ignore_loglevel debug log_buf_len=100M".

It’s important to note that the files in this directory are processed in alphanumeric order, and they modify the environment variables that are used in the main /etc/default/grub file.

The runcmd directive will run update-grub command to regenerate the GRUB configuration file.

On the next reboot, your new kernel parameters will be in effect.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel