Fix The repository no longer has a Release file on Ubuntu

Table of Contents

Fix The repository no longer has a Release file on Ubuntu

Xử lý lỗi The repository no longer has a Release file trên Ubuntu

https://azdigi.com/blog/linux-server/the-repository-no-longer-has-a-release-file/


I. Giới thiệu và nguyên nhân

Trong quá trình sử dụng hệ điều hành Ubuntu thì chắc chắn ai trong chúng ta cũng sẽ tự dụng lệnh apt-get update để cập nhật hệ điều hành Ubuntu.

Nhưng bỗng một ngày bạn sử dụng lệnh này và gặp lỗi như sau:

root@labbao:~# apt-get update
Ign:1 http://us.archive.ubuntu.com/ubuntu cosmic InRelease
Ign:2 http://security.ubuntu.com/ubuntu cosmic-security InRelease
Ign:3 http://us.archive.ubuntu.com/ubuntu cosmic-updates InRelease
Err:4 http://security.ubuntu.com/ubuntu cosmic-security Release
  404  Not Found [IP: 91.189.91.39 80]
Ign:5 http://us.archive.ubuntu.com/ubuntu cosmic-backports InRelease
Err:6 http://us.archive.ubuntu.com/ubuntu cosmic Release
  404  Not Found [IP: 91.189.91.39 80]
Err:7 http://us.archive.ubuntu.com/ubuntu cosmic-updates Release
  404  Not Found [IP: 91.189.91.39 80]
Err:8 http://us.archive.ubuntu.com/ubuntu cosmic-backports Release
  404  Not Found [IP: 91.189.91.39 80]
Reading package lists... Done
E: The repository 'http://security.ubuntu.com/ubuntu cosmic-security Release' no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://us.archive.ubuntu.com/ubuntu cosmic Release' no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://us.archive.ubuntu.com/ubuntu cosmic-updates Release' no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://us.archive.ubuntu.com/ubuntu cosmic-backports Release' no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

Dưới đây là hình ảnh cho các bạn dễ hình dung hơn.

The repository no longer has a Release file - Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Lỗi The repository no longer has a Release file trên Ubuntu 18.

Thì nguyên nhân dẫn đến lỗi này rất đơn giản là do các bản phát hành cũ hơn của Ubuntu được chuyển đến một máy chủ lưu trữ mới, vì vậy bạn cần cập nhật danh sách repo của mình theo máy chủ mới thì mọi thứ mới hoạt động được trở lại. Và lỗi này mình từng gặp trên Ubuntu 18.10.

Ngoài ra bài hướng dẫn này cũng giúp khắc phục luôn lỗi sau khi bạn cài mới một phần mềm trên Ubuntu:

Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

II. Xử lý lỗi The repository no longer has a Release file trên Ubuntu

Để xử lý lỗi The repository no longer has a Release file trên Ubuntu chúng ta sẽ đi qua 2 bước.

Bước 1: SSH vào máy chủ Ubuntu của bạn

Để xử lý lỗi The repository no longer has a Release file trên Ubuntu việc đầu tiên chúng ta cần làm là SSH hoặc truy cập VPS hoặc máy chủ của bạn với quyền root trước.

Sau khi đã SSH thành công chúng ta tiếp tục với bước 2 để thực hiện một số lệnh khắc phục lỗi này.

Bước 2: Các lệnh xử lý lỗi The repository no longer has a Release file trên Ubuntu

Chúng ta sẽ sử dụng 3 lệnh sau để khắc phục được lỗi này:

# cp /etc/apt/sources.list /etc/apt/sources.list.bak
# sudo sed -i -re 's/([a-z]{2}.)?archive.ubuntu.com|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
# sudo apt-get update && sudo apt-get dist-upgrade

Giải thích 3 lệnh trên:

  • Lệnh 1: Sao lưu tệp tin sources.list hiện tại trên máy chủ.
  • Lệnh 2: Thay thế các liên kết bằng địa chỉ kho lưu trữ mới.
  • Lệnh 3: Chạy cập nhật lại sau khi thực hiện hai lệnh trên.

Dưới đây là hình ảnh quá trình thực hiện của mình.

The repository no longer has a Release file - Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Thực hiện lệnh 1, 2, 3.

The repository no longer has a Release file - Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Khi thực hiện lệnh 3, bạn sẽ thấy lệnh này không còn gặp lỗi nữa.

Đến đây khi bạn thấy lệnh 3 đã chạy thành công thì bạn hoàn toàn có thể chọn Y để tiếp tục quá trình cập nhật cho máy chủ Ubuntu của mình. Hoặc chọn N để hủy quá trình cập nhật.

Và một khi lệnh 3 đã chạy bình thường thì vấn đề "The repository no longer has a Release file" của chúng ta cũng đã được giải quyết xong.

III. Tổng kết

Ở thời điểm hiện tại Ubuntu 18 cũng là một phiên bản Ubuntu đã lỗi thời rồi nên nếu được các bạn hãy cân nhắc chuyển dần sang sử dụng Ubuntu 20 thì sẽ ổn hơn rất nhiều và cũng sẽ tránh được những lỗi vặt như thế này.

Hy vọng bài viết này sẽ giúp ích cho các bạn. Chúc các bạn thực hiện thành công.

Leave a Reply

Your email address will not be published. Required fields are marked *