Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8052

Raspberry Pi OS • Re: Emergency mode

$
0
0
If it were me and I was aiming for repair rather than recreate from scratch I'd do it like this:
  1. Get a couple of spare SD card at least one of which must be bigger than the capacity of the broken one.
    You can use a USB flash drive instead of one/both of the SD cards if your PI is able to boot from USB (you haven't told us which model you're using).
    You will lose all data on both drives
  2. Get two USB card readers
  3. On the first spare drive install a clean RPiOS image.
  4. Boot from it and let the first boot stuff run.
  5. Put the broken SD card into the card reader and insert it into the PI. If desktop mounts it, immediately unmount/eject both partitions.
  6. Identify which entry in /dev it is:

    Code:

    sudo lsblk
    Look for sd? (e.g. sda) in the first column. The last column for that device and all of its partitions (sda1 etc) should be empty.
  7. Connect the second spare drive
  8. Identify which entry in /dev it is:

    Code:

    sudo lsblk
    Look for sd? (e.g. sdb) in the first column. The last column for that device and all of its partitions (sdb1 etc) should be empty. It will be different to the one identified above
  9. Open a terminal
  10. Use dd to copy the broken SD card to the second spare drive:

    Code:

    sudo dd if=/dev/sda of=/dev/sdb
    Where /dev/sda and /dev/sdb are taken from steps 6 and 8 above. All data on the of= device will be lost so be 101% certain you have these correct.
  11. Wait...
  12. Disconnect the broken SD card and reader then put it in a safe place.
  13. Mount the second (root) partition of the backed up drive
  14. Open and edit it's [...]etc/fstab and either comment out the line for /boot/firmware* or add .nofail to the list of mount options. [...] should be replace with the correct path to where you (or the OS) has mounted the partition. Either of those will allow that drive to boot (barring further problems) as having the boot partition mounted is only usually necessary when performing some updates.
  15. Shut down
  16. Boot from the backed up drive.

You now have a system you can work with for recovery with minimal risk of further data loss.

And once you have it fixed (or have rebuilt it from scratch) remember to take regular backups.

*: or /boot if running Bullseye or earlier.

Statistics: Posted by thagrol — Tue Apr 29, 2025 10:06 pm



Viewing all articles
Browse latest Browse all 8052

Trending Articles