1

I think I got some SD corruption by plugging one-too-many external (powered) USB drives into a Pi 3, (but not using a powered USB hub).

I am able to start-up and I can ssh into the device, but when I connect via RealVNC, I get a tiny screen back.

I am hoping that there's some way to rescue the card contents. I'd really appreciate it if anyone has any ideas what I can try next. (I have another Pi and a Mac that I can use if of any use.)

This is what I have tried:

Trying to recover the VNC connection, I tried running

vncserver

to establish a virtual mode instance, but this resulted in an error:

xauth:  error in locking authority file /home/pi/.Xauthority
Error: could not run xauth

/home/pi/.Xauthority shows -rw------- (600)

If I try to do

chmod

or

sudo chmod

I get an error:

chmod: changing permissions of 'xxx': Read-only file system

I have tried doing

sudo fsck.ext4 -v /dev/xxx

and then trying to find superblock backups with

sudo mke2fs -n /dev/xxx

but this doesn't find any backups.

4

If the linux OS has become corrupted sometimes it will place the entire root in read only mode to prevent further damage. If this is the case, use ssh only and try the following from your mac to the pi:

ssh [user]@[ip]

In the terminal for the pi we need a root shell and to remount the drive

sudo su
[type password]
mount -o remount, rw /

The filesystem should now be accessible. Now you can navigate and clear any protections you have made on any files for later. Make a list of all files you wish to recover. Exit the ssh shell

exit
exit

Now back in the mac terminal (I think mac has scp? it should) we will copy all the files you listed.

scp [user]@[ip]:[/path/to/foo.bar] [/path/to/save/on/mac/foo.bar]

alternatively while you are in the root shell in the pi you can save copies of each file you wish to save in a new directory in the home folder, then use the tar utility to compress them together in one file, then scp that only. This method however is inadvisable if the sd card is in fact failing. The more writes you do, the more likely the sd card will just quit.

This is what I would try. Hope it helps!

  • Thank you for your reply. The good news is that I was able to access the filesystem after remounting the drive. Now, I am confused about which files I need to 'rescue' to be able to make a new SD card. For starters, I am not sure whether the boot partition will be where the corruption lies. Do you have any general advice for me to get back to my previous position without simply starting over? – Lorccan Jun 24 '17 at 17:24
  • The files you are looking for are any configuration .conf files you have modified to your taste, any shell scripts you have written .sh or .py or anything else you have placed on the system that would required you to rewrite everything inside. As for the system itself, it is simpler to wipe the card and start fresh by writing a new raspian OS to the card or another card if the card itself is bad. I'd recommend saving anything you made or changed yourself, and starting over with a new OS install. – Nalaurien Jun 24 '17 at 17:39
  • Understood. Luckily this was a relatively new build so it won't take too long to get back to where I was. I can pull down some configuration files that will save time. – Lorccan Jun 24 '17 at 18:05
0

I had this problem on a Raspberry Pi 2B running on a HDD. The problem occurred because of power supply low Voltage when the disk was active.

The solution of "In /boot/cmdline.txt, add rw just before rootwait" worked. After you use this solution, or any solution for that matter, to restore a drive to working, check for data corruption and also make a backup immediately.

  • Welcome to the Raspberry Pi flavoured corner of the Stack Exchange network. You may wish to take the tour to get a better idea of how to ask and answer questions in the most effective way. I think your response would work better as a comment on the other answer - though you will need to build up to 50 reputation point to do that on other peoples answers - you can nevertheless comment at this time on the question which is almost as good as it still indicates to others that a solution has been tested and works for me... – SlySven Dec 24 '18 at 1:48
  • ... anyway, I hope you continue to participate and come up with original questions and answers. 8-) – SlySven Dec 24 '18 at 1:49
-1

In /boot/cmdline.txt, add rw just before rootwait

  • Does that work when the SD card put itself in RO mode? – Dirk Dec 8 '18 at 11:41
  • I dident test it but it shall work – Ar Win Dec 9 '18 at 12:06
  • I doubt it since the card has its own processor and 'OS' – Dirk Dec 9 '18 at 12:39
  • It works when linux have made it readonly – Ar Win Dec 9 '18 at 17:49

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.