
grubby Command in Linux
The grubby command is a versatile tool in Linux that allows users to interact with the bootloader configuration, particularly for systems using GRUB (Grand Unified Bootloader). It is an essential utility for system administrators and users who need to manage kernel boot parameters and configurations without directly editing bootloader files.
Table of Contents
Here is a comprehensive guide to the options available with the grubby command −
Understanding grubby Command
The grubby command is a powerful utility in Linux that is used for updating and configuring bootloader settings. It is particularly useful for managing kernel parameters and boot entries, especially when multiple kernels are installed on a system.
Following are the options and flags available with the grubby command −
Options | Descriptions |
---|---|
--make-default | Makes the specified kernel the default for booting. |
--copy-default | Copies the default kernel's parameters when adding a new kernel entry. |
--update-kernel=path | Updates an existing kernel entry with new settings. |
--remove-kernel=path | Removes the specified kernel from the bootloader configuration. |
--add-kernel=path | Adds a new kernel to the bootloader configuration. The path should point to the kernel image. |
--args=args | Adds the specified arguments to the kernel command line. |
--remove-args=args | Removes the specified arguments from the kernel command line. |
--info=ALL | Displays information about all configured kernel entries. |
--info=DEFAULT | Displays information about the default kernel entry. |
--default-index | Outputs the index of the default kernel. |
--default-title | Outputs the title of the default kernel. |
--set-default=path | Sets the specified kernel as the default. |
--set-default-index=index | Sets the kernel at the specified index as the default. |
--add-initrd=path | Adds an initial ramdisk for the specified kernel. |
--remove-initrd=path | Removes the initial ramdisk for the specified kernel. |
--list=ALL | Lists all configured kernel entries. |
--default-kernel | Outputs the path of the default kernel. |
--env-var=name=value | Sets an environment variable in the bootloader configuration. |
--bootloader-probe | Outputs the type of bootloader installed. |
--help | Displays the help message with all options and usage. |
Each of these options allows system administrators to fine-tune the boot process, ensuring that the system boots with the correct parameters and kernel. It's important to use these commands with caution, as incorrect settings can lead to an unbootable system.
Examples of grubby Command in Linux
The grubby command is a versatile utility in Linux that allows users to modify and manage their bootloader configurations, particularly for systems that use GRUB (GRand Unified Bootloader). It's an essential tool for system administrators and those who need to maintain multiple kernel versions.
Here's a comprehensive guide to using the grubby command with examples −
- Adding a New Kernel Entry
- Removing a Kernel Entry
- Adding Kernel Arguments
- Removing Kernel Arguments
- Listing Installed Kernels
- Setting the Default Kernel
- Getting Information on Kernel Boot Entries
- Changing the Default Boot Entry
- Adding and Removing Kernel Arguments Simultaneously
Adding a New Kernel Entry
The --add-kernel option allows you to add a new kernel entry to the bootloader configuration. This is useful when you have compiled a custom kernel and want to add it to the boot menu. To add a new kernel entry, you can use the following syntax −
grubby --add-kernel=/path/to/new_kernel --title="New Kernel Title" --initrd=/path/to/initrd --copy-default
This command copies all kernel arguments from the default kernel to the new kernel entry. If you want to add custom kernel arguments, you can use --args option. Using --copy-default copies all kernel arguments from the default kernel to the new entry. To add custom kernel arguments, use --args.
Removing a Kernel Entry
To remove an existing kernel entry, use the --remove-kernel option. This helps in cleaning up old kernels from the boot menu.If you need to remove a kernel entry, the command is −
grubby --remove-kernel=/path/to/kernel
This will delete the specified kernel from the bootloader configuration.
Adding Kernel Arguments
The --update-kernel option followed by --args allows you to add new arguments or modify existing ones for a specific kernel.To add new arguments to a kernel entry −
grubby --update-kernel=/path/to/kernel --args="new_arguments"
This adds the specified arguments to the kernel command line.
Removing Kernel Arguments
If you need to remove specific kernel arguments, use the --remove-args option.
Similarly, to remove arguments −
grubby --update-kernel=/path/to/kernel --remove-args="arguments_to_remove"
This command removes the specified arguments from the kernel command line.
Listing Installed Kernels
You can list all the kernel entries in the bootloader configuration using the --info=ALL option.To list all installed kernels −
grubby --info=ALL
This will display information about all the kernels installed on the system.
Setting the Default Kernel
The --set-default option sets the specified kernel as the default one to boot.You can set the default kernel by specifying its path −
grubby --set-default=/path/to/kernel
This command sets the specified kernel as the default for booting.
Getting Information on Kernel Boot Entries
To get detailed information about a specific kernel entry, use the --info option with the kernel path.For more detailed information on a specific kernel boot entry −
grubby --info=/path/to/kernel
This provides detailed information about the specified kernel boot entry.
Changing the Default Boot Entry
Instead of specifying the kernel path, you can also set the default kernel by its index in the boot menu using --set-default-index.
To change the default boot entry to another installed kernel −
grubby --set-default-index=0
The index corresponds to the order of the kernel entries as listed by the --info=ALL command.
Adding and Removing Kernel Arguments Simultaneously
The grubby command allows you to add and remove kernel arguments in one go using --args and --remove-args together.
grubby --update-kernel=/path/to/kernel --args="new_arguments" --remove-args="arguments_to_remove"
These examples cover the most common uses of the grubby command. It's a powerful tool that can greatly simplify the management of boot configurations, especially on systems with multiple kernels. Always remember to be cautious when using grubby, as incorrect commands can affect the system's ability to boot properly.
For more detailed examples and explanations, you can refer to the comprehensive tutorials available online. These resources provide step-by-step guides and additional context that can be invaluable for both new and experienced Linux users.
Remember, managing bootloaders and kernels is a critical task, and having a solid understanding of tools like grubby can make system maintenance much more manageable.
Conclusion
The grubby command is a powerful tool for managing the bootloader configuration on Linux systems. It provides a safer and more convenient way to modify boot parameters than manually editing configuration files.
By understanding and utilizing the options available in grubby, users can ensure their system boots with the correct parameters and maintain a clean and organized boot menu.