How to get the display settings right on Raspberry Pi

by Remy Pereira on 27th August 2014

When you connect your raspberry pi to your TV or monitor via HDMI, Pi attempts to guess the resolution, hdmi mode, overscan values etc., that best fits your display. But it might get this wrong and you may come across various problems with display such as :

  • Picture doesn't fill the entire size of the screen and you can see black borders on left, right, top, bottom or all sides.
  • Picture spills off the size of the screen and some parts of the picture are outside the screen.
  • The resolution and HDMI modes are not the best values for your screen

This article explains how to set the correct display resolution on Raspberry Pi.

Picture doesn't fill the entire size of the screen and you can see black borders on left, right, top, bottom or all sides.

This is possibly because Pi is adding overscan to the signal. Modern TVs and monitors don't need overscan and hence disabling overscan altogether can make the Pi graphics fill the entire screen.

Check the settings on the TV or monitor first. Eg: On a Sony Bravia TV these settings are under Screen Format (Normal, Zoom, Wide Zoom etc.,). If this doesn't remove the black borders, then try disabling overscan on the Pi. This can be done by setting the parameter disable_overscan to 1 in /boot/config.txt and commenting other parameters related to overscan.

  1. Take a backup of the file /boot/config.txt
    sudo cp /boot/config.txt /boot/config.txt.backup
  2. Open config.txt for editing
    sudo nano /boot/config.txt
  3. Uncomment the #disable_overscan=1 (Remove the #)
  4. Comment all other overscan parameters
  5. Save and exit. ( CTRL+X followed by Y to save)
  6. Reboot
    sudo reboot

On most monitors/TVs this would remove the black borders and make the desktop fill the whole screen. However if your display stil has some overscan you may need to keep the overscan parameters in config.txt file, but adjust the values:


More negative values means less black borders. Centre the display by trying different values for feft, right, top, bottom.

Picture spills off the size of the screen and some parts of the picture are outside the screen

This means you need positive overscan values.


The resolution and HDMI modes are not the best values for your screen

Try to change monitor settings from Preferences → Monitor settings

However if it says "Unable to get monitor information", find out the modes supported by your monitor by running tvservice command and set the correct mode in /boot/config.txt as below

  1. Run the tvservice command to output the result to a file.
    $ tvservice -d edid.dat
    Written 256 bytes to edid.dat
  2. Pipe the file to edidparser to generate a readable text file.
    $ edidparser edid.dat > edid.txt
  3. Grep the desired resolution to check if it is available. For example if you are checking for 1080p resolution
    $ cat edid.txt | grep 1080p
      HDMI:EDID found preferred CEA detail timing format: 1920x1080p @ 60 Hz (16)
      HDMI:EDID found CEA detail timing format: 1920x1080p @ 50 Hz (31)
      HDMI:EDID found CEA format: code 31, 1920x1080p @ 50Hz 
      HDMI:EDID found CEA format: code 16, 1920x1080p @ 60Hz 
      HDMI:EDID found CEA format: code 32, 1920x1080p @ 24Hz 
      HDMI:EDID found CEA format: code 34, 1920x1080p @ 30Hz 
      HDMI:EDID best score mode is now CEA (16) 1920x1080p @ 60 Hz with pixel clock 148 MHz (score 5398248)
      HDMI:EDID CEA mode (31) 1920x1080p @ 50 Hz with pixel clock 148 MHz has a score of 4232360
      HDMI:EDID CEA mode (32) 1920x1080p @ 24 Hz with pixel clock 74 MHz has a score of 124532
      HDMI:EDID CEA mode (34) 1920x1080p @ 30 Hz with pixel clock 74 MHz has a score of 149416
      HDMI:EDID preferred mode remained as CEA (16) 1920x1080p @ 60 Hz with pixel clock 148 MHz
      HDMI:EDID best score mode is now CEA (16) 1920x1080p @ 60 Hz with pixel clock 148 MHz (score 5398248)

    "CEA" corresponds to hdmi_group=1
    "DMT" corresponds to hdmi_group=2
    The value inside () corresponds to hdmi_mode.

    From the above result:

  4. Take a backup of /boot/config.txt
     sudo cp /boot/config.txt /boot/config.txt.backup
  5. Edit /boot/config.txt
     sudo nano /boot/config.txt 
  6. Uncomment hdmi_group and hdmi_mode and set the right values
  7. Save and exit; Ctrl+X followed by Y to save
  8. Reboot
    $ sudo reboot 

Post a comment


oert | November 28, 2020 2:53 PM |

Ubuntu-on-Raspberry-Pi users: beware Ubuntu ignores config.txt if it is in /boot/; it instead looks for: /boot/firmware/config.txt Read /boot/firmware/README

Herbie | July 3, 2020 11:48 AM |

This is excellent .. but it helps to right-click on the desktop to access desktop preferences, and then select defaults for large, medium or small screens as appropriate. This finally got the whole image visible. In my case I had to use minus numbers to get the borders right.

Guybrush | March 24, 2020 8:38 PM |

Oh yeah, this is what I was looking for! Cheers, mate!

andy | January 31, 2020 7:20 PM |

thanks for the tip, helped me alot to find the best resolution. By the way, I have not tinckered with the config.txt file. Instead, I went directly to the pi config via UI and [Resolution...] chose the one recommended by the tvservice -d Thanks a ton

Eoin | July 21, 2019 10:02 PM |

Whenever i try to save it it says it cant open the file to write

nayan | April 20, 2019 12:29 PM |

i cant set resolution in Debian 2016 OS

Russ Locke | January 6, 2019 4:14 PM |

At the command line, sudo cp /boot/config.txt /boot/config.txt.backup returns the response :invalid command cp/boot/config.txt So now what?

Harch | March 23, 2019 12:48 PM |

You have to put space between /boot/config.txt and /boot/config.txt.backup Perhaps I'm wrong but I think this is your issue. This site maybe ain't optimise to let us know what commands to put. Don't know, I'm on mobile phone...

Janith Priyankara | October 7, 2018 9:12 AM |

if you use remote desktop like vnc viewer, go to ssh software,in my case putty, and type sudo raspi-config.Then raspi configuration window will appear. in there in Advanced options disable overscan. Change resolution if you like to.

Anthony | February 10, 2018 3:22 PM |

fantastic post, thank you so much for sharing these settings.

annonymous | October 17, 2017 12:30 PM |

i dont know where to put the coding so it didnt help

Maddelyn | January 27, 2018 1:47 PM |

try rebooting your pi this helped for me

Maddelyn | January 27, 2018 1:44 PM |

this didn't work anywhere on my pi its not working. so it definitely didn't work.

king | October 17, 2017 12:32 PM |

you need to edit the /boot/config.txt file

digwat | October 3, 2017 3:03 PM |

you watch too closley

Richard Ballard | August 17, 2017 7:02 AM |

A lot of information, but I am running my RPi on a 70" screen. Picture is beautiful but I would like to change the resolution to something smaller so I can see the type better! I am running Jessie. Any suggestions?

Anwar Shiekh | May 25, 2017 8:59 PM |

Found how to let the monitor sleep

Anwar Shiekh | May 24, 2017 7:22 AM |

But how does one get the Raspberry Pi to sleep the monitor (not just blank it); burns up a lot of electricity without this. 1W ~ $1 a year

Tyrell153 | April 3, 2017 11:55 AM |

Solution HERE >>> Don't Despair here is what you need to do. 1. sudo nano /boot/config.txt 2.# disable_overscan=1 (leave this) 3. overscan_left=0 (# -Remove) overscan_right=480 overscan_top=0 overscan_bottom=220 4. hdmi_mode=4 (# - remove and change to number 4) 5.framebuffer_width=800 (#-remove) framebuffer_height=480 Ok guys this should get you 90% of the way. You can tinker around

Andrew David Sprott | January 30, 2017 6:51 AM |

Thank you very much for that help. Now maybe you could sort out my broadband provider they are getting very annoying ;)

David | December 21, 2016 1:46 PM |

I cant get my Mame to play in 4:3 and i get this flashing effect on shadows.

Huub Knops | November 1, 2016 10:39 AM |

Great! Worked for me!

John Wiggins | May 9, 2016 10:22 AM |

Another tip, you can change the default console font with: sudo dpkg-reconfigure console-setup Then select utf-8, Guess optimal char set, Terminus Bold, thenot pick one to see if it is better. You can always retry if it isn't to your liking

Alvaro | May 9, 2016 10:22 AM |

Works for a 7'' monitor. Thank you very very much. Now I don't have black borders

Zaffre | April 8, 2016 9:14 AM |

Thank you Lukas. Simple and it works. I'm very new to this. :)

N/A | February 18, 2016 9:52 AM |

This solution worked for me, thank you.

Eike | January 14, 2016 11:55 PM |

Worked like a charm on my Samsung TV. Thanks!

Sander | December 18, 2015 9:53 AM |

(I'm using Raspbian Jessie) I had black borders around my screen. I followed the 6 steps, but it didn't work. Adding another step fixed it for me. After: Comment all other overscan parameters #overscan_left=10 #overscan_right=10 #overscan_top=15 #overscan_bottom=15 I also had to comment a line "disable_overscan=0" before saving the file. Located at line number 75 in my file.

Lee | December 8, 2015 9:30 AM |

Thanks, seems to stop the screen detection errors when booting ubuntu mate on the pi now after removing the overscan. Much appreciated!

Mark | November 27, 2015 12:29 PM |

If you have used NOOBS to run Raspbian you may find that there is a set of settings already at the bottom of the config.txt file. I missed those when uncommenting the above suggestions so it looked like nothing was being fixed.

modom | August 9, 2015 6:08 AM |

Worked for me, thanks.

Pascal | July 27, 2015 8:01 PM |

Thank you, I was able to fix it with your guide

zoor | March 25, 2015 10:16 PM |

please the display is too tiny i cant see anything to even make changes, what do i do?

Lukas | March 5, 2015 2:29 AM |

Uncomment: Disable_overscan=1 In /boot/config.txt And you are done Mate.

Martin | February 10, 2015 10:15 PM |

Sure did the trick for me :-)

bobby | January 3, 2015 10:41 AM |

this didnt do anything. still off the screen on both sides