1

Recently, my Raspbian OS froze on my Raspberry Pi 4, and when I restarted the machine, it immediately produced a solid green screen. Research suggests that it is most likely due to a corrupted OS, and the most popular solution is just to reinstall a fresh copy. However, I don't want to have to set up the software on my Pi all over again. Is there a way to repair a Raspbian installation without wiping the SD card?

I should add that the green screen comes up almost immediately on boot, so there's no opportunity for me to jump into a command line interface first.

Thanks in advance to the community for their help!

  • "the most popular solution is just to reinstall a fresh copy" -> Yes, among the desperate and naive (and I mean that seriously and objectively). The normal way to deal with a corrupted filesystem is to run fsck on it. WRT "green screen", you might want to describe this in better detail, because it is not at all normal or commonplace: After more than a decade and 36K+ questions there are only two here that mention a green screen at boot, and one of them is in reference to something attached via a USB-to-VGA adapter... – goldilocks Mar 03 '23 at 15:12
  • What happens if you power up with NO SD card inserted? The same, or something different? – goldilocks Mar 03 '23 at 15:15
  • You can see a photo of this green screen phenomenon here: https://tacticalware.com/raspberry-pi-green-screen/. Although there's not much discussion of it on this forum, I do see a lot of mentions elsewhere. – 123MilitaryNerd Mar 04 '23 at 21:54
  • Since the Pi boots directly to the green screen, I can't run fsck natively. I do have the SD card plugged into another laptop and tried fsck there, but the card mounts as read-only, and I can't get around that. I hadn't thought of booting the Pi without the SD card, but I'll give it a try. – 123MilitaryNerd Mar 04 '23 at 21:54
  • Okay, booting without the SD card gives me this: https://i.imgur.com/NO5MjKg.jpg. – 123MilitaryNerd Mar 04 '23 at 22:42
  • So the presence of the SD card does have some effect, which is probably better than if it had none. You should try putting an image on a new card -- 16gb should be plenty, and those are < $10, so it is a bit about how much your time is worth to you. Use that to make sure something can boot. You also need to solve the problem with the card mounting read-only on your laptop. That implies you at least can access the filesystems there, post the output of fdisk -l /dev/whatever. – goldilocks Mar 05 '23 at 14:17
  • Finally, the moral of the story here is to keep your tish backed up and look into an automated config system liike puppet or chef. I have my own set of scripts for a similar purpose, and I can replace any of my Pi systems from scratch in under an hour (which a lot of people would consider way too slow). This is not to say "just reinstalling" is a good solution to every problem (I haven't done it more than a couple of times in 10 years of daily pi use), but sometimes you may end up with no other choice. – goldilocks Mar 05 '23 at 14:18
  • When I plug the SD card into another computer, I get three directories: root, boot, and SETTINGS. The fdisk output for all three is here: https://i.imgur.com/TcZWCly.png (the order shown is boot, SETTINGS, root). I have everything backed up, but I'm not familiar with auto-config tools, so I'll explore those for future reference. I can get another SD card, but it will take me a couple of days. – 123MilitaryNerd Mar 05 '23 at 18:32
  • My hope in all of this was that I could just plug the SD card into another computer, run a repair utility, and have it as good as new, but it sounds like that may not be possible. – 123MilitaryNerd Mar 05 '23 at 18:33
  • Actually I meant fdisk -l /dev/mmcblk0, ie, the partition table for the card -- but anyway, partitions are numbered from 1, so there are, ostensibly at least seven partitions on the card. This could be due to a corrupted partition table (good idea to keep a copy of the first 512 byte block on the card as a backup for this, see MBR). If you honestly can't find a way to mount it read-write and try fsck on it, you're in a small minority; you might want to give up on the card at this point and just consider it defunct (which it could be). – goldilocks Mar 07 '23 at 15:38
  • Ah, okay, here's the fdisk output: https://i.imgur.com/vImYpx3.png. Running fsck gives me this: https://i.imgur.com/h39fIGt.png. I get the same thing regardless of which way the write-protect switch on the side of the microSD-to-SD adapter is turned. – 123MilitaryNerd Mar 08 '23 at 02:27
  • WRT the fdisk stuff, that makes sense-- my bad in that you can't have more than 4 "primary" partitions on a DOS MBR formatted device, but you can divide one of them into more "extended" partitions, in this that's p2 and it contains p5/6/7, the extended partitions are numbered from 5 hence the last one is p7 (and their total size adds up to the size of p2). But dunno why you have a 2G boot partition, then a boot sized fat32 partition in p6 (and a tiny smidge ext fs in p5). – goldilocks Mar 08 '23 at 12:33
  • WRT fsck, it's a filesystem checker, but /dev/mmcblk0 is not filesystem, it's a block device with 5 partitions on it some or all of which contain filesystems. That might be why it considers it "read only", in any case you should be trying fsck /dev/mmcblkp1 etc (don't bother with p2, the extended container). Have you tried to mount any of these outside the pi? If so, what is the content of cmdline.txt in p1? – goldilocks Mar 08 '23 at 12:37
  • Okay. I don't think I did anything other than the default installation of Raspbian when I set up the SD card. Certainly no fancy partitioning. Here's the message when I fsck p1: https://i.imgur.com/Ln9KKW2.png. Same issue. I also don't see a cmdline.txt file in p1 (and I can't find it with a find command, either). Here's p1 when I mount it: https://i.imgur.com/6JtwkbR.png – 123MilitaryNerd Mar 09 '23 at 00:39
  • You definitely installed Raspbian via NOOBS, though; that image has more than just the two base partitions (NOOBs does that so you can install multiple OS's), and when I searched here for "recovery.elf", I got this, which is virtually all explicitly in a NOOBs context -- and this answer makes that very clear. There's also "Where is cmdline.txt located on the NOOBS SD card?": recovery.cmdline, which is there. – goldilocks Mar 09 '23 at 13:31
  • ..I'm not too sure all this is going to be of much help to you though, because it really sounds like the card is probably defunct, esp. if you are trying to access it from another linux system and it says read-only (vs. eg. if you are using a linux container on a windows machine, maybe there is another reason for that). Could be that the card itself, when it gets worn enough (SD cards blacklist worn-out blocks, but eventually there is too many for them to function properly), it goes permanent read-only to prevent (more) data loss. – goldilocks Mar 09 '23 at 13:32
  • ..If all you have been doing is using Raspbian, you are better off doing a pure install of that anyway; the general consensus around here is that NOOBs causes more problems than it solves. You at least still have what's on the old card as a reference for configuration, etc., and hopefully any content that you didn't want to lose. – goldilocks Mar 09 '23 at 13:33

0 Answers0