Play with the Raspberry Pi 4. Modify the domestic source to improve the update speed

The package source of the Raspberry Pi is connected to the official source by default, and the speed is not very fast. We can replace it with a third-party source to improve the download speed and experience.

First, lsb_release -agetbullseye

pi@Rpi4B2G:/etc/apt $ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye

1. Back up source files

Run the command to back up the source files of the current system

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo cp /etc/apt/sources.list.d/raspi.list /etc/apt/sources.list.d/raspi.list.bak

2. Modify the source file

To edit sources.listthe file run the command:

sudo vi /etc/apt/sources.list

Replace the content of the file with the address of Tsinghua source:

deb [arch=armhf] http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ bullseye main non-free contrib rpi 
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ bullseye main non-free contrib rpi

Save and exit the editor.

To edit raspi.listthe file run the command:

sudo vi /etc/apt/sources.list.d/raspi.list

Delete all content and replace the content of the file with the address of Tsinghua source:

deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bullseye main

3. Update package cache

Run the command:

sudo apt update

This will update the package index file from the Tsinghua source, pull the package version information, and then install or uninstall the software will use the Tsinghua source.

Run the command:

sudo apt upgrade

This will pull the latest package information from Tsinghua source, check the version of the installed package in the system, and prompt to update the updateable package.

Through the above steps, we have successfully changed the software source of the Raspberry Pi bullseye system to Tsinghua source. At this time, the download speed of the software package will be very fast, and it can ensure higher connectivity in the domestic network environment. Better user experience.

4. Restore the software source

Just overwrite the backup sources.list.bakfile back to the original location, and then run sudo apt updateupdate cache.

Enter the command to delete the source file:

sudo rm /etc/apt/sources.list
sudo rm /etc/apt/sources.list.d/raspi.list

Enter the command to restore the backup source file:

sudo cp /etc/apt/sources.list.bak /etc/apt/sources.list
sudo cp /etc/apt/sources.list.d/raspi.list.bak /etc/apt/sources.list.d/raspi.list

5. Troubleshooting

In the process of updating the list, sometimes the following error will appear

pi@Rpi4B2G:/etc/apt $ sudo apt update
Get:1 https://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian bullseye InRelease [15.0 kB]               
Hit:2 http://archive.raspberrypi.org/debian bullseye InRelease                                          
Err:1 https://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian bullseye InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 9165938D90FDDD2E
Reading package lists... Done
W: GPG error: https://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian bullseye InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 9165938D90FDDD2E
E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian bullseye InRelease' is not signed.
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.

This error indicates that the signature of a software source cannot be verified because the public key for the corresponding software source is not available.

The solution is to import the public key of the software source.

We copy the public key number that appears above and try to import Ubuntu's Launchpad public key server

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9165938D90FDDD2E

After importing the public key, re-run sudo apt updateupdate package cache, and the error disappears.

Guess you like

Origin blog.csdn.net/no1xium/article/details/130322572