ubuntu18升级至ubuntu20

news/2025/1/8 16:34:39/

背景

机房有套老k8s集群,上面的比较重要的服务迁移走了。使用的是ubuntu18的系统,升级至ubuntu20再到ubuntu22,然后升级上面的k8s集群,方便后期维护

思路

注意的点:升级node节点的系统时,注意先将node上的pod及其他服务cordon&驱逐后再进行升级

步骤

  1. 配置机器路由&dns使得机器可以访问真正的互联网(你懂得)
  2. 移除第三方源
  3. 禁止GPU节点nvidia相关包的升级
  4. 执行升级
  5. 卸载gnome环境&也可以在升级前先卸载gnome环境

第一步骤配置路由略,配置私有dns

grep nameserver /etc/resolv.conf
nameserver 192.168.0.220
nameserver 127.0.0.53

移除第三方软件源&将软件源换为ubuntu官方源,不然升级到最后有可能重启的时候会出现kernel panic等诸多问题

mkdir /tmp/apt
mv /etc/apt/sources.list.d/* /tmp/aptcat /etc/sources.list
# deb cdrom:[Ubuntu 18.04.3 LTS _Bionic Beaver_ - Release amd64 (20190805)]/ bionic main restricted# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic main restricted## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ bionic universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic universe
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://us.archive.ubuntu.com/ubuntu/ bionic multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu bionic partner
# deb-src http://archive.canonical.com/ubuntu bionic partnerdeb http://security.ubuntu.com/ubuntu bionic-security main restricted
# deb-src http://security.ubuntu.com/ubuntu bionic-security main restricted
deb http://security.ubuntu.com/ubuntu bionic-security universe
# deb-src http://security.ubuntu.com/ubuntu bionic-security universe
deb http://security.ubuntu.com/ubuntu bionic-security multiverse
# deb-src http://security.ubuntu.com/ubuntu bionic-security multiverse

更新源

apt update
apt upgrade
# 配置允许升级到的版本
grep Prompt /etc/update-manager/release-upgrades
Prompt=lts
# 需要完全升级的包
apt full-upgrade
# 卸载掉不需要的包
apt autoremove -y
# 检查可以更新的版本
do-release-upgrade -c
# -d 表示更新到lts版本,这里无
# 开始升级 会使用一个终端与回话分离工具分开
do-release-upgradeCan not upgradeYour python3 install is corrupted. Please fix the '/usr/bin/python3'
symlink.# 之前使用alter管理python版本 软链接定向到/etc/alter下了 重新更改回来即可
ln -sf /usr/bin/python3.6 /usr/bin/python3

在使用了gnome环境的桌面中,大概需要下载1500个包

过程中出现的一些提示

# 选项1
Do you want to start the upgrade?8 installed packages are no longer supported by Canonical. You can
still get support from the community.26 packages are going to be removed. 222 new packages are going to be
installed. 1344 packages are going to be upgraded.You have to download a total of 1,223 M. This download will take
about 1 minute with your connection.Installing the upgrade can take several hours. Once the download has
finished, the process cannot be canceled.Continue [yN]  Details [d]# 输入y# 选项2
系统正在询问你是否允许在升级过程中自动重启某些服务(例如 libpam、libc 和 libssl 等关键库相关的服务
Configuring libc6
There are services installed on your system which need to be restarted when certain libraries, such as libpam, libc, and libssl, are upgraded. Since these restarts may cause interruptions of service for the system, you will normally be prompted on each upgrade for the list of services you wish to restart.  You   │  │ can choose this option to avoid being prompted; instead, all necessary restarts will be done for you automatically so you can avoid being asked questions on each library upgrade.                                                                                                                                        │  │                                                                                                                                                                                                                                                                                                                           │  │ Restart services during package upgrades without asking? # 选择yes# 选项3A new version (/tmp/fileG81NRI) of configuration file /etc/ssh/sshd_config is available, but the version installed currently has been locally modified.  │                                                                                  │                                                                                                                                                          │                                                                                  │ What do you want to do about modified configuration file sshd_config?                                                                                    │                                                                                  │                                                                                                                                                          │                                                                                  │                                                   install the package maintainer's version                                                               │                                                                                  │                                                   keep the local version currently installed                                                             │                                                                                  │                                                   show the differences between the versions                                                              │                                                                                  │                                                   show a side-by-side difference between the versions                                                    │                                                                                  │                                                   show a 3-way difference between available versions                                                     │                                                                                  │                                                   do a 3-way merge between available versions                                                            │                                                                                  │                                                   start a new shell to examine the situation
# 保持当前版本即可,选择keep the local version currently installed# 选项4
Configuration file '/etc/security/limits.conf'==> Modified (by you or by a script) since installation.==> Package distributor has shipped an updated version.What would you like to do about it ?  Your options are:Y or I  : install the package maintainer's versionN or O  : keep your currently-installed versionD     : show the differences between the versionsZ     : start a shell to examine the situationThe default action is to keep your current version.
*** limits.conf (Y/I/N/O/D/Z) [default=N] ? # 输入N# 选项4 lxd版本选择
The LXD project puts out monthly feature releases which while backward compatible at an API and CLI level, will contain some behavior change and potentially require manual intervention during   │ │ an upgrade.                                                                                                                                                                                       │ │                                                                                                                                                                                                   │ │ In addition to those, every 2 years a LTS release is made which comes with 5 years of support through frequent bugfix-only releases.                                                              │ │                                                                                                                                                                                                   │ │ The LXD team recommends you pick "4.0" for production environments and use "latest" if you're interested in getting the latest LXD features.                                                      │ │                                                                                                                                                                                                   │ │ LXD snap track                                                                                                                                                                                    │ │                                                                                                                                                                                                   │ │                                                                                               3.0                                                                                                 │ │                                                                                               4.0                                        
选择4.0 长期支持版本

升级过程中出现的提示视情况选择即可

升级完毕,提示是否执行重启

8 installed packages are no longer supported by Canonical. You can
still get support from the community.26 packages are going to be removed. 222 new packages are going to be
installed. 1344 packages are going to be upgraded.You have to download a total of 1,223 M. This download will take
about 1 minute with your connection.Installing the upgrade can take several hours. Once the download has
finished, the process cannot be canceled.Continue [yN]  Details [d]System upgrade is complete.Restart requiredTo finish the upgrade, a restart is required.
If you select 'y' the system will be restarted.Continue [yN] y

卸载gnome桌面环境

apt remove --purge ubuntu-desktop gnome-shell gnome-session gdm3
apt remove --purge gnome* gnome-shell* gnome-session* gdm3* nautilus* ubuntu-gnome-desktop
apt autoremove --purge
apt autoclean
# 手动卸载未清理的gnome包
apt remove --purge 包名
# 卸载snap包管理工具安装的gnome工具
snap list
Name                  Version          Rev    Tracking         Publisher   Notes
bare                  1.0              5      latest/stable    canonical✓  base
core18                20240920         2846   latest/stable    canonical✓  base
core20                20240911         2434   latest/stable    canonical✓  base
core22                20241119         1722   latest/stable    canonical✓  base
gnome-3-34-1804       0+git.3556cb3    93     latest/stable/…  canonical✓  -
gnome-3-38-2004       0+git.efb213a    143    latest/stable/…  canonical✓  -
gnome-42-2204         0+git.510a601    176    latest/stable    canonical✓  -
gnome-calculator      45.0.2           955    latest/stable/…  canonical✓  -
gnome-characters      46.0             797    latest/stable/…  canonical✓  -
gnome-logs            45.0             123    latest/stable/…  canonical✓  -
gnome-system-monitor  45.0             186    latest/stable/…  canonical✓  -
gtk-common-themes     0.1-81-g442e511  1535   latest/stable/…  canonical✓  -
snapd                 2.66.1           23258  latest/stable    canonical✓  snapd
# 卸载
snap remove gnome-3-34-1804
snap remove gnome-3-38-2004
snap remove gnome-42-2204
snap remove gnome-calculator
snap remove gnome-characters
snap remove gnome-logs
snap remove gnome-system-monitor

取消grub参数

grep GRUB_CMDLINE_LINUX_DEFAULT /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT=""
update-grub
reboot

GPU节点升级日志

# 禁止升级和nvidia相关的包
root@k8s-gpu-node3:/etc/apt# apt update
Hit:1 http://cn.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://cn.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:3 http://cn.archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu bionic-security InRelease
Reading package lists... Done
Building dependency tree      
Reading state information... Done
61 packages can be upgraded. Run 'apt list --upgradable' to see them.
root@k8s-gpu-node3:/etc/apt# apt upgrade
Reading package lists... Done
Building dependency tree      
Reading state information... Done
Calculating upgrade... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:The following packages have unmet dependencies:libnvidia-compute-470 : Breaks: libnvidia-compute-470:i386 (!= 470.129.06-0ubuntu0.18.04.1) but 470.182.03-0ubuntu0.18.04.1 is to be installedlibnvidia-compute-470:i386 : Breaks: libnvidia-compute-470 (!= 470.182.03-0ubuntu0.18.04.1) but 470.129.06-0ubuntu0.18.04.1 is to be installedlibnvidia-decode-470 : Breaks: libnvidia-decode-470:i386 (!= 470.129.06-0ubuntu0.18.04.1) but 470.182.03-0ubuntu0.18.04.1 is to be installedlibnvidia-decode-470:i386 : Breaks: libnvidia-decode-470 (!= 470.182.03-0ubuntu0.18.04.1) but 470.129.06-0ubuntu0.18.04.1 is to be installedlibnvidia-encode-470 : Breaks: libnvidia-encode-470:i386 (!= 470.129.06-0ubuntu0.18.04.1) but 470.182.03-0ubuntu0.18.04.1 is to be installedlibnvidia-encode-470:i386 : Breaks: libnvidia-encode-470 (!= 470.182.03-0ubuntu0.18.04.1) but 470.129.06-0ubuntu0.18.04.1 is to be installedlibnvidia-fbc1-470 : Breaks: libnvidia-fbc1-470:i386 (!= 470.129.06-0ubuntu0.18.04.1) but 470.182.03-0ubuntu0.18.04.1 is to be installedlibnvidia-fbc1-470:i386 : Breaks: libnvidia-fbc1-470 (!= 470.182.03-0ubuntu0.18.04.1) but 470.129.06-0ubuntu0.18.04.1 is to be installedlibnvidia-gl-470 : Breaks: libnvidia-gl-470:i386 (!= 470.129.06-0ubuntu0.18.04.1) but 470.182.03-0ubuntu0.18.04.1 is to be installedlibnvidia-gl-470:i386 : Breaks: libnvidia-gl-470 (!= 470.182.03-0ubuntu0.18.04.1) but 470.129.06-0ubuntu0.18.04.1 is to be installedlibnvidia-ifr1-470 : Breaks: libnvidia-ifr1-470:i386 (!= 470.129.06-0ubuntu0.18.04.1) but 470.182.03-0ubuntu0.18.04.1 is to be installedlibnvidia-ifr1-470:i386 : Breaks: libnvidia-ifr1-470 (!= 470.182.03-0ubuntu0.18.04.1) but 470.129.06-0ubuntu0.18.04.1 is to be installed
E: Broken packagesroot@k8s-gpu-node3:/etc/apt# apt-mark hold libnvidia-compute-470 libnvidia-decode-470 libnvidia-encode-470 libnvidia-fbc1-470 libnvidia-gl-470 libnvidia-ifr1-470
root@k8s-gpu-node3:/etc/apt# apt-mark hold libnvidia-compute-470:i386 libnvidia-decode-470:i386 libnvidia-encode-470:i386 libnvidia-fbc1-470:i386 libnvidia-gl-470:i386 libnvidia-ifr1-470:i386
root@k8s-gpu-node3:/etc/apt# apt-mark showhold
apt upgrade -y

后面发现好像还是不能mark hold,还是需要将包升级完成才行

建议先卸载gnome桌面环境后再执行升级

reference

https://ubuntu.com/blog/how-to-upgrade-from-ubuntu-18-04-lts-to-20-04-lts-today


http://www.ppmy.cn/news/1561593.html

相关文章

【项目】多模态图文理解-GLM-Edge实战

【项目】多模态图文理解-GLM-Edge实战 (一)模型初体验(二)模型介绍(三)性能指标(1)高通(2)Intel (四)安装依赖(五&#xf…

混合专家模型 (MoE)笔记摘要

ref: https://huggingface.co/blog/zh/moe#%E4%BB%80%E4%B9%88%E6%98%AF%E6%B7%B7%E5%90%88%E4%B8%93%E5%AE%B6%E6%A8%A1%E5%9E%8B 简短总结 混合专家模型 (MoEs): 与稠密模型相比, 预训练速度更快 与具有相同参数数量的模型相比,具有更快的…

Spring Boot + Jasypt 实现application.yml 属性加密的快速示例

Jasypt(Java Simplified Encryption)是一个专为Java应用程序设计的开源加密库,旨在简化加密和解密流程,保护敏感数据如密码、API密钥等。 jasypt-spring-boot-starter允许开发者在Spring Boot应用中轻松地实现加密和解密功能。 本篇介绍使用 jasypt-spring-boot-starter 以…

用JAVA 源码角度看 客户端请求服务器流程中地址是域名情况下解析域名流程

1. 域名解析的入口点 getaddrinfo 或 getAllByName 方法:在底层,Java 使用 getaddrinfo(在 Unix-like 系统中)或类似的系统调用来解析域名。在 Java 的 InetAddress 类中,getAllByName 方法是解析域名的入口点之一。它…

private前端常见算法

1.数组 合并两个有序数组(简单-5) https://leetcode.cn/problems/merge-sorted-array/description/?envTypestudy-plan-v2&envIdtop-interview-150 移除元素(简单-4) https://leetcode.cn/problems/remove-element/descr…

【竞技宝】CS2:NertZ离队Liquid光速加盟!

2025年1月7日,目前CS2的赛事正处于空窗期中,很多队伍在近期都在进行阵容上的调整,其中出现了很多震惊观众的转会消息。今日凌晨,HEROIC官宣队内的NertZ选手正式离队,此后Liquid很快发布消息宣布了NertZ的加盟。 今日凌…

【Unity笔记】资源包导入后是洋红色(粉色)怎么办?

1.导入后发现是这样的 2.这个问题是渲染管道不匹配引起的。 导入的素材用的是 「通用渲染管线 Universal Render Pipeline, URP」,而项目里默认配置的是「内置渲染管线」,如图: 【知识补充】什么是渲染管线??&#x…

C语言实现杨辉三角教程

简介 杨辉三角(Pascal’s Triangle)是一种非常经典的数学问题,同时也是编程练习中常见的题目之一。它的特点是每行的两端数字为1,其他数字是它上一行相邻两数之和。 本篇博客将详细讲解杨辉三角的基本概念、构建原理&#xff0c…