-1

I had made a script and I wanted it to run on startup so I included it in /etc/rc.local. But I had forgotten that at the end of the script I have it set to shut the pi completely. And so now whenever I turn on the pi, it runs through the script and shutdown. I need to make a change to the code, is there any way for me to access the script via the sd card rather than actually turning it on. Or can I bypass the startup script? Thanks in advance.

2

1 Answer 1

1

Requirements

  1. Another computer running Linux OR another MicroSD card to boot the Raspberry Pi with.
  2. MicroSD card reader

Steps

  1. Shutdown the Raspberry Pi (Done!)
  2. Pull out the boot media, in this case the MicroSD card.
  3. Put the card in another computer running Linux using the MicroSD card reader.

This can be another Raspberry Pi with an USB MicroSD card reader. In this case, boot your Raspberry Pi with the second MicroSD card that does not have the script. Put the first MicroSD card (with script) into the USB card reader and plugin the USB card reader into your Raspberry Pi.

  1. Mount the ext4 partition in the MicroSD card to a suitable mount point, if the partitions in the card is not mounted automatically.
  2. Navigate to /media/username/A_bunch_of_letters_and_numbers/etc/rc.local and edit (and save) the script.
  3. Unmount or "Eject" the card so that it can be safely removed.

Done.

Note, if you only have a Windows 10/11 computer, the same thing can be done with Windows Subsystem for Linux (WSL). However, mounting the MicroSD card partitions in WSL is not simple.

A Note on Temporarily Running Linux on your PC

Most current Linux installation USBs allow running the OS without installing it into the internal disks. Here I will use the example of Raspberry Pi OS for PC as you should be familiar with its interface.

  1. Download Raspberry Pi OS for PC from https://www.raspberrypi.com/software/raspberry-pi-desktop/
  2. See https://www.techrepublic.com/article/how-to-run-raspberry-pis-raspbian-os-on-a-pc/ for how to create an installation USB from the downloaded file.
  3. Use the Run Without Persistence option to start the OS directly from the USB without installing. Do not choose Graphical Install if you don't want to install the Pi OS on your computer.

enter image description here

Note, you can also use the Run With Persistence option. For this purpose it does not matter.

Follow the steps above.

Hope this helps

2
  • 1
    Thank you! This seems like something that could work. One additional question though if you don't mind. Would Kali Linux be a suitable option for this procedure?
    – Mohammad
    Feb 24 at 0:05
  • 1
    @Mohammad Any current version of Linux distribution should work. Choose the one you are most familiar with. If you have Kali installed use it. You can even use the Raspberry Pi OS for PC. I mention "Raspberry Pi OS for PC" because I assume you are familiar with its desktop user interface.
    – user68186
    Feb 24 at 12:28

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.