Apt upgrade results in Input/output error

Hi there, i ran an apt upgrade on my NCP which ended in an error.

root@nextcloudpi:/etc/php/8.1/cli# apt upgrade -f
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
  dos2unix python3-toml userconf-pi
The following packages have been kept back:
  gcc-8-base
The following packages will be upgraded:
  avahi-daemon base-files bind9-dnsutils bind9-host bind9-libs bluez console-setup console-setup-linux curl dbus dhcpcd5 dnsutils dpkg dpkg-dev isc-dhcp-client isc-dhcp-common
  keyboard-configuration libavahi-client3 libavahi-common-data libavahi-common3 libavahi-core7 libc-bin libc-dev-bin libc-devtools libc-l10n libc6 libc6-dbg libc6-dev libcurl3-gnutls
  libcurl4 libdbus-1-3 libdpkg-perl libexpat1 libgnutls30 libgssapi-krb5-2 libk5crypto3 libkrb5-3 libkrb5support0 libldb2 libpcre2-posix2 libpcre3 libpq5 libtirpc-common libtirpc-dev
  libtirpc3 libudev1 libuv1 libxml2 libxslt1.1 linux-libc-dev locales php8.1 php8.1-bcmath php8.1-bz2 php8.1-cli php8.1-common php8.1-curl php8.1-fpm php8.1-gd php8.1-gmp php8.1-intl
  php8.1-ldap php8.1-mbstring php8.1-mysql php8.1-opcache php8.1-readline php8.1-xml php8.1-zip publicsuffix python3-ldb raspberrypi-bootloader raspberrypi-kernel raspberrypi-net-mods
  raspberrypi-sys-mods raspi-config rpi-eeprom systemd-sysv tzdata udev unzip vcdbg zlib1g
82 upgraded, 3 newly installed, 0 to remove and 1 not upgraded.
Need to get 148 MB of archives.
After this operation, 169 MB disk space will be freed.
Do you want to continue? [Y/n] y
.
.
.
.
.
.
.
.
Removing 'diversion of /boot/overlays/gpio-no-bank0-irq.dtbo to /usr/share/rpikernelhack/overlays/gpio-no-bank0-irq.dtbo by rpikernelhack'
Removing 'diversion of /boot/overlays/gpio-no-irq.dtbo to /usr/share/rpikernelhack/overlays/gpio-no-irq.dtbo by rpikernelhack'
Removing 'diversion of /boot/overlays/gpio-poweroff.dtbo to /usr/share/rpikernelhack/overlays/gpio-poweroff.dtbo by rpikernelhack'
dpkg-divert: error: unable to sync file '/boot/overlays/gpio-poweroff.dtbo.dpkg-divert.tmp': Input/output error
dpkg: error processing package raspberrypi-kernel (--configure):
 installed raspberrypi-kernel package post-installation script subprocess returned error exit status 2
Setting up libc6-dbg:armhf (2.31-13+rpt2+rpi1+deb11u4) ...
dpkg: unrecoverable fatal error, aborting:
 unable to truncate for updated status of 'libc6-dbg:armhf': Read-only file system
sh: 1: /usr/bin/test: Input/output error
E: Sub-process /usr/bin/dpkg returned an error code (2)
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - pkgDPkgPM::Go (30: Read-only file system)

Afterwards i can’t access via ssh. But the PI is sending a ping back.
Anyone an idea how to get this fixed?

Thank you in advance!
Fisher

I/O errors are an indication of a corrupt filesystem or bad drive. I see it says “read-only” mode, if you’re using an SD card, this means it’s reaching the end of its lifespan

Hi, thanks for your fast answer. I’m also using a USB HDD for all the data, is there a way to just setup a new sd card and get it going or do i have to do a complete fresh install? At the moment i’m not completely sure if my database is on the sdcard or on the HDD, but i think i moved it to the HDD.

Thanks for your answer!
Fisher