Unable to install any packages Ubuntu 23.10
All of a sudden, I am unable to install anything successfully with apt with the below error:
The following packages will be upgraded: linux-headers-6.5.0-10-generic 1 upgraded, 0 newly installed, 0 to remove and 4 not upgraded. 75 not fully installed or removed. Need to get 0 B/3,737 kB of archives. After this operation, 28.8 MB of additional disk space will be used. (Reading database ... 156176 files and directories currently installed.) Preparing to unpack .../linux-headers-6.5.0-10-generic_6.5.0-10.10_amd64.deb ... Unpacking linux-headers-6.5.0-10-generic (6.5.0-10.10) over (6.5.0-10.10) ... dpkg: error processing archive /var/cache/apt/archives/linux-headers-6.5.0-10-generic_6.5.0-10.10_amd64.deb (--unpack): error creating symbolic link './lib/modules/6.5.0-10-generic/build': Read-only file system dpkg: error while cleaning up: unable to remove newly-extracted version of '/lib/modules/6.5.0-10-generic/build': Read-only file system Errors were encountered while processing: /var/cache/apt/archives/linux-headers-6.5.0-10-generic_6.5.0-10.10_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1)
If it helps, and possibly could be, the issue is that I have enabled the experimental feature called TPM Encryption in my Ubuntu 23.10 installation.
I have submitted a bug with the inbuilt Ubuntu bug submission software. But I am unable to even install PHP packages without running into this error.
I have tried the following:
sudo apt clean && sudo apt update && sudo apt upgrade
sudo dpkg --configure -a && sudo apt-get -f install
Does not resolve the issue.
In this answer I am presuming that the root file system has been damaged and that you need to fix it. This is not normally something anyone should do without great care. See if you can find someone to assist in person.
I think one way forward is to boot the computer using another installation, e.g. a live ISO or similar, and then run
fsck on the main disk drive.
If you value your data I would also strongly suggest you ensure you have a good backup of the data, should something have gone wrong (which is quite possible). Obtaining a USB-connected drive and doing a
dd backup would work, though other ways may be faster. Do this BEFORE you run fsck!
Running fsck generally requires that the filesystem is not currently in use, hence using a live ISO. There may be GUI ways but I would suggest something like:
fsck -n /dev/sda1
which would check (but not change) the first partition on block device sda. You may have different device names, so use
lsblk to identify which device has what content. For example if you have an NVME SSD drive the name will be something like
If a run of
fsck -n ... shows any errors, you will be asked questions but the answer will be pre-filled with ‘no’ (hence -n). To fix them requires re-running the command without
-n, which would pause and ask you what to do each time an error was found, or with
-y, which will answer ‘fix’ to all questions. Unless you know what you’re doing,
-y is recommended.
You did make a backup?? this is why!
fsck is not magic, and it may not fix the filesystem completely or at all. If it does, you should run
sync to flush the disk cache and then reboot the computer back into the live ISO. Now run the
fsck -n again to see if it’s still broken. If so, you will need to take your backup to a (more) competent person for help.
If it seems ok, mount it locally in the live distro and have a look:
mount /dev/sda1 /mnt
(replace sda1 with the disk device name found earlier).
You should then be able to
ls files on the device under
/mnt. In particular for the ‘ext4’ filesystem you will see a directory ‘lost+found’, which is where ‘fsck’ puts any files or directories that it doesn’t know what to do with otherwise. If there are things there, you will need to assess whether it’s worth persevering with this disk or to copy what you can off to another device and then reformat and rebuild. Sometimes it is, sometimes it’s very hard to get all correct again.
Hope you have luck.
This is now a known bug and has been submitted by another person on launchpad. The link to the bug report is here.