无法更新 Raspberry PI(apt-get)

无法更新 Raspberry PI(apt-get)

我无法再更新我的 Raspberry PI(带有 Raspbian Stretch 的 Raspberry PI 1 Model B)。sudo apt-get update告诉我包文件存在一些问题。我不太了解 apt-get 及其工作原理,所以我无法提供更多信息。

这是我之前尝试过的:

pi@raspberrypi:~ $ sudo apt-get update
Get:1 http://archive.raspberrypi.org/debian stretch InRelease [25.4 kB]
Get:2 http://mirrordirector.raspbian.org/raspbian buster InRelease [15.0 kB]
Get:3 http://raspbian.raspberrypi.org/raspbian stretch InRelease [15.0 kB]             
Get:4 http://mirrordirector.raspbian.org/raspbian buster/main armhf Packages [13.0 MB]                
Get:5 http://raspbian.raspberrypi.org/raspbian stretch/main armhf Packages [11.7 MB]                         
Get:6 http://mirrordirector.raspbian.org/raspbian buster/contrib armhf Packages [59.1 kB]                    
Get:7 http://archive.raspberrypi.org/debian stretch/main armhf Packages [223 kB]                             
Get:8 http://archive.raspberrypi.org/debian stretch/ui armhf Packages [45.0 kB]                              
Get:9 http://raspbian.raspberrypi.org/raspbian stretch/non-free armhf Packages [95.5 kB]                     
Fetched 25.1 MB in 1min 6s (376 kB/s)                                                                        
Reading package lists... Error!
E: Encountered a section with no Package: header
E: Problem with MergeList /var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_buster_non-free_binary-armhf_Packages
E: The package lists or status file could not be parsed or opened.
pi@raspberrypi:~ $ sudo rm /var/lib/apt/lists/* -vf
removed '/var/lib/apt/lists/archive.raspberrypi.org_debian_dists_stretch_InRelease'
removed '/var/lib/apt/lists/archive.raspberrypi.org_debian_dists_stretch_main_binary-armhf_Packages'
removed '/var/lib/apt/lists/archive.raspberrypi.org_debian_dists_stretch_ui_binary-armhf_Packages'
removed '/var/lib/apt/lists/lock'
removed '/var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_buster_contrib_binary-armhf_Packages'
removed '/var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_buster_InRelease'
removed '/var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_buster_main_binary-armhf_Packages'
removed '/var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_buster_non-free_binary-armhf_Packages'
removed '/var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_buster_rpi_binary-armhf_Packages'
rm: cannot remove '/var/lib/apt/lists/partial': Is a directory
removed '/var/lib/apt/lists/raspbian.raspberrypi.org_raspbian_dists_stretch_contrib_binary-armhf_Packages'
removed '/var/lib/apt/lists/raspbian.raspberrypi.org_raspbian_dists_stretch_InRelease'
removed '/var/lib/apt/lists/raspbian.raspberrypi.org_raspbian_dists_stretch_main_binary-armhf_Packages'
removed '/var/lib/apt/lists/raspbian.raspberrypi.org_raspbian_dists_stretch_non-free_binary-armhf_Packages'
removed '/var/lib/apt/lists/raspbian.raspberrypi.org_raspbian_dists_stretch_rpi_binary-armhf_Packages'
pi@raspberrypi:~ $ sudo apt-get update
Get:1 http://mirrordirector.raspbian.org/raspbian buster InRelease [15.0 kB]
Get:2 http://raspbian.raspberrypi.org/raspbian stretch InRelease [15.0 kB] 
Get:3 http://archive.raspberrypi.org/debian stretch InRelease [25.4 kB]                      
Get:4 http://mirrordirector.raspbian.org/raspbian buster/main armhf Packages [13.0 MB]                
Get:5 http://raspbian.raspberrypi.org/raspbian stretch/main armhf Packages [11.7 MB]                         
Get:6 http://mirrordirector.raspbian.org/raspbian buster/contrib armhf Packages [59.1 kB]                    
Get:7 http://mirrordirector.raspbian.org/raspbian buster/non-free armhf Packages [103 kB]                    
Get:8 http://mirrordirector.raspbian.org/raspbian buster/rpi armhf Packages [1,360 B]                        
Get:9 http://archive.raspberrypi.org/debian stretch/main armhf Packages [223 kB]                             
Get:10 http://archive.raspberrypi.org/debian stretch/ui armhf Packages [45.0 kB]                             
Get:11 http://raspbian.raspberrypi.org/raspbian stretch/contrib armhf Packages [56.9 kB]                     
Get:12 http://raspbian.raspberrypi.org/raspbian stretch/non-free armhf Packages [95.5 kB]                    
Get:13 http://raspbian.raspberrypi.org/raspbian stretch/rpi armhf Packages [1,360 B]                         
Fetched 25.3 MB in 1min 5s (384 kB/s)                                                                        
Reading package lists... Error!
E: Unable to parse package file /var/lib/dpkg/status (1)
W: You may want to run apt-get update to correct these problems
E: The package cache file is corrupted

当然,我尝试sudo apt-get update再次运行,但仍然出现同样的错误。

以下是关于我的源列表的一些附加信息。也许这会有所帮助:

pi@raspberrypi:~ $ sudo cat /etc/apt/sources.list
deb http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi
pi@raspberrypi:~ $ sudo ls /etc/apt/
apt.conf.d  listchanges.conf  preferences.d  sources.list  sources.list.d  trusted.gpg  trusted.gpg.d
pi@raspberrypi:~ $ sudo ls /etc/apt/sources.list.d/
10-buster.list  raspi.list
pi@raspberrypi:~ $ sudo cat /etc/apt/sources.list.d/10-buster.list 
deb http://mirrordirector.raspbian.org/raspbian/ buster main contrib non-free rpi

pi@raspberrypi:~ $ sudo cat /etc/apt/sources.list.d/raspi.list 
deb http://archive.raspberrypi.org/debian/ stretch main ui
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://archive.raspberrypi.org/debian/ stretch main ui

更新:我做了什么评论#2建议。不幸的是,这没有帮助 :( 以下是输出:

pi@raspberrypi:~ $ cd /var/lib/apt
pi@raspberrypi:/var/lib/apt $ sudo mv lists lists.old
pi@raspberrypi:/var/lib/apt $ sudo mkdir -p /var/lib/apt/lists/partial

pi@raspberrypi:/var/lib/apt $ sudo apt-get update
Get:1 http://mirrordirector.raspbian.org/raspbian buster InRelease [15.0 kB]
Get:2 http://raspbian.raspberrypi.org/raspbian stretch InRelease [15.0 kB] 
Get:3 http://archive.raspberrypi.org/debian stretch InRelease [25.4 kB]                 
Get:4 http://mirrordirector.raspbian.org/raspbian buster/main armhf Packages [13.0 MB]                
Get:5 http://raspbian.raspberrypi.org/raspbian stretch/main armhf Packages [11.7 MB]                                                     
Get:6 http://mirrordirector.raspbian.org/raspbian buster/contrib armhf Packages [59.1 kB]                                                
Get:7 http://mirrordirector.raspbian.org/raspbian buster/non-free armhf Packages [103 kB]                                                
Get:8 http://mirrordirector.raspbian.org/raspbian buster/rpi armhf Packages [1,360 B]                                                    
Get:9 http://archive.raspberrypi.org/debian stretch/main armhf Packages [223 kB]                                                         
Get:10 http://archive.raspberrypi.org/debian stretch/ui armhf Packages [45.0 kB]                                                         
Err:10 http://archive.raspberrypi.org/debian stretch/ui armhf Packages                                                                   
  Hash Sum mismatch
  Hashes of expected file:
   - Filesize:44957 [weak]
   - SHA256:8cae70e2e6b9edf4dcdaa5698f0b19478f9de69e29c9600308f46cf3e0045e2e
   - SHA1:ea81522b950027496c2ced0eb2ff6ede2e75f897 [weak]
   - MD5Sum:ae6ca9fe1a5cca877cae33de122ababe [weak]
  Hashes of received file:
   - SHA256:bc3e0c2522623b50e36251cea08e80cd876aae57b83c83aab83183b54155311c
   - SHA1:14b504b069e7d4404c8cb41eebd73c2702918116 [weak]
   - MD5Sum:d1929e4454bbbb207ae70e00d0fd54cd [weak]
   - Filesize:44949 [weak]
  Last modification reported: Fri, 26 Apr 2019 20:49:31 +0000
  Release file created at: Mon, 29 Apr 2019 12:36:11 +0000
Get:11 http://raspbian.raspberrypi.org/raspbian stretch/contrib armhf Packages [56.9 kB]                                                 
Get:12 http://raspbian.raspberrypi.org/raspbian stretch/non-free armhf Packages [95.5 kB]                                                
Get:13 http://raspbian.raspberrypi.org/raspbian stretch/rpi armhf Packages [1,360 B]                                                     
Fetched 25.3 MB in 1min 3s (401 kB/s)                                                                                                    
Reading package lists... Done
E: Failed to fetch http://archive.raspberrypi.org/debian/dists/stretch/ui/binary-armhf/Packages.gz  Hash Sum mismatch
   Hashes of expected file:
    - Filesize:44957 [weak]
    - SHA256:8cae70e2e6b9edf4dcdaa5698f0b19478f9de69e29c9600308f46cf3e0045e2e
    - SHA1:ea81522b950027496c2ced0eb2ff6ede2e75f897 [weak]
    - MD5Sum:ae6ca9fe1a5cca877cae33de122ababe [weak]
   Hashes of received file:
    - SHA256:bc3e0c2522623b50e36251cea08e80cd876aae57b83c83aab83183b54155311c
    - SHA1:14b504b069e7d4404c8cb41eebd73c2702918116 [weak]
    - MD5Sum:d1929e4454bbbb207ae70e00d0fd54cd [weak]
    - Filesize:44949 [weak]
   Last modification reported: Fri, 26 Apr 2019 20:49:31 +0000
   Release file created at: Mon, 29 Apr 2019 12:36:11 +0000
E: Some index files failed to download. They have been ignored, or old ones used instead.

pi@raspberrypi:/var/lib/apt $ ls -al /var/lib/dpkg/status*
-rw-r--r-- 1 root root 535604 Feb 24 10:04 /var/lib/dpkg/status
-rw-r--r-- 1 root root 536580 Feb 24 10:00 /var/lib/dpkg/status-old
pi@raspberrypi:/var/lib/apt $ ls -al /var/backups/dpkg.status.*
-rw-r--r-- 1 root root 535604 Feb 24 10:04 /var/backups/dpkg.status.0
-rw-r--r-- 1 root root 161528 Feb 24 10:04 /var/backups/dpkg.status.1.gz
-rw-r--r-- 1 root root 161528 Feb 24 10:04 /var/backups/dpkg.status.2.gz
-rw-r--r-- 1 root root 161528 Feb 24 10:04 /var/backups/dpkg.status.3.gz
-rw-r--r-- 1 root root 161528 Feb 24 10:04 /var/backups/dpkg.status.4.gz
-rw-r--r-- 1 root root 161528 Feb 24 10:04 /var/backups/dpkg.status.5.gz
-rw-r--r-- 1 root root 161528 Feb 24 10:04 /var/backups/dpkg.status.6.gz

pi@raspberrypi:/var/lib/apt $ sudo apt-get update
Hit:1 http://mirrordirector.raspbian.org/raspbian buster InRelease
Hit:2 http://raspbian.raspberrypi.org/raspbian stretch InRelease
Get:3 http://archive.raspberrypi.org/debian stretch InRelease [25.4 kB]
Get:4 http://archive.raspberrypi.org/debian stretch/main armhf Packages [223 kB]
Get:5 http://archive.raspberrypi.org/debian stretch/ui armhf Packages [45.0 kB]
Fetched 293 kB in 5s (52.6 kB/s)                      
Reading package lists... Error!
E: Encountered a section with no Package: header
E: Problem with MergeList /var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_buster_main_binary-armhf_Packages
E: The package lists or status file could not be parsed or opened.
pi@raspberrypi:/var/lib/apt $ sudo apt-get upgrade
Reading package lists... Error!
E: Encountered a section with no Package: header
E: Problem with MergeList /var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_buster_main_binary-armhf_Packages
E: The package lists or status file could not be parsed or opened.
pi@raspberrypi:/var/lib/apt $ 

答案1

您需要做的就是在终端中输入以下命令

sudo rm -r /var/lib/apt/lists/*

之后运行以下命令

sudo apt-get clean && sudo apt-get update

您应该发现这将修复所有包装问题和合并列表错误

答案2

我发现 SD 卡坏了。我甚至无法重新格式化它。使用 unixdd命令写入零也不起作用。所以我买了一张新的 SD 卡 ;)

相关内容