I came across this problem with my RPi 2 model B many times this last month, and I wanted to ask your opinion about it. The problem occurred with Raspbian Jessie Lite, both the 23/09/2016 version and the previous one. I connect to the RPi via ssh from my laptop. The RPi is adequately powered.

Basically, when I edit a file with nano and I reboot or shutdown/start the RPi, I often find out that the file has been corrupted. This happened with configuration files for transmission/daemon or samba, but also with crontab. With corrupted I mean that usually half or more of the file has been overwritten by random sequences of ^@ and last time I even noticed that half of the crontab had been copy-pasted to the file /etc/transmission/daemon/settings.json which I previously edited. Another time the RPi failed to boot altogether.

My question is: is this a known bug/problem with either nano or Raspbian? Or maybe it is a failing micro SD? Or, worse, could it be the RPi itself?

Currently I don't have a different micro SD to try out, I will edit the question as soon as I get one.


There are two possibilities (given that if there was a bug in nano or Raspbian there would be several thousand reports).

  1. You are not saving the file (unlikely).
  2. Your SD card has a corrupt filesystem.

To eliminate 1 all you need to do is use the sync command from the command line after saving the file (to ensure it is written to the SD card) and cat the file.

  • So this means that ctrl+X in nano isn't enough to save the file? Alright, I will try the sync command, thank you very much! – user34748 Oct 8 '16 at 18:37
  • Linux will do an auto sync every now and then (certainly before a shutdown) so I doubt the lack of sync is the problem. But it's worthwhile to see if it makes any difference. – joan Oct 8 '16 at 18:40
  • I tried with a different micro SD and so far so good, I didn't experience any of the problems described in my question. Also, the sync command didn't work. I'm accepting your answer given that point 2. is the likely explanation. – user34748 Oct 11 '16 at 20:05
  • @NicolaBastianello Have you seem Milliways answer below. Perhaps you weren't actually saving the file. – joan Oct 11 '16 at 20:08
  • No, I'm sure I was saving it, I always typed 'y' when prompted to save or discard the changes and the confirmed the name of the file I wanted to save. – user34748 Oct 11 '16 at 20:10

ctrl+X in nano doesn't save the file, just exit the editor. You need to Writeout with ctrl+O

  • 2
    It'll ask if you want to save though – ElefantPhace Oct 9 '16 at 2:48

Your Answer

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