Edit - I checked the version and the original SD A was actually at Buster. SD B is at Buster as well.
My Raspberry Pi 3 B+ was turned off while running sudo apt-get upgrade
. The SD card (SD card A) is fine, the PI is fine, but it hangs at the rainbow screen on boot.
I flashed a new card with base Raspbian Buster (SD card B) and booted the Pi using that with SD Card A in a USB reader. Can see SD Card A file systems (rootfs
, boot) and open in the terminal, read files, etc.
I don't really know what I am doing with fsck but after some reading did the following based on How to recover files from pi SD card which can't boot
# have RPi 3B+ booted with SD B and original SD A card that was powered off during upgrade in USB reader slot
pi@raspberrypi:/media/pi $ mount
/dev/sdb2 on /media/pi/rootfs type ext4 (rw,nosuid,nodev,relatime,uhelper=udisks2)
/dev/sdb1 on /media/pi/boot type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)
pi@raspberrypi:/media/pi $ sudo umount /dev/sdb2
pi@raspberrypi:/media/pi $ sudo umount /dev/sdb1
pi@raspberrypi:/media/pi $ sudo e2fsck /dev/sdb2;
e2fsck 1.44.5 (15-Dec-2018)
rootfs: clean, 208916/1903104 files, 4906295/7724160 blocks
pi@raspberrypi:/media/pi $ sudo fsck /dev/sdb1
fsck from util-linux 2.33.1
fsck.fat 4.1 (2017-01-24)
/dev/sdb1: 113 files, 48952/516191 clusters
To me, this implies SD A is OK card and filesystem integrity-wise, and I might be able to recover it by cleaning up or re-initializing the card with Raspbian Stretch.
I've been searching for a couple of hours but Google is just incoherent in terms of how to do this - most of the advice for searches like "repair Raspberry PI SD card after power off during upgrade" just talk about corrupted SD card or not pulling the power while it's running, which isn't this scenario.
I have a number of sensors attached to this Pi and drivers/custom code installed and if there's any way I can recover SD A I'd like to do that. I can just copy the files to SD B but I'm afraid I'll just copy the corrupted to SD B and then it won't work either.
Can I edit files on SD A to reset the in-progress upgrade, or find out what's wrong?