Trying to fix tty resolution on nvidia driver via KMS

Hi, I ran into the fact that in tty and during boot I have a problem with the screen resolution (apparently it is 1024x768), however on Fedora I did not have such problems (I also used proprietary drivers), I tried to find out how Fedora defines the screen resolution. I was told that Kernel mode setting (KMS) is being used.

I followed the archwiki and I tried late KMS start , specified nvidia-drm.modeset=1 kernel parameter, but it did not help me.
Then I tried Early KMS start, it also did not help me, but it fixed plymouth , now it is displayed correctly during boot, but if you press esc it goes back to the incorrect resolution after a couple of seconds and vice versa to normal if you return to plymouth screen.

What can be done to fix the resolution in the tty and at boot time?

inxi -v7azy
System:
  Kernel: 5.17.0-1-MANJARO arch: x86_64 bits: 64 compiler: gcc v: 11.2.0
    parameters: BOOT_IMAGE=/boot/vmlinuz-5.17-x86_64
    root=UUID=44bb182f-f8d0-4fcc-99c0-ed01074ebcf1 rw quiet splash apparmor=1
    security=apparmor udev.log_priority=3 nvidia-drm.modeset=1
  Desktop: GNOME v: 41.4 tk: GTK v: 3.24.33 wm: gnome-shell dm: GDM v: 41.3
    Distro: Manjaro Linux base: Arch Linux
Machine:
  Type: Desktop System: ASUS product: All Series v: N/A
    serial: <superuser required>
  Mobo: ASUSTeK model: B85M-G v: Rev X.0x serial: <superuser required>
    UEFI: American Megatrends v: 2501 date: 07/22/2015
Memory:
  RAM: total: 7.7 GiB used: 2.43 GiB (31.6%)
  RAM Report:
    permissions: Unable to run dmidecode. Root privileges required.
CPU:
  Info: model: Intel Celeron G1840 bits: 64 type: MCP arch: Haswell family: 6
    model-id: 0x3C (60) stepping: 3 microcode: 0x28
  Topology: cpus: 1x cores: 2 smt: <unsupported> cache: L1: 128 KiB
    desc: d-2x32 KiB; i-2x32 KiB L2: 512 KiB desc: 2x256 KiB L3: 2 MiB
    desc: 1x2 MiB
  Speed (MHz): avg: 2465 high: 2605 min/max: 800/2800 scaling:
    driver: intel_cpufreq governor: schedutil cores: 1: 2605 2: 2325
    bogomips: 11178
  Flags: abm acpi aperfmperf apic arat arch_perfmon bts clflush cmov
    constant_tsc cpuid cpuid_fault cx16 cx8 de ds_cpl dtes64 dtherm dts epb ept
    ept_ad erms est flexpriority flush_l1d fpu fsgsbase fxsr ht ibpb ibrs
    invpcid invpcid_single lahf_lm lm mca mce md_clear mmx monitor movbe msr
    mtrr nonstop_tsc nopl nx pae pat pbe pcid pclmulqdq pdcm pdpe1gb pebs pge
    pln pni popcnt pse pse36 pti pts rdrand rdtscp rep_good sdbg sep ss ssbd
    sse sse2 sse4_1 sse4_2 ssse3 stibp syscall tm tm2 tpr_shadow tsc
    tsc_adjust tsc_deadline_timer vme vmx vnmi vpid xsave xsaveopt xtopology
    xtpr
  Vulnerabilities:
  Type: itlb_multihit status: KVM: VMX disabled
  Type: l1tf
    mitigation: PTE Inversion; VMX: conditional cache flushes, SMT disabled
  Type: mds mitigation: Clear CPU buffers; SMT disabled
  Type: meltdown mitigation: PTI
  Type: spec_store_bypass
    mitigation: Speculative Store Bypass disabled via prctl
  Type: spectre_v1
    mitigation: usercopy/swapgs barriers and __user pointer sanitization
  Type: spectre_v2 mitigation: Full generic retpoline, IBPB: conditional,
    IBRS_FW, STIBP: disabled, RSB filling
  Type: srbds mitigation: Microcode
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: NVIDIA GF108 [GeForce GT 730] driver: nvidia v: 390.147
    alternate: nouveau,nvidia_drm pcie: gen: 2 speed: 5 GT/s lanes: 16 ports:
    active: none off: VGA-1 empty: DVI-I-1,HDMI-A-1 bus-ID: 01:00.0
    chip-ID: 10de:0f02 class-ID: 0300
  Display: x11 server: X.org v: 1.21.1.3 with: Xwayland v: 22.1.0
    compositor: gnome-shell driver: X: loaded: nvidia gpu: nvidia display-ID: :1
    screens: 1
  Screen-1: 0 s-res: 1600x900 s-size: <missing: xdpyinfo>
  Monitor-1: VGA-1 mapped: VGA-0 note: disabled model: LG (GoldStar) W2043
    serial: <filter> built: 2009 res: 1600x900 hz: 60 dpi: 92 gamma: 1.2
    size: 443x249mm (17.44x9.8") diag: 515mm (20.3") ratio: 16:9 modes:
    max: 1600x900 min: 640x480
  OpenGL: renderer: GeForce GT 730/PCIe/SSE2 v: 4.6.0 NVIDIA 390.147
    direct render: Yes
mhwd -li
Installed PCI configs:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
    video-nvidia-390xx            2021.12.18               false            PCI
           video-linux            2018.05.04                true            PCI


Warning: No installed USB configs!
/etc/mkinitcpio.conf
# vim:set ft=sh
# MODULES
# The following modules are loaded before any boot hooks are
# run.  Advanced users may wish to specify all system modules
# in this array.  For instance:
#     MODULES=(piix ide_disk reiserfs)
MODULES=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)

# BINARIES
# This setting includes any additional binaries a given user may
# wish into the CPIO image.  This is run last, so it may be used to
# override the actual binaries included by a given hook
# BINARIES are dependency parsed, so you may safely ignore libraries
BINARIES=()

# FILES
# This setting is similar to BINARIES above, however, files are added
# as-is and are not parsed in any way.  This is useful for config files.
FILES=""

# HOOKS
# This is the most important setting in this file.  The HOOKS control the
# modules and scripts added to the image, and what happens at boot time.
# Order is important, and it is recommended that you do not change the
# order in which HOOKS are added.  Run 'mkinitcpio -H <hook name>' for
# help on a given hook.
# 'base' is _required_ unless you know precisely what you are doing.
# 'udev' is _required_ in order to automatically load modules
# 'filesystems' is _required_ unless you specify your fs modules in MODULES
# Examples:
##   This setup specifies all modules in the MODULES setting above.
##   No raid, lvm2, or encrypted root is needed.
#    HOOKS=(base)
#
##   This setup will autodetect all modules for your system and should
##   work as a sane default
#    HOOKS=(base udev autodetect block filesystems)
#
##   This setup will generate a 'full' image which supports most systems.
##   No autodetection is done.
#    HOOKS=(base udev block filesystems)
#
##   This setup assembles a pata mdadm array with an encrypted root FS.
##   Note: See 'mkinitcpio -H mdadm' for more information on raid devices.
#    HOOKS=(base udev block mdadm encrypt filesystems)
#
##   This setup loads an lvm2 volume group on a usb device.
#    HOOKS=(base udev block lvm2 filesystems)
#
##   NOTE: If you have /usr on a separate partition, you MUST include the
#    usr, fsck and shutdown hooks.
HOOKS="base udev autodetect modconf block keyboard keymap consolefont plymouth filesystems fsck"

# COMPRESSION
# Use this to compress the initramfs image. By default, gzip compression
# is used. Use 'cat' to create an uncompressed image.
#COMPRESSION="gzip"
#COMPRESSION="bzip2"
#COMPRESSION="lzma"
#COMPRESSION="xz"
#COMPRESSION="lzop"
#COMPRESSION="lz4"
#COMPRESSION="zstd"

# COMPRESSION_OPTIONS
# Additional options for the compressor
#COMPRESSION_OPTIONS=()

/etc/default/grub
GRUB_DEFAULT=saved
GRUB_TIMEOUT=15
GRUB_TIMEOUT_STYLE=hidden
GRUB_DISTRIBUTOR="Manjaro"
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash apparmor=1 security=apparmor udev.log_priority=3 nvidia-drm.modeset=1"
GRUB_CMDLINE_LINUX=""

# If you want to enable the save default function, uncomment the following
# line, and set GRUB_DEFAULT to saved.
GRUB_SAVEDEFAULT=true

# Preload both GPT and MBR modules so that they are not missed
GRUB_PRELOAD_MODULES="part_gpt part_msdos"

# Uncomment to enable booting from LUKS encrypted devices
#GRUB_ENABLE_CRYPTODISK=y

# Uncomment to use basic console
GRUB_TERMINAL_INPUT=console

# Uncomment to disable graphical terminal
#GRUB_TERMINAL_OUTPUT=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command 'videoinfo'
GRUB_GFXMODE=1600x900

# Uncomment to allow the kernel use the same resolution used by grub
GRUB_GFXPAYLOAD_LINUX=keep

# Uncomment if you want GRUB to pass to the Linux kernel the old parameter
# format "root=/dev/xxx" instead of "root=/dev/disk/by-uuid/xxx"
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
GRUB_DISABLE_RECOVERY=true

# Uncomment this option to enable os-prober execution in the grub-mkconfig command
GRUB_DISABLE_OS_PROBER=false

# Uncomment and set to the desired menu colors.  Used by normal and wallpaper
# modes only.  Entries specified as foreground/background.
GRUB_COLOR_NORMAL="light-gray/black"
GRUB_COLOR_HIGHLIGHT="green/black"

# Uncomment one of them for the gfx desired, a image background or a gfxtheme
#GRUB_BACKGROUND="/usr/share/grub/background.png"

# Uncomment to get a beep at GRUB start
#GRUB_INIT_TUNE="480 440 1"

# Uncomment to ensure that the root filesystem is mounted read-only so that
# systemd-fsck can run the check automatically. We use 'fsck' by default, which
# needs 'rw' as boot parameter, to avoid delay in boot-time. 'fsck' needs to be
# removed from 'mkinitcpio.conf' to make 'systemd-fsck' work.
# See also Arch-Wiki: https://wiki.archlinux.org/index.php/Fsck#Boot_time_checking
#GRUB_ROOT_FS_RO=true
GRUB_THEME="/usr/share/grub/themes/Tela/theme.txt"

You can safely uninstall that driver. Eventually reinstall the video-nvidia-390xx

Instead of this:

i would use this:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash apparmor=1 security=apparmor udev.log_priority=3"
GRUB_CMDLINE_LINUX="nvidia-drm.modeset=1"

maybe not “required”, just a personal preference.

I uninstalled video-linux and reinstalled video-nvidia-390xx , even moved parameter to GRUB_CMDLINE_LINUX.

Unfortunately this didn’t help me.

Hi,
first of all, you have to check, which resolution your graphic card is supporting during boot and on TTY.

Therefore you have to get into GRUB Commandline during boot.

During boot of my computer with Manjaro, I have to press “C” in GRUB boot menue.

For activating of GRUB boot menue you probably have to set following in /etc/default/grub:

GRUB_TIMEOUT=5
GRUB_TIMEOUT_STYLE=menu

For activating this change, you have to rebuild the GRUB configuration with

sudo grub-mkconfig -o /boot/grub/grub.cfg

and reboot afterwards.

Now after reboot the GRUB menu should appear, where you have to press “C” for activating of GRUB Commandline.

In GRUB Commandline with command videoinfo you will get information about supported videomodes of your graphic card in terminal mode.

Take the information about supported video modes and add them in that order, which is comfortable for you again in /etc/default/grub:

GRUB_GFXMODE="1600x1200x32;1280x1024x32;1024x768x32;800x600x32;auto"

For activating this change, you have to rebuild the GRUB configuration again with

sudo grub-mkconfig -o /boot/grub/grub.cfg

and reboot afterwards.

Hopefully after boot the resolution during boot and on TTY has been changed to your new settings.

I have already tried this option, of course, it did not help me, moreover, in videoinfo my maximum resolution is 1280x1024x32.

That’s why I’m trying to use KMS.

Did you already tested GRUB_GFXMODE set to

GRUB_GFXMODE="1280x1024x32"

As I saw in your GRUB configuration file, it seems that you have an invalid value in GRUB_GFXMODE set for your graphic card:

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command 'videoinfo'
GRUB_GFXMODE=1600x900

When I set GRUB_GFXMODE to an invalid value for my graphic card, it is using a resolution of 1024x768 in GRUB menu, which afterwards leads to 128 columns and 48 lines in TTY shell which looks not very good on my monitor, too.

With supported resolution of 1600x1200 reported by videoinfo afterwards TTY has better looking 200 columns and 75 lines in shell.

According resolution information provided by my monitor, in both cases the used resolution for TTY has been set to monitor maximum of 2560x1440.
I didn’t configured anything for maximum monitor resolution off 2560x1440 in TTY, so I think this has been changed automatically during boot by NVIDIA driver itself.

I would suggest to do following for another test:

  • remove all changes which you made for testing of KMS
  • set valid video mode GRUB_GFXMODE="1280x1024x32" in /etc/default/grub
  • install NVIDIA proprietary driver ** linux5??-nvidia-470xx** fitting to your kernel which should support your card: NVIDIA Linux x64 (AMD64/EM64T) Display Driver
  • if not automatically done during installation of NVIDIA installation, refresh grub configuration with sudo grub-mkconfig -o /boot/grub/grub.cfg

Otherwise, there are also additional information available in Arch wiki which probably could help you:

Yes, without KMS 1280x1024x32 works
But that’s not what I want as it’s still not 1600x900(yes, there is no such screen resolution in videoinfo, that’s why I’m trying to use KMS) and because of that I have to wait a few seconds to switch to tty… Unlike fedora, where in tty I really have a resolution of 1600x900(and also during system boot) and I switch to it instantly, moreover, night light even works

This is not entirely true, specifically my version of gt730 (fermi) only supports 390 driver.

Yes, as I wrote, I used archwiki to enable KMS.