0

I have a Raspberry PI which is 4 years old and running all the time as a home server.

Recently I noticed that sometimes when I try to save or copy a file (however small it is) there are delays of several seconds before it finally saves. Is this a sign that my SD card is struggling to find cells that are still alive and needs replacement soon?

I can't find anything suspicious in logs. There are no I/O errors so far.

EDIT: htop says the hanging process in "D" state.

EDIT2: Yesterday my SD card died. I had a spare card and backups ready to replace it. But decided to install Bullseye into the new SD card so it took me a day to get everything back online. Didn't lose anything precious.

2 Answers 2

1

htop says the hanging process in "D" state.

This is bad and usually it does indicate failing hardware. What's happened is the OS is trying to do some IO and it isn't happening, so that process is stuck in uninterruptible sleep. It's uninterruptible because if the hardware doesn't respond, there's nothing that can be done -- other than I suppose kill the process, but there are some logical reasons not to do so. For starters, it may do more harm: Right now the process is just paused at some arbitrary point, but when killed, its relationship to other resources, data in memory, etc., what other processes (children) may also be killed because of it, is, and so on, are also arbitrary. Normally when a process is killed it and the OS have an opportunity to end things properly, even if it is in the middle of some activity.

Hence, even if you want to, you cannot kill D state processes (there may be some further technical reason for that, but in any case it is the case).

If this is due to glitches with the device the root filesystem is stored on, it can easily be that more and more processes get stuck the same way, which is obviously no good.

You should get a new SD card and hope that is the problem and not the SD card reader.

1
  • Yup that was it, yesterday my SD card started making i/o errors and had to replace it.
    – Calmarius
    Dec 12, 2021 at 15:16
2

Not necessarily. The application that copies files for you may be stuck for a number of reasons: Xorg call updating the window, swapping, generating a thumbnail, refreshing a list of favorite folders, calculating free space, etc. It's also possible that an unrelated process with a higher priority decided to access the SD card just moments before and your file manager has to wait.

If there's a change in system responsiveness that appeared recently, look at the system load when the Pi is idle (e.g. with top), perhaps something started to run behind the scenes recently.

2
  • htop says the process is in "D" state. I'm using the RPi only from SSH. So the GUI part is not relevant for me.
    – Calmarius
    Oct 5, 2021 at 15:51
  • @Calmarius you might want to check your SD card with e2fsck -c and run dmesg | grep sector to see if any actual bad blocks are reported Oct 6, 2021 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.