Question
How to save the boot messages, console, and error log of a Linux VM to file on a virtualization host where the VM is running?
Answer
To make it possible to monitor the VMs system logs from the virtualization host, we need to make two changes. One should be made inside the VM — enable debug and redirect it to the serial line. The second is made on virsh — enable serial port and redirect data to a file.
Example:
1. Edit the bootloader inside the VM
# vi /etc/default/grub
Modify GRUB_CMDLINE_LINUX and replace ‘rhgb quiet’ to ‘debug console=ttyS0,115200 console=tty’ (consult with the Guest OS vendor documentation if needed)
And commit changes
# grub2-mkconfig -o /boot/grub2/grub.cfg
2. Stop VM
# prlctl stop (VM_NAME)
3. Specify a log file
# prlctl set (VM_NAME) --device-add serial --output /var/log/vmdebug_(VM_NAME).log
4. Start the VM and observe the output
# prlctl start (VM_NAME) # tail -f /var/log/vmdebug_(VM_NAME).log