• ubuntu从1804LTS升级至2004LTS


    [生命周期]
    1804 LTS -> 2023年4月
    2004 LTS -> 2025年4月
    2204 -> 2027年4月

    [升级路径]
    1804 -> 2004 -> 2204

    鉴于2204还不是LTS,因此本次没有直接升级到此版本。

    [升级步骤]

    1. 备份
    • 快照备份 -> 防止升级完成无法启动内核;
    • 应用与数据备份 -> 防止组件升级不兼容现有配置,可能要做配置调整;
    1. 检查版本信息
    cat /etc/os-release
    NAME="Ubuntu"
    VERSION="18.04.6 LTS (Bionic Beaver)"
    ID=ubuntu
    ID_LIKE=debian
    PRETTY_NAME="Ubuntu 18.04.6 LTS"
    VERSION_ID="18.04"
    HOME_URL="https://www.ubuntu.com/"
    SUPPORT_URL="https://help.ubuntu.com/"
    BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
    PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
    VERSION_CODENAME=bionic
    UBUNTU_CODENAME=bionic
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    1. 更新软件
    sudo apt update
    sudo apt upgrade -y
    sudo apt dist-upgrade
    
    • 1
    • 2
    • 3

    A. 移除任何被自动安装的,但是不再被任何包所依赖的软件包:
    sudo apt --purge autoremove
    ※ 我比较懒,一般不操作此步骤…

    1. 安装update-manager-core
    sudo apt install update-manager-core
    
    • 1

    A. do-release-upgrade是update-manager-core软件包的一部分,没有就手工执行一下吧。

    1. 升级内核
    sudo do-release-upgrade -d
    
    • 1

    A. 如果没有执行步骤3,可能会遇到如下提示:
    Checking for a new Ubuntu release
    Please install all available updates for your release before upgrading.
    B. 如下提示后,可以执行步骤6
    Checking for a new Ubuntu release
    You have not rebooted after updating a package which requires a reboot. Please reboot before upgrading.

    1. 重启生效
    sudo reboot
    
    • 1
    1. 再次升级内核
    sudo do-release-upgrade -d
    
    System upgrade is complete.
    
    Restart required
    
    To finish the upgrade, a restart is required.
    If you select 'y' the system will be restarted.
    
    Continue [yN] y
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    A. 过程期间,将需要针对提示进行操作。正常来说,确认回车即可;
    B. 可能会遇到ubuntu源无法升级的情况,请更换国内其它的源。
    #备份源
    sudo cp -a /etc/apt/sources.list /etc/apt/sources.list.bak
    #切换阿里云源
    sudo vi sources.list
    :%d 删除所有内容并替换如下内容
    deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    #更新资源文件
    sudo apt-get update

    1. 检查版本信息
    cat /etc/os-release
    ----
    NAME="Ubuntu"
    VERSION="20.04.5 LTS (Focal Fossa)"
    ID=ubuntu
    ID_LIKE=debian
    PRETTY_NAME="Ubuntu 20.04.5 LTS"
    VERSION_ID="20.04"
    HOME_URL="https://www.ubuntu.com/"
    SUPPORT_URL="https://help.ubuntu.com/"
    BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
    PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
    VERSION_CODENAME=focal
    UBUNTU_CODENAME=focal
    ----
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    [风险预判]

    1. ssh密钥失效
      公有云控制台通过VNC方式访问ubuntu console配置ssh并重置密码访问,远程访问重置ssh公钥进行免密登录。
      sudo nano /etc/ssh/sshd_config
      [+] PasswordAuthentication yes
    2. Apache/PHP/Tomcat无法启动
      如果没有什么特殊的配置,可以卸载重装解决。如果有非常多的自定义配置,那么就需要依据实际配置检查参数的兼容性。
  • 相关阅读:
    【网络编程】网络基础
    rabbitmq 交换机相关实例代码
    shell原理
    常见的排序算法的时间复杂度
    新手做独立站需要掌握哪些技能
    Ftp连接显示connection refused问题的解决
    组件库自定义主题换肤实现方案
    DJ13-1 汇编语言程序设计-1
    【无标题】
    Linux第一次作业
  • 原文地址:https://blog.csdn.net/weixin_38623994/article/details/127709248