Is it possible to dictate which kernel to use when creating a Linode with API?
I would like to boot with a kernel other than the default when booting Linodes via the API. How can this be done?
1 Reply
Hello,
Users are unable to specify a kernel to launch with when creating a new Linode. To boot into a desired kernel via the API, you would first have to prevent its initial boot by issuing call with "booted": false,
as such (with whatever specific configurations and additional calls you require) —
curl -X POST https://api.linode.com/v4/linode/instances \
-H "Authorization: Bearer $TOKEN" -H "Content-type: application/json" \
-d '{"type": "g6-standard-2", "region": "us-east", "image": "linode/debian9", "root_pass": "$annpl3p@$$w0Rd", "label": "nameoflinode", "booted": false}'
Once this Linode has been created, you can issue a call altering the kernel of the desired configuration.
curl -H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-X PUT -d '{
"kernel": "linode/direct-disk"
}' \
https://api.linode.com/v4/linode/instances/$LINODE_ID/configs/$CONFIG_ID
Your Linodes and relevant Configuration ID required for the above command can be gathered from the following calls, respectively:
curl -H "Authorization: Bearer $TOKEN" \
https://api.linode.com/v4/linode/instances
curl -H "Authorization: Bearer $TOKEN" \
https://api.linode.com/v4/linode/instances/$LINODE_ID/configs
Once the configuration has been updated with the desired kernel, issue a boot command as featured below, and your Linode will be booted with the desired kernel.
curl -H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-X POST \
https://api.linode.com/v4/linode/instances/$LINODE_ID/boot
More information about each of these calls can be found at our API Documentation.