You are in the middle of a Raspberry Pi project when you suddenly realize that something is wrong: fixing it means editing the config.txt file, which is located in the /boot/ directory.

But what’s the easiest way to access this file while the Raspberry Pi is still running? And if you have to disconnect to get a microSD card, how are you supposed to edit it? Here’s everything you need to know.

Why do you need config.txt on Raspberry Pi

Edit the config.txt file on Raspberry Pi

The default Raspberry Pi operating system (and most alternatives) rely on some configuration options that are read when the computer boots from a microSD card. They are stored in the config.txt document, which is located in the /boot/ folder.

Such instructions may regulate how the display is detected and the desktop is displayed; config.txt can even be used to overclock a Raspberry Pi. (or return to default clock settings).

Both of these settings are registered in config.txt because neither of them can be changed on a running Raspberry Pi. If the display is not detected, you cannot change desktop settings.

Similarly, if the Pi has been overclocked and won’t boot, or reboots multiple times, you won’t be able to access raspi-config to reset it. Instead, a config.txt file is provided which gives you the option to reset your Raspberry Pi’s clock speed.

It is also possible to change the USB boot mode from config.txt, just like for sound settings.

1. Accessing config.txt from within Raspbian

If you need to edit the config.txt file while Raspbian is running, you can find it. You will find the /boot/ folder in the root directory of the microSD card. Once you’ve found it, just double click to open it and edit it with your default text editor.

However, if you plan to edit the file, it is recommended that you keep the original. Make a copy of the file using your file manager, giving it a different but descriptive name. Once you do this, you can easily restore the original if you run into problems 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. Please note that if you edit the config.txt file, the changes will not 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 online, you can edit the config.txt file remotely. Do this by connecting via SSH (or VNC or RDP) and navigating to the /boot/ directory. You will need to use

 cd / 

command to elevate from the default /home/ directory in Raspbian. Here use

 ls 

list the contents of the root directory. Find / download / then

 cd /boot 

open it by listing the contents again. Here you should find config.txt. To read or edit a text file, use the nano text editor that comes preinstalled (although others are available).

 sudo nano config.txt 

After making changes, click ctrl+X, to save and exit. Don’t forget to reboot your Raspberry Pi after making changes.

 sudo reboot 

3. Edit the config.txt file on your computer.

Linux, Windows, and macOS computers must be able to access the config.txt file via a microSD card. This means powering off the Raspberry Pi (safely to prevent data corruption) and removing the SD card. Insert it into your computer’s card reader to check its contents.

Edit the config.txt file on a Linux PC

If you need to edit the config.txt file on a Linux PC, look for the drive listed in your default file manager when it is inserted. It should be listed as two devices: the main volume (usually «1.8 GB volume» according to Raspbian’s default partition size) and bootable .

Edit the config.txt file in Raspbian on a Linux machine

As you may have guessed, this is the volume you need to access. It is essentially a /boot/ directory mounted as a drive. Open this to find config.txt. Save any changes made in the default text editor, then use the » Extract» in the file manager to safely eject the SD card.

Edit the config.txt file in Windows 10

Installing a Raspberry Pi SD card on a Windows computer should result in it being immediately connected and accessible via Windows Explorer. However, while two partitions will be displayed on the device, only one boot partition will be available on Windows.

Select this, then find config.txt. Use the default Notepad text editor to make changes (or an alternative like Notepad++), then save and close when you’re done.

To safely eject the SD card, right-click the drive in My Computer and select » Extract» .

Edit config.txt on macOS

If you are using a Mac, you should find that the card appears on your desktop when it is detected. Use the Finder to browse the content looking for a file named config (without the .txt file extension). Read and edit the file in the TextEdit application, making sure that any changes you make are saved on exit. To eject the card, drag the desktop icon to the trash or click » Extract» in Finder.

Whichever method you use to edit the config.txt file from a microSD card read from your PC, be sure to safely eject the device before returning it to your Raspberry Pi.

Customize Your Raspberry Pi Even Further

The config.txt file is just one of several ways to edit the overall configuration of your Raspberry Pi. This is one of the best ways to hack Raspberry Pi through the boot partition. You probably already know about the raspi-config screen, which is accessed through the terminal. There’s even a Raspberry Pi desktop setup tool that can be found in Raspbian Jessie and Raspbian Stretch’s Preferences menu.

Setting up your Pi configuration can save you a lot of time if you do it right. To make sure your computer is set up the way you want it, why not take a look at PiBakery? ? It is a software tool that uses a block approach to help you pre-configure various Raspberry Pi settings in Raspbian, from the SSID and Wi-Fi password to running custom scripts.

Похожие записи