在将VMware虚拟机导入Oracle Cloud时,为了debug需要在虚拟机上开启串口。
This is achieved by adding the following line co:2345:respawn:/sbin/agetty ttyS0 115200 vt100
to the /etc/inittab
file
# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6
co:2345:respawn:/sbin/agetty ttyS0 115200 vt100
After this edit is made, run the following command:
# init q
To start agetty on a serial port that is not the primary console, create a new /etc/init/serial-ttyS0.conf
file with the following contents:
start on stopped rc RUNLEVEL=[2345] stop on runlevel [S016] respawn exec /sbin/agetty /dev/ttyS0 115200 vt100-nav
To check the status of the serial console, use the initctl command to query the init daemon's jobs:
[root@localhost ~]# initctl list | grep serial
serial (ttyS0) start/running, process 1254
Add, or update if already present, the following lines to /etc/default/grub
:
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"
GRUB_TERMINAL="console serial"
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"
Rebuild the /boot/grub2/grub.cfg
file by running the grub2-mkconfig -o
command as follows:
~]# grub2-mkconfig -o /boot/grub2/grub.cfg
~]# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
Use the grub2-env command to modify the boot parameters persistently.
# grub2-editenv - list | grep kernelopts
kernelopts=root=/dev/mapper/rhel-root ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap
Copy the kernelopts line above completely.
Set the new kernel options by pasting the original options and appending the new ones like so:
# grub2-editenv - set "kernelopts=root=/dev/mapper/rhel-root ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap console=ttyS0,115200 console=tty0"
Check to see if the parameters were set properly:
# grub2-editenv - list | grep kernelopts
kernelopts=root=/dev/mapper/rhel-root ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap console=ttyS0,115200 console=tty0
Reboot
Share on Twitter Share on Facebook
Comments
There are currently no comments
New Comment