On Debian Linux and Debian FreeBSD, the design is for the X server and the kernel virtual terminals to share one set of configuration information. The
console-setup package provides tools and startup scripts that take the keyboard/font configuration of the X server, convert it, and use it to configure the kernel virtual terminals.
console-setup service invokes the
setupcon --save command, which generates scripts in
/etc/console-setup containing the converted keyboard and font setup instructions, which are run against the kernel virtual terminal devices by udev rules. The keyboard map is converted from XKB to
loadkeys format by
ckbcomp, and the generated script invoked from the udev rule runs
So on Debian Linux and Debian FreeBSD you need to ensure that your
XKBOPTIONS variables are properly set in
/etc/default/keyboard. In your case in particular you need to ensure that the
XKBOPTIONS variable has
caps:swapescape. Then you need to ensure that you have the
console-setup package properly installed.
On systemd operating systems, things are somewhat less integrated than on Debian. There's a configuration file named
/etc/vconsole.conf and a service named
systemd-vconsole-setup.service that processes it at system bootstrap (in response to a udev rule announcing the existence of the kernel virtual terminal subsystem). But this isn't joined up with the X server configuration at all.
vconsole.conf file has a
KEYMAP setting denoting the keyboard map that is passed to
loadkeys, which again one does not need to explicitly run oneself. But it's left entirely up to you to create a (customized) keyboard map that swaps Caps Lock and Escape and put it where
loadkeys can find it.
To get more joined up settings, one has to involve another two services,
systemd-localed and the Desktop Bus. One runs, say,
localectl set-x11-keymap pl pc105 "" "caps:swapescape"
and the locale D-BUS service goes and rewrites
with its best guess as to the nearest equivalent
map for the kernel virtual terminal. This nearest equivalent may not be exactly
equivalent, though, and you may find it just outright ignoring options and suchlike.
Of course, you could always alternatively use Debian's
ckbcomp by hand to directly convert an XKB keyboard map. ☺