How can I update the kernel of my Linode's configuration profile via the CLI?

Linode Staff

I'm creating Linodes with the CLI and I want to set the kernel of my new Linodes to be GRUB 2. How do I do this?

2 Replies

Linode's deprecated v3-based CLI cannot update the kernel, so we'll need to use the new v4 API to take care of this.

Installing the Python v4 API client

Linode offers a Python client for the v4 API, and we'll use that to complete this task. The following page shows how to install the Python client:

Getting Started

You'll also need to create a v4 API token; you can do this from our new cloud.linode.com website:

API Client Token

Creating a Linode and updating the kernel

Once you've installed it, launch Python in your Terminal. Then, import the LinodeClient object and create an instance of it with your API token:

>>> from linode import LinodeClient
>>> client = LinodeClient("your-api-token-here")

Then create your new Linode. These arguments will create a Linode 2GB in Fremont with our Debian 8 image and whatever root password you provide:

>>> new_linode = client.linode.create_instance(
...     "g5-standard-1",
...     region="us-west-1a",
...     image="linode/debian8",
...     booted=False,
...     root_pass="your-root-pass-here")
...
>>> new_linode
Linode: 7942105

You can also pass in other Linode plans, regions, and images. I'll include sections at the bottom of this post showing how to list what plans, regions, and images are available using the API.

Get the configuration profile object from the Linode object:

>>> config = new_linode.configs[0]

Update the kernel and save the change. I'll include a section below that shows how to list the available kernels.

>>> config.kernel = "linode/grub2"
>>> config.save()
True

Boot the Linode:

>>> new_linode.boot()
True

You should now be able to use the Linode as normal.

Listing regions, Linode plans, images, and kernels via the API

Regions:

>>> regions = client.get_regions()
>>> for region in regions:
...     print(region)
...
Region: us-central
Region: us-west
Region: us-southeast
Region: us-east
Region: eu-west
Region: ap-south
Region: eu-central
Region: ap-northeast
Region: ap-northeast-1a

Linode plans:

>>> types = client.linode.get_types()
>>> for type in types:
...     print(type)
...
Type: g5-standard-1
Type: g5-standard-2
Type: g5-standard-4
Type: g5-standard-6
Type: g5-standard-8
Type: g5-standard-12
Type: g5-standard-16
Type: g5-standard-20
Type: g5-nanode-1
Type: g5-highmem-1
Type: g5-highmem-2
Type: g5-highmem-4
Type: g5-highmem-8
Type: g5-highmem-16

Images:

>>> images = client.get_images()
>>> for image in images:
...     print(image)
...
Image: linode/slackware13.37
Image: linode/slackware14.1
Image: linode/ubuntu14.04lts
Image: linode/centos6.8
Image: linode/centos7
Image: linode/debian7
Image: linode/debian8
Image: linode/ubuntu16.04lts
Image: linode/arch
Image: linode/slackware14.2
Image: linode/gentoo
Image: linode/opensuseleap42.2
Image: linode/containerlinux
Image: linode/debian9
Image: linode/fedora26
Image: linode/opensuse42.3
Image: linode/ubuntu17.10
Image: linode/fedora27
Image: linode/ubuntu18.04
Image: linode/fedora28

Kernels:

>>> kernels = client.linode.get_kernels()
>>> for kernel in kernels:
...     print(kernel)
...

Further v4 API documentation is available on our developers site: developers.linode.com

Update

Linode recently updated the Linode CLI: linode-cli

This new version is capable of setting the kernel. Here's the syntax for that:

linode-cli linodes config-update <Linode ID> <Configuration Profile ID> --kernel "linode/grub2"

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct