| name | grub-bootloader |
| description | GRUB bootloader configuration and installation. Use when configuring boot menus, installing GRUB to disk, setting up multi-boot systems, or customizing boot parameters. |
GRUB Bootloader
Configure and install the GRUB bootloader for Linux systems.
Installation
# Install GRUB to MBR
grub-install /dev/sda
# Install GRUB for UEFI
grub-install --target=x86_64-efi --efi-directory=/boot/efi
# Install to directory (for ISO creation)
grub-install --target=i386-pc --boot-directory=/mnt/boot /dev/sda
Configuration File
Create /boot/grub/grub.cfg:
set timeout=5
set default=0
menuentry "Linux" {
linux /boot/vmlinuz root=/dev/sda1 ro quiet
initrd /boot/initrd.img
}
menuentry "Linux (Recovery)" {
linux /boot/vmlinuz root=/dev/sda1 ro single
initrd /boot/initrd.img
}
menuentry "Custom Initramfs" {
linux /boot/bzImage rdinit=/init console=tty0
initrd /boot/initramfs.cpio.gz
}
Generate Configuration
# Auto-generate config
grub-mkconfig -o /boot/grub/grub.cfg
# Update GRUB after changes
update-grub # Debian/Ubuntu
grub2-mkconfig -o /boot/grub2/grub.cfg # RHEL/CentOS
GRUB Modules
# List available modules
ls /usr/lib/grub/i386-pc/
# Common modules
insmod part_msdos # MBR partitions
insmod part_gpt # GPT partitions
insmod ext2 # ext2/3/4 filesystem
insmod iso9660 # ISO filesystem
insmod loopback # Loopback devices
Boot Parameters
# In grub.cfg
linux /boot/vmlinuz \
root=/dev/sda1 \
rootwait \
console=tty0 \
console=ttyS0,115200 \
init=/sbin/init
GRUB Rescue
# At GRUB rescue prompt
set root=(hd0,1)
set prefix=(hd0,1)/boot/grub
insmod normal
normal
Create Bootable USB
# Install GRUB to USB drive
grub-install --target=i386-pc --boot-directory=/mnt/usb/boot /dev/sdb