2

I am new to raspberry pi, and to linux. When I am trying to follow tutorials online, they sometimes require me to change /boot/config.txt. I am using the Jessie Version or Raspbian. (I am trying to change the file on the pi itself.) Whenever I try to save my edits, however, I get an error saying "Can't open file to write." How can I edit config.txt?

  • Do you use Linux or Windows to change the file? – MadMike Aug 19 '17 at 15:09
  • I am using the Jessie Version or Raspbian. (I am trying to change the file on the pi itself.) – Nathan Dimmer Aug 19 '17 at 15:12
  • 1
    Hello and welcome. Please use the edit function to add requested information directly to the question itself instead of putting it in comments. This ways readers of your question will get the whole picture much easier without going through the comments too. Thanks. – Ghanima Aug 19 '17 at 15:21
3

Locked SD-Card

Check if your SD-card (or SD-card adapter) has been set to "lock" by accident.

Unlocked SD card

/boot mounted as read-only

Issue a

mount | grep /boot

if the the output is

/dev/mmcblk0p1 on /boot type vfat (ro,relatime, ... ,errors=remount-ro)

it is mounted read-only (see the ro). You can remount it with the following command:

sudo mount -o remount,rw /boot

Sometimes there are errors on the boot-filesystem which triggers the system to mount it read-only. Issue a

sudo fsck -y /boot

to try and correct errors.

Edit your file with root rights

/boot/config.txt isn't editable by the pi user. So you need to start your editor with sudo to gain root rights:

sudo nano /boot/config.txt

You can check the file right with ls -l. Here an example:

ls -al /boot/config.txt 
-rwxr-xr-x 1 root root 1590 Jul  5 10:53 /boot/config.txt

root root means that the file is owned by the user root and by the group root. -rwxr-xr-x shows who has which rights. The first part -rwx means that the user has the right to read, write and execute the file. The next part r-x means that other user of the group root can read and execute the file. The last r-x the other users. Which are allowed read and execute the file.

  • I am using a micro-sd card... – Nathan Dimmer Aug 19 '17 at 15:09
  • I tried remounting, and it still wouldn't save, then I tried "sudo fsck -y /boot" but it till wouldn't save. – Nathan Dimmer Aug 19 '17 at 15:32
0

If you are new to RPi & Linux, you might find the Leafpad editor more friendly... :-)

sudo leafpad /boot/config.txt
0

You can also edit the file from another operating system. It is very handy if you cannot boot up the raspberry pi anymore. Plug the sdcard into your computer (using an adapter). You will find two partitions on the sdcard. Go into the folder boot. There you will find the file config.txt. Edit it with a text editor like Notepad++. Then save it. Put it back into the raspberry and boot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.