5

The image file I am using is quite old. How old exactly I am not sure, because this image I have inherited from previous developer.

I have learnt that running:

sudo apt-get update
sudo apt-get upgrade

Kills the Raspberry Pi. I checked memory consumption with htop, and at the last moment the system was responding I had 10 megabytes left (including swap). Then everything went readonly, the upgrade crashed, not a single command was working (I typed ls, ls command not found, cat, cat command not found). I had to reboot.

I increased swap size to 512 megabytes, and it seemed it helped a little, but Raspbian crashed on later into the installation.

I would like to hear from you guys:

  • Did you have a similar error?
  • How do I solve it?
  • Is there a way to install only some packages and not all of them in one go?

Typical stdout from apt-get upgrade looks like this:

Unpacking replacement python2.7-minimal ...
Preparing to replace idle-python2.7 2.7.3-6 (using .../idle-python2.7_2.7.3-6+deb7u2_all.deb) ...
Unpacking replacement idle-python2.7 ...
Preparing to replace initramfs-tools 0.109.1 (using .../initramfs-tools_0.115~bpo70+1_all.deb) ...
Unpacking replacement initramfs-tools ...
Preparing to replace libclutter-1.0-common 1.10.8-2 (using .../libclutter-1.0-common_1.10.8-2+rpi1_all.deb) ...
Unpacking replacement libclutter-1.0-common ...
Preparing to replace libcogl-common 1.10.2-7 (using .../libcogl-common_1.10.2-7+rpi1_all.deb) ...
Unpacking replacement libcogl-common ...
Preparing to replace libglib2.0-data 2.33.12+really2.32.4-5 (using .../libglib2.0-data_2.40.0-3rpi3rpi1_all.deb) ...
dpkg: unrecoverable fatal error, aborting:tee: deployment.log: Read-only file system
Etee: deployment.log: Read-only file system: Sub-process /usr/bin/dpkg returned an error code (2)

Some people have requested df -h:

Filesystem      Size  Used Avail Use% Mounted on
rootfs           15G  2.4G   12G  18% /
/dev/root        15G  2.4G   12G  18% /
devtmpfs        212M     0  212M   0% /dev
tmpfs            44M  236K   44M   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            88M     0   88M   0% /run/shm
/dev/mmcblk0p1   56M   19M   38M  33% /boot
Peter Mortensen
  • 2,004
  • 2
  • 15
  • 18
Drachenfels
  • 171
  • 1
  • 6
  • You are trying to write to a read only filesystem. Please edit your question and include the contents of /etc/fstab. – Steve Robillard Feb 17 '15 at 23:54
  • I thought we should not be using swap http://raspberrypi.stackexchange.com/questions/70/how-to-set-up-swap-space or did you mean something else? – rob Feb 18 '15 at 09:01
  • How much disk space have you got left? What is the output of df -h ? – Bex Feb 18 '15 at 09:19
  • 1
    @rob This is I don't know why but shared misconception, raspbery is using dphys-swapfile. – Drachenfels Feb 18 '15 at 10:19
  • @Bex nearly 12 gigabytes is left. I can provide you with df -h when I get back to home. – Drachenfels Feb 18 '15 at 10:20
  • @SteveRobillard nope I am not trying to write to read only filesystem, unless out of blue my home becomes read-only. ;-) This is not the cause. Perhaps all partitions are suddenly unmounted? Perhaps. Errors are more or less random, sometimes upgrade crashes with statement 'there is no perl' or 'there is no python', 'there is no make'. After that you can see in logs complains about missing commands and read-only file system. At that point I cannot check anything because there is no single command that works (no ls, cat, echo, sudo, vim or whatever you can think of). – Drachenfels Feb 18 '15 at 10:24
  • @SteveRobillard I will add one more thing, while this output is from the script that intercepts all the stdout and stderr and saves it to file (this is why you can see complains about tee, deployment.log and etc). Exactly the same happens when I run command manually without this wrapper, same complains about readonly but no deployment.log mentioned but stuff like /usr/man/ or /usr/lib/. Obviously unwrapped stuff leaves no trace thus cannot post it here. – Drachenfels Feb 18 '15 at 10:35
  • 1
    @Bex df -h added to main question. – Drachenfels Feb 18 '15 at 10:49
  • Its been a while, but what for the 2nd part of the question of how to get out of the situation? I just had this same effect and after rebooting my (headless) pi has all the necessary LED blinking (LAN, disk) but does not respond to ping. – Harald Jan 07 '18 at 15:21
  • After reboot your pi should be fine, unless some critical package got corrupted in the process. In my case restart always helped. Back then I was working to have sort of conveyor belt installation process that was fully automated. if anything went wrong (critically wrong) I was installing raspbian from the image all over again. – Drachenfels Jan 08 '18 at 15:50
  • As per how to avoid this error in the first place, I found no good solution. – Drachenfels Jan 08 '18 at 15:51

4 Answers4

2

Did you have a similar error?

Yes, if I don't take care to avoid it.

How do I solve it?

  1. Use top to make sure you have stopped all CPU or RAM consuming services. For example,

    /etc/init.d/lighttpd stop
    
  2. Prefix your upgrade command with nice.

  3. Sometimes upgrading breaks, or the img breaks, and you just need to re-install, so keep an install log and backup files you created.

Is there a way to install only some packages and not all of them in one go?

Yes,

sudo nice apt-get install PACKAGE-TO-BE-UPGRADED
user1133275
  • 2,216
  • 15
  • 31
2

As far as I can tell there is no easy solution. If the Pi wasn't upgraded regularly there is a great deal of chance that running generic sudo apt-get upgrade will kill it. Adding nice or releasing as much memory as possible helps mitigate but not really solves the problem. I tried to create a bash script that first reads packages that require update, and then upgrade them one at a time as a subprocess. On paper I understood it will solve it, in practice, not really (however it might be that bash script worked differently than I thought), for a reference below:

DATA=$(apt-get upgrade -s -y -q | grep "Inst " | cut -d ' ' -f 2)

PACKAGES=(${DATA// / })
Z=0

for package in "${PACKAGES[@]}";
do
    echo ""
    echo ""
    echo "apt-get install -y -q $package"
    bash -c "nice apt-get install -y -q $package"
    bash -c "nice apt-get clean -y -q"

    Z=$((Z+1))

    # update only first 50 packages, just to be sure that we won't kill pi by running this script
    if [[ $Z -eq 50 ]];
    then
        break
    fi
done
Drachenfels
  • 171
  • 1
  • 6
1

Check your SD card against this list. I bought two of the same cards at the same time and had the same issue, only to find my make and model were listed as Not OK on this list.

tlhIngan
  • 3,372
  • 5
  • 19
  • 33
0

I had a similar issue on my Zero 2 W, and there were two things that solved it:

  1. Set the Pi to boot to command line (not GUI) using raspi-config. This stopped apt-get from completely locking up my Pi, allowing me to keep htop running in a second SSH session so I could monitor CPU, memory, swap, etc.

  2. Increase swap file size. The default was set to an absurd 100 MB, so I set it to 1024 MB and my issue was solved. Have run a pretty huge apt-get update with no issues, no further lock-ups.

Other things I tried that didn't help my specific situation:

  • fsck - my filesystem was fine.
  • disabling IPv6 - made no difference. I've re-enabled IPv6 and re-tested, and it's not causing any issues.

Link to page that explains the GUI and swap file fixes - see bottom post: https://forums.raspberrypi.com/viewtopic.php?t=311580

Ash
  • 1
  • 1