首页
升级搬瓦工vps的ubuntu版本

升级步骤

  1. 更新系统软件

    root@koomu:~# apt-get update 
    root@koomu:~# apt-get upgrade -y 
    root@koomu:~# apt-get dist-upgrade
    
  2. 移除不必要软件

    root@koomu:~# apt-get autoremove
    
  3. 安装更新管理器

    root@koomu:~# apt-get install update-manager-core
    
  4. 更新系统

    注意,不要ssh登录执行,使用vnc来操作。

    root@koomu:~# do-release-upgrade
    
  5. 我的系统是16.04的,执行完是升级到18.04,如果要升级到20.04就再重复一遍上面的步骤即可。

遇到的问题

  1. do-release-upgrade 执行一半提示 /boot 空间不足,没办法清理boot空间,删多余的内核吧。

    • 查看当前系统使用的内核

      root@koomu:~# uname -a
      Linux koomu.cn 4.15.0-142-generic #146~16.04.1-Ubuntu SMP Tue Apr 13 09:27:15 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
      
    • 查看安装的内核

      root@koomu:~# dpkg --get-selections |grep linux-image|grep -v deinstall
      linux-image-4.15.0-139-generic			install
      linux-image-4.15.0-140-generic			install
      linux-image-4.15.0-142-generic			install
      linux-image-generic-hwe-16.04			install
      
    • 删除旧内核

      root@koomu:~# apt-get remove linux-image-4.15.0-139-generic linux-image-4.15.0-140-generic linux-image-generic-hwe-16.04
      
    • 清理无用包

      root@koomu:~# apt-get autoremove
      

    等空间释放后,再次执行更新命令即可。

  2. 中间过程会有选择提示,比如是否要保留现有配置啥的,一定要保留啊,要不就等着重新配置现有的服务啥的吧。

  3. 从16.04升级后DNS失效问题

    Ubuntu20.04 LTS 版本安装之后网络管理方式变了,导致原来设置的DNS失效。

    • 首先修改 /etc/systemd/resolved.conf

      root@koomu:~# cat /etc/systemd/resolved.conf
      #  This file is part of systemd.
      #
      #  systemd is free software; you can redistribute it and/or modify it
      #  under the terms of the GNU Lesser General Public License as published by
      #  the Free Software Foundation; either version 2.1 of the License, or
      #  (at your option) any later version.
      #
      # Entries in this file show the compile time defaults.
      # You can change settings by editing this file.
      # Defaults can be restored by simply deleting this file.
      #
      # See resolved.conf(5) for details
      
      [Resolve]
      DNS=8.8.8.8 8.8.4.4
      #FallbackDNS=
      #Domains=
      #LLMNR=no
      #MulticastDNS=no
      #DNSSEC=no
      #DNSOverTLS=no
      #Cache=no-negative
      #DNSStubListener=yes
      #ReadEtcHosts=yes
      
    • 以root身份执行

      root@koomu:~# systemctl restart systemd-resolved
      root@koomu:~# systemctl enable systemd-resolved
      root@koomu:~# mv /etc/resolv.conf  /etc/resolv.conf.bak
      root@koomu:~# ln -s /run/systemd/resolve/resolv.conf /etc/