When working with CentOS 6 systems, you'll notice the default kernel boot parameters include rhgb
(Red Hat Graphical Boot) and quiet
, which suppress boot messages. For server environments and automated deployments, we often need to remove these for better visibility into the boot process.
Unlike Debian-based systems that use /etc/default/grub
, CentOS 6 handles kernel parameters differently. The key files involved are:
/boot/grub/grub.conf
/etc/grub.conf (symlink to /boot/grub/grub.conf)
/etc/sysconfig/grub
Here's a robust script to modify parameters for all current and future kernels:
#!/bin/bash
# Backup original configuration
cp /boot/grub/grub.conf /boot/grub/grub.conf.bak
# Remove rhgb and quiet parameters
sed -i 's/\brhgb\b//g; s/\bquiet\b//g' /boot/grub/grub.conf
# Ensure new kernels inherit these settings
echo 'GRUB_CMDLINE_LINUX=""' > /etc/sysconfig/grub
# Rebuild grub configuration
/sbin/grub-mkconfig -o /boot/grub/grub.conf
The key to making changes persist across kernel updates lies in the /etc/sysconfig/grub
file. New kernels installed via yum will inherit settings from this file when generating their boot entries.
After running the script, verify the changes:
grep -E 'kernel|initrd' /boot/grub/grub.conf
You should see kernel lines without rhgb
or quiet
parameters. For a complete test, reboot the system and observe the boot messages.
If you're working with newer CentOS versions that include grubby
, you can use:
grubby --update-kernel=ALL --remove-args="rhgb quiet"
When implementing this in automated deployments:
- Always create backups before modifying boot configurations
- Include verification steps in your scripts
- Handle cases where files might be symlinks
In CentOS 6, the bootloader configuration differs significantly from Debian-based systems. Unlike Ubuntu's /etc/default/grub
approach, CentOS stores kernel parameters in /boot/grub/grub.conf
(or menu.lst
for legacy systems). The challenge is modifying this configuration programmatically for both current and future kernels.
Here's a script that permanently removes rhgb
and quiet
parameters while maintaining future compatibility:
#!/bin/bash
# Backup original grub.conf
cp /boot/grub/grub.conf /boot/grub/grub.conf.bak
# Remove rhgb and quiet from all kernel entries
sed -i 's/\brhgb\b//g; s/\bquiet\b//g' /boot/grub/grub.conf
# Create a persistent configuration template
if [ ! -f /etc/grub.conf.template ]; then
cp /boot/grub/grub.conf /etc/grub.conf.template
fi
# Install script to maintain changes during kernel updates
cat << 'EOF' > /etc/kernel/postinst.d/99-update-grub
#!/bin/sh
if [ -f /etc/grub.conf.template ]; then
cp /etc/grub.conf.template /boot/grub/grub.conf
for kernel in /boot/vmlinuz-*; do
version=${kernel#*-}
if ! grep -q "initrd /boot/initrd-${version}" /boot/grub/grub.conf; then
sed -i "/^title.*${version}/a \ \ \ \ initrd /boot/initrd-${version}" /boot/grub/grub.conf
fi
done
fi
EOF
chmod +x /etc/kernel/postinst.d/99-update-grub
The above solution creates a post-installation hook that maintains your configuration. For systems using GRUB2 (which CentOS 6 doesn't by default), you would need a different approach:
# For GRUB2 systems (e.g., CentOS 7+)
grubby --update-kernel=ALL --remove-args="rhgb quiet"
After implementation, verify your changes by:
grep -E 'kernel|initrd' /boot/grub/grub.conf
cat /proc/cmdline
Reboot and check the kernel command line parameters are indeed removed.
While not directly related to boot parameters, some settings can be adjusted via sysctl for runtime configuration:
# Example of persistent sysctl changes
echo "kernel.printk = 4 4 1 7" >> /etc/sysctl.conf
sysctl -p