前言
我在DigitalOcean的虛擬機器上有開兩台進行一些服務的部署與測試,除了包含該WordPress Blog之外,還有其他網站的測試等,近期有台VM是Ubuntu 18.04,該版本已經過了支援的日期有一陣子了,近期規劃要將該虛擬機器從18.04升級到22.04版本,在升級的過程中有遇到一些問題,因此特別寫了一篇文章進行問題的紀錄與對應的解決方法。
問題集錦
問題1
要將Ubuntu版本進行升級且不透過重新安裝的話,通常都會執行「do-release-upgrade」之指令進行,但是當在DigitalOcean之虛擬機器中執行前述的指令時,則會出現以下的錯誤訊息:
1 2 3 4 5 6 7 | After updating your package information, the essential package 'ubuntu-minimal' could not be located. This may be because you have no official mirrors listed in your software sources, or because of excessive load on the mirror you are using. See /etc/apt/sources .list for the current list of configured software sources. In the case of an overloaded mirror, you may want to try the upgrade again later. |
會出現前述的問題是因為,DigitalOcean預設是使用他們自家建置的Ubuntu鏡像網站,因此需要在執行「do-release-upgrade」時再加入「–allow-third-party」,允許升級時使用的套件來源可以是使用第三方的來源,這樣就可以順利的進行升級版本了。
問題2
當升級完成之後,執行「sudo apt-get update」時,會發現有些儲存給外部套件所需要的GPG金鑰會出現下列的訊息出來:
1 | Key is stored in legacy trusted.gpg keyring ( /etc/apt/trusted .gpg) |
或是出現類似下列的問題:
1 | W: https: //apt .releases.hashicorp.com /dists/jammy/InRelease : Key is stored in legacy trusted.gpg keyring ( /etc/apt/trusted .gpg), see the DEPRECATION section in apt-key(8) for details. |
要解決上述的問題,則需要使用「sudo apt-key list」找到有問題的key名稱,並將該key透過執行「gpg」指令轉移到「/etc/apt/trusted.gpg.d」之目錄底下。
下列以hashicorp套件之GPG金鑰進行轉移的範例指令如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | $ sudo apt-key list Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)). /etc/apt/trusted .gpg -------------------- pub rsa4096 2023-01-10 [SC] [expires: 2028-01-09] 798A EC65 4E5C 1542 8C8E 42EE AA16 FCBC A621 E701 uid [ unknown] HashiCorp Security (HashiCorp Package Signing) <security+packaging@hashicorp.com> sub rsa4096 2023-01-10 [S] [expires: 2028-01-09] /etc/apt/trusted .gpg.d /ubuntu-keyring-2012-cdimage .gpg ------------------------------------------------------ pub rsa4096 2012-05-11 [SC] 8439 38DF 228D 22F7 B374 2BC0 D94A A3F0 EFE2 1092 uid [ unknown] Ubuntu CD Image Automatic Signing Key (2012) <cdimage@ubuntu.com> /etc/apt/trusted .gpg.d /ubuntu-keyring-2018-archive .gpg ------------------------------------------------------ pub rsa4096 2018-09-17 [SC] F6EC B376 2474 EDA9 D21B 7022 8719 20D1 991B C93C uid [ unknown] Ubuntu Archive Automatic Signing Key (2018) <ftpmaster@ubuntu.com> $ sudo apt-key export A621E701 | sudo gpg --dearmour -o /etc/apt/trusted .gpg.d /hashicorp .gpg |
上述完成之後,之後執行「sudo apt-get update」就不會再跳出上述的GPG金鑰警告訊息了。
參考資料
- do-release-upgrade指令相關的參考,https://www.digitalocean.com/community/questions/the-essential-package-ubuntu-minimal-could-not-be-located
- 與GPG金鑰轉移相關的指令參考,https://blog.clarence.tw/2023/05/28/%E5%9C%A8-ubuntu-%E5%87%BA%E7%8F%BE-key-is-stored-in-legacy-trusted-gpg-keyring-etc-apt-trusted-gpg-%E7%9A%84%E8%A7%A3%E6%B1%BA%E6%96%B9%E6%B3%95%E4%BB%A5-hashicrop-%E7%82%BA%E4%BE%8B/