中途停止从 20.04 LTS 升级到 22.04 LTS,现在无法执行 sudo apt update 和 upgrade

中途停止从 20.04 LTS 升级到 22.04 LTS,现在无法执行 sudo apt update 和 upgrade

因此,我一直在等待 22.04 LTS 版本在 sudo dist upgrade 上发布,并立即开始按照 [此处][1] 的步骤通过官方“安全”方法进行升级。我按照以下步骤操作,直到我必须在提示符中输入是/否的部分:

X number of packages are going to be removed
Removing the packages can take several hours

我后来决定不升级,没有注意到提示中有一个选项可以回答升级的“否”,于是就不停地按 Ctrl+C 和 Ctrl+D,因为它们通常会在中途停止终端进程。这两个都不起作用,所以我关闭了部分卡在升级中的终端窗口并终止了该进程。(这部分肯定是错的^)

部分升级重写了我的 sources.list 文件,并将“focal”列表源替换为“jammy”源。以下是在目录中找到的一个/etc/apt/实例

deb http://in.archive.ubuntu.com/ubuntu/ jammy multiverse
# deb-src http://in.archive.ubuntu.com/ubuntu/ focal multiverse
deb http://in.archive.ubuntu.com/ubuntu/ jammy-updates multiverse
# deb-src http://in.archive.ubuntu.com/ubuntu/ focal-updates multiverse

“focal”源被注释掉,并添加了“jammy”源。sudo apt update 和 sudo apt-get update 都不起作用(第三方软件的匹配变得无效),所以我将文件修改sources.list为 Ubuntu 20.04 附带的默认版本。其当前内容为:

deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse

deb http://archive.canonical.com/ubuntu focal partner
deb-src http://archive.canonical.com/ubuntu focal partner

sudo apt update现在可以sudo apt-get update正常工作,但它们只命中那些默认源,没有任何第三方软件源。我准备了一个备份文件 (sources.listdefault.bak),其中包含sources.list升级前的内容,其内容为:

deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse

deb http://archive.canonical.com/ubuntu focal partner
deb-src http://archive.canonical.com/ubuntu focal partner
cassandra.list   #line 15
cassandra.list.distUpgrade
cassandra.list.save
home:hawkeye116477:waterfox.list
home:hawkeye116477:waterfox.list.distUpgrade
home:hawkeye116477:waterfox.list.save
...etc

将这些行复制到 sources.list 文件中,但是当我运行 sudo apt update 时出现了新的错误:

E: Malformed line 15 in source list /etc/apt/sources.list (type)
E: The list of sources could not be read

仅供参考:第 15 行是我的第三方软件源的起始位置,它们前面是原始工作的“焦点”源。结果是sudo do-release-upgrade -d

Checking for a new Ubuntu release
Traceback (most recent call last):
  File "/usr/bin/do-release-upgrade", line 133, in <module>
    m = MetaReleaseCore(useDevelopmentRelease=options.devel_release,
  File "/usr/lib/python3/dist-packages/UpdateManager/Core/MetaRelease.py", line 100, in __init__
    cache = apt.Cache()
  File "/usr/lib/python3/dist-packages/apt/cache.py", line 170, in __init__
    self.open(progress)
  File "/usr/lib/python3/dist-packages/apt/cache.py", line 232, in open
    self._cache = apt_pkg.Cache(progress)
apt_pkg.Error: E:Malformed line 15 in source list /etc/apt/sources.list (type), E:The list of sources could not be read.

我认为发生的事情是,Ubuntu 认为它实际上是 22.04,但由于我部分停止了升级,有些内容仍然是 20.04(lsb_release -a也这么说)。我该如何解决这个问题(apt 无法更新我的第三方源)?我是否被困在一个既不是 20.04 也不是 22.04 的无效 Ubuntu 版本中,我必须删除操作系统本身?我准备备份我的系统并从头开始重新安装 Ubuntu,但我更愿意看看我的选择,看看我是否可以从中断的地方恢复更新,或者完全降级到原来的普通 20.04。

TL,DR:中途停止从 20.04 升级到 22.04,可能会陷入 frankensystem

我还阅读了与另一个部分升级问题相关的评论 [2],但我不知道该怎么做。将提供所需的任何其他详细信息。感谢您阅读这篇长文,我将不胜感激任何帮助。

相关内容