You’re in the middle of a Raspberry Pi project, when all of a sudden you realize there’s something wrong: fixing it means editing the config.txt file, which is found in the /boot/ directory.
But what is the easiest way to access this file while the Raspberry Pi is still running? And if you have to shut down to retrieve the microSD card, how should you edit it? Here’s everything you need to know.
Why You Need config.txt on Raspberry Pi
The Raspberry Pi’s default operating system (and most of the alternatives) rely on some configuration parameters that are read when the computer boots from the microSD card. These are stored in the config.txt document, found in the /boot/ folder.
Such instructions might adjust the way the display is detected and the desktop displayed; config.txt can even be used to overclock your Raspberry Pi (or return to default clock settings).
Both of these settings are logged in config.txt as neither can be changed on a running Raspberry Pi. If the display isn’t detected, you cannot alter any desktop settings.
Similarly, if the Pi has been overclocked and won’t boot, or repeatedly restarts, you won’t be able to access raspi-config to reset it. Instead, config.txt is provided to give you the option of resetting your Raspberry Pi’s clock speed.
It’s also possible to alter the USB boot mode from within config.txt, just as it is to tweak audio settings.
1. Access config.txt From Within Raspbian
If you need to edit the config.txt file while Raspbian is running, you should be able to browse to it. You’ll find the /boot/ folder in the root directory of the microSD card. Once you’ve found it, simply double click to open, and edit it in your default text editor.
However, if you’re planning to edit the file, it’s a good idea to retain the original. Make a copy of the file using your file manager, giving it a different, but descriptive name. Once you’ve done this, you’ll easily be able to restore the original should run into trouble with the edited version.
You can also create a copy in the terminal using
mv config.txt backupconfig.txt
Again, give your copy a meaningful name. Note that when editing the config.txt file, no changes will be applied until you reboot your Raspberry Pi.
2. Edit config.txt Remotely
Rarely connect a keyboard to your Raspberry Pi? As long as the computer is on the network, you should be able to edit the config.txt file remotely. Do this by connecting via SSH (or VNC or RDP) and browsing to the /boot/ directory. You’ll need to use the
command to step up a level from the default /home/ directory in Raspbian. Here, use
to list the contents of the root directory. Find /boot/ then
open it, again listing the contents. Here, you should find config.txt. To read or edit the text file, use the nano text editor, which comes preinstalled (although others are available).
sudo nano config.txt
Once the changes have been made, press Ctrl + X to save and exit. Remember to reboot your Raspberry Pi after making changes.
3. Edit config.txt on Your PC
Linux, Windows, and macOS computers should be able to access the config.txt file via the microSD card. This means shutting down your Raspberry Pi (safely, in order to avoid data corruption) and ejecting the SD card. Insert it into your computer’s card reader to check the contents.
Edit config.txt on Linux PC
If you need to edit the config.txt file on a Linux PC, find the disk listed in your default file manager when inserted. It should be listed as two devices, the main volume (typically “1.8GB Volume” as per the size of the default Raspbian partition), and boot.
As you might have guessed, this is the volume you need to access. It is essentially the /boot/ directory mounted as a drive. Open this to find config.txt. Save any changes you make in your default text editor, then use the Eject button in the file manager to safely eject the SD card.
Edit config.txt on Windows 10
Inserting the Raspberry Pi’s SD card on a Windows computer should result in it being instantly mounted, and accessible via Windows Explorer. However, while two partitions will be displayed on the device, only one, boot, will be accessible in Windows.
Select this, then find config.txt. Use the default Notepad text editor to make edits (or an alternative, such as Notepad++), then save and exit when you’re done.
To safely eject the SD card, right-click the drive in My Computer, and select Eject.
Edit config.txt on macOS
If you’re using a Mac, you should find the card appears on your desktop when it is detected. Use the Finder to browse the contents, looking for a file called config (without the TXT file extension). Read and edit the file in the TextEdit app, ensuring that any changes you make are saved when you exit. To eject the card, drag the desktop icon to the Trash, or click Eject in Finder.
Whichever method you use to edit the config.txt from the microSD card read on your PC, remember to safely eject the device before returning it to your Raspberry Pi.
Tweaking Your Raspberry Pi Even Further
The config.txt file is just one of several ways to edit your Raspberry Pi’s general configuration. You’re probably already aware of the raspi-config screen, accessed via the terminal. There’s even a desktop-based Raspberry Pi Configuration Tool, found in the Preferences menu on Raspbian Jessie and Raspbian Stretch.
Tweaking the Pi’s configuration can save a lot of time if you get it right. To help ensure the computer is set up as you intend, why not take a look at the PiBakery? This is a software tool that uses a block-based approach to help you preconfigure various Raspberry Pi settings in Raspbian, from the Wi-Fi SSID and password to running custom scripts.
Read the full article: 3 Ways to Edit the boot/config.txt File on Raspberry Pi