I ruined my RPi, by using Python script in rc.local which shutdowns RPi as soon as it starts. Thus I cannot even login or ssh. How could I edit SD card from windows to change that rc.local file?

  • boot into safe mode, use this answer (not the accepted answer) - note, you will need keyboard and screen on the pi
    – Bravo
    Commented Feb 3, 2022 at 9:42
  • thanks, but I already installed fresh OS to sd card. I retrieved all important data with win32imager and 7zip
    – Ri Di
    Commented Feb 3, 2022 at 13:22

1 Answer 1


This can not be done on Windows, but it can be fixed on any Linux system (which can be a Pi).

You can repair most such problems on the Pi itself by rebooting to a root shell.

  1. Append init=/bin/sh at the end of cmdline.txt and reboot.
  2. After booting you will be at the prompt in a root shell.
  3. Your root file system is mounted as readonly now, so remount it as read/write mount -n -o remount,rw /

You can then edit files to fix the problem.

  1. Remove init=/bin/sh from cmdline.txt and reboot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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