Skip to main content
SysAdmin Shell Scripting Essentials

Install tvservice on Raspberry Pi: Commands, Errors, and

install tvservice is the process of making the tvservice utility available on a Raspberry Pi running Raspbian or Raspberry Pi OS, enabling HDMI display control via the VideoCore GPU driver.

sudo apt update && sudo apt install raspberrypi-utils -y

tvservice is part of the raspberrypi-utils package. On older or legacy systems, libraspberrypi-bin may be used. The binary is located at /opt/vc/bin/tvservice.

Common Errors

  • Error: bash: tvservice: command not found
    Cause: The raspberrypi-utils package is not installed or the binary is not in PATH. The full path is /opt/vc/bin/tvservice.
    Fix: Install the package as above or add /opt/vc/bin to $PATH.
  • Error: tvservice is not supported when using the vc4-kms-v3d driver
    Cause: You are running the modern KMS driver. tvservice cannot work because the legacy VideoCore API is not exposed.
    Fix: Switch to legacy firmware KMS (Bullseye only) or use vcgencmd / modetest alternatives.
  • Error: Cannot open /dev/fb0: No such file or directory
    Cause: Framebuffer device missing under KMS. tvservice may attempt to use it.
    Fix: Ensure you have a console framebuffer (e.g., vc4-fkms-v3d provides /dev/fb0). On KMS, framebuffer is emulated through DRM.
  • Error: Failed to allocate EDID buffer
    Cause: HDMI monitor not connected or EDID read failure.
    Fix: Check physical connection. Use tvservice -d edid.dat to dump EDID and decode with edid-decode.
  • Error: tvservice: error while loading shared libraries: libvcos.so: cannot open shared object file: No such file or directory
    Cause: Userland libraries not in ldconfig path.
    Fix: Run sudo ldconfig -v after building userland, or install the raspberrypi-utils package which includes libraries.
See also  Export-CSV PowerShell: Syntax, Flags, Exit Codes, Troubleshooting

Why tvservice Is Missing

tvservice is part of the raspberrypi-utils package, which contains VideoCore utilities for the legacy proprietary driver (vc4-fkms-v3d or firmware KMS). Starting with Raspberry Pi OS Bullseye (Debian 11), the default graphics driver switched to the open-source vc4-kms-v3d (Kernel Modesetting). Under this driver, tvservice is not functional and the package may not be installed.

RPi OS Version Default Graphics Driver tvservice Available? Reason
Buster (10) and earlier Firmware KMS / vc4-fkms-v3d Yes (built-in) Legacy driver exposes VideoCore API
Bullseye (11) Lite vc4-kms-v3d Not installed by default Driver does not support tvservice
Bookworm (12) Lite vc4-kms-v3d Not present in repos Driver deprecates VideoCore-specific tools
Bullseye Desktop vc4-kms-v3d (with xserver-xorg-video-fbdev) May be absent Desktop uses KMS, no tvservice needed

Tested on Raspberry Pi OS Bullseye Lite (kernel 5.15) with vc4-kms-v3d driver; tvservice not functional.

How to Install tvservice

Installing tvservice requires either using the legacy driver (Bullseye only) or installing the package from a repository that provides it. Follow these steps according to your OS version.

  1. Check Current OS Version and Driver

    # Determine RPi OS release
    cat /etc/os-release | grep VERSION_ID
    
    # Check active graphics driver
    ls /dev/dri/
    # If /dev/dri/card0 exists, KMS is active; tvservice may not work.

    If you are using LibreELEC, Pi-Star, or other non-Raspbian images, skip to the Pi-Star method below.

  2. For Raspberry Pi OS Bullseye (Legacy Driver)

    tvservice can be made to work by forcing the legacy firmware KMS driver. This disables KMS advantages but restores VideoCore access.

    # Install the package (may fail if not in repos)
    sudo apt update
    sudo apt install libraspberrypi-bin -y
    
    # Ensure the legacy driver is loaded
    # Add to /boot/config.txt:
    echo "dtoverlay=vc4-fkms-v3d" | sudo tee -a /boot/config.txt
    sudo reboot
    
    # After reboot, test tvservice
    /opt/vc/bin/tvservice -s

    If the package is missing from repositories (common in newer images), download the .deb from an older Buster install or compile from source. See the Pi-Star method.

  3. For Pi-Star 4.x / 3.x Users

    Pi-Star images often include tvservice as part of the /opt/vc/bin directory. If missing, install via source:

    # Enable write access (if in read-only mode)
    rpi-rw
    
    # Clone the userland repository and build
    sudo apt update
    sudo apt install cmake git -y
    git clone https://github.com/raspberrypi/userland
    cd userland
    ./buildme
    sudo ldconfig -v
    
    # The binary will be at /opt/vc/bin/tvservice
    /opt/vc/bin/tvservice -s

    Reference: This method is documented in the January 2019 K2IE blog post and works on Pi-Star 4.0 RC+. Ensure /opt/vc/lib is in your linker path.

  4. Quick Reference Table

    Action CLI Command Key Flag Description
    Install package sudo apt install raspberrypi-utils N/A Installs tvservice on systems with legacy support
    Check status /opt/vc/bin/tvservice -s -s Display current HDMI status
    Turn off HDMI sudo /opt/vc/bin/tvservice -o -o Power down HDMI output
    Turn on HDMI sudo /opt/vc/bin/tvservice -p -p Preferred mode restore
    List modes tvservice -m DMT -m GROUP List supported display modes (DMT/CEA)
  5. For Raspberry Pi OS Bookworm and Later

    tvservice is intentionally unsupported under KMS. If you must use it, downgrade to Bullseye (legacy driver) or use alternative tools: vcgencmd for power management, and modetest (from libdrm) for display enumeration. No direct installation method exists for Bookworm without breaking KMS.

    # Alternative: switch off display via KMS (requires root)
    echo "off" | sudo tee /sys/class/drm/card0-HDMI-A-1/status
    # Or use vcgencmd for basic power control
    vcgencmd display_power 0

Frequently Asked Questions

What is the difference between ‘sudo apt install tvservice’ and ‘sudo apt install raspberrypi-utils’?

Answer: ‘sudo apt install tvservice’ fails because tvservice is not a package; ‘sudo apt install raspberrypi-utils’ correctly installs the tvservice binary along with other utilities. tvservice is included in the raspberrypi-utils package on Raspberry Pi OS. Attempting to install a package named “tvservice” will return E: Unable to locate package tvservice. Use the correct package name:

sudo apt update && sudo apt install raspberrypi-utils -y

When should I use the ‘–no-install-recommends’ flag during installation of tvservice?

Answer: Use ‘–no-install-recommends’ in resource-constrained or containerized environments to avoid pulling non-essential dependencies for raspberrypi-utils. The flag reduces package size and install time. For example, on a minimal Raspberry Pi image:

sudo apt install --no-install-recommends raspberrypi-utils -y

This installs only the core utils (including tvservice) and skips documentation, debug tools, and optional firmware packages.

See also  PowerShell Echo to Console: Write-Output Syntax & Troubleshooting

How do I fix ‘E: Unable to locate package tvservice’ on Raspberry Pi OS?

Answer: Run ‘sudo apt update’ to refresh sources, then install the correct package: ‘sudo apt install raspberrypi-utils’. This error occurs when the package database is outdated or when using the wrong package name. Ensure the raspberrypi-sys-mods repository is enabled (default on Raspberry Pi OS). Steps:

sudo apt update
sudo apt install raspberrypi-utils -y

Verify installation with tvservice --version.

Does tvservice work on Ubuntu Server for Raspberry Pi or AWS EC2 instances?

Answer: tvservice works on Raspberry Pi OS (Debian-based) but not on standard Ubuntu Server or EC2 due to missing proprietary GPU firmware. On Ubuntu for Pi (Ubuntu Core or Server), the package raspberrypi-utils may be available but tvservice requires the VideoCore GPU driver and /dev/vchiq access, which are absent on EC2 or non-Raspberry Pi hardware. Use only on physical Raspberry Pi running Raspberry Pi OS.

What is the fastest way to install tvservice from a clean image or script?

Answer: Use a single apt command without further prompts: ‘sudo apt install -y raspberrypi-utils’ after ensuring sources are updated. For headless automation, combine update and install in one line, suppressing unnecessary output:

export DEBIAN_FRONTEND=noninteractive
sudo apt update -qq && sudo apt install -y -qq raspberrypi-utils
tvservice -v # Verify

This reduces execution time to under 10 seconds on a modern Raspberry Pi with a fast SD card.