第一步:
echo "S0:12345:respawn:/sbin/agetty/ ttyS0 115200" >> /etc/inittab
第二步:
echo "ttyS0" >> /etc/securetty
第三步:
在/etc/grub.conf文件中为内核添加参数:
console=ttyS0
cat /etc/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/mapper/vg_ameim7-lv_root
# initrd /initrd-[generic-]version.img
#boot=/dev/vda
default=0
timeout=5
splashp_w_picpath=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux (2.6.32-358.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=/dev/mapper/vg_ameim7-lv_root rd_NO_LUKS rd_LVM_LV=vg_ameim7/lv_swap rd_NO_MD rd_LVM_LV=vg_ameim7/lv_root crashkernel=128M LANG=zh_CN.UTF-8 KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet console=ttyS0
initrd /initramfs-2.6.32-358.el6.x86_64.img
如果是grub2系统,请修改
vim /etc/default/grub文件,
GRUB_CMDLINE_LINUX=" console=tty0 console=ttyS0",
然后update-grub
即执行如下命令,然后重启机器
grub2-mkconfig -o /boot/grub2/grub.cfg
转载于:https://blog.51cto.com/6226001001/1772133