Skip to content

Instantly share code, notes, and snippets.

@BoyanXu
Forked from yuna0x0/pve_xtermjs_for_ubuntu_vm.txt
Last active September 10, 2023 04:24
Show Gist options
  • Save BoyanXu/3dc2315c70900e6b066cc28376181987 to your computer and use it in GitHub Desktop.
Save BoyanXu/3dc2315c70900e6b066cc28376181987 to your computer and use it in GitHub Desktop.
Proxmox VE xterm.js (Serial Terminal) for Arch Linux VM
1. Add a virtual serial port to the VM using PVE Web GUI and restart the VM
2. Config grub
When using GRUB with a generated grub.cfg, edit /etc/default/grub and enable serial input and output support:
/etc/default/grub
...
GRUB_TERMINAL_INPUT="console serial"
...
GRUB_TERMINAL_OUTPUT="gfxterm serial"
...
Next add the GRUB_SERIAL_COMMAND variable and set the options for the serial connection. For COM1 (/dev/ttyS0) with baud rate of 115200 bit/s:
/etc/default/grub
...
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200"
3. Enable and start the virtual serial port on VM, change tty number as needed (Reference:
$ sudo systemctl enable serial-getty@ttyS0.service
$ sudo systemctl start serial-getty@ttyS0.service
4. Done! You can now select xterm.js in the PVE Web GUI
@BoyanXu
Copy link
Author

BoyanXu commented Sep 10, 2023

To enable auto-reszie:

  1. Install xterm
  2. Add following setting to .bashrc
alias rsz='resize >/dev/null'
if [ $(tty) == '/dev/ttyS0' ]; then
trap rsz DEBUG
export TERM=xterm
fi

For fish shell:

function rsz
    resize > /dev/null
end

if test (tty) = "/dev/ttyS0"
    function resize_on_command
        rsz
    end

    # Set up an event handler to run before every command execution
    functions -e fish_preexec # Remove if it already exists
    function fish_preexec --on-event fish_preexec
        resize_on_command
    end

    set -gx TERM xterm
end
  1. Use command resize to manually resize serial window size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment