Skip to content

Instantly share code, notes, and snippets.

@goffinet
Last active June 17, 2022 03:51
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save goffinet/ea0df57d760293a5b861e63253dfeea4 to your computer and use it in GitHub Desktop.
Save goffinet/ea0df57d760293a5b861e63253dfeea4 to your computer and use it in GitHub Desktop.
Centos7 serial console enabled by grub /etc/default/grub, "grub-mkconfig -o /boot/grub/grub.cfg"
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
cat << EOF > /etc/default/grub
# grub-mkconfig -o /boot/grub/grub.cfg
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=false
GRUB_TERMINAL="serial console"
GRUB_SERIAL_COMMAND="serial --speed=115200"
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap console=ttyS0,115200n8"
GRUB_DISABLE_RECOVERY="false"
EOF
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment