Administrator
发布于 2023-12-27 / 5 阅读
0

树莓派换源

树莓派换源

  1. 开启ssh

    sudo systemctl enable ssh
    sudo systemctl start ssh
    
  2. 查看系统架构

    uname -a
    

    Linux raspberrypi 6.1.0-rpi7-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.63-1+rpt1 (2023-11-24) aarch64 GNU/Linux
    raspbian | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

    aarch64直接选择 Debian

    image.png
    [debian | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

    ](https://mirrors.tuna.tsinghua.edu.cn/help/debian/)

  3. 查询系统版本

    lsb_release -a
    

    No LSB modules are available.
    Distributor ID: Debian
    Description: Debian GNU/Linux 12 (bookworm)
    Release: 12
    Codename: bookworm

  4. 替换源
    替换前的源

    $ sudo cat /etc/apt/sources.list
    deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
    deb http://deb.debian.org/debian-security/ bookworm-security main contrib non-free non-free-firmware
    deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
    # Uncomment deb-src lines below then 'apt-get update' to enable 'apt-get source'
    #deb-src http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
    #deb-src http://deb.debian.org/debian-security/ bookworm-security main contrib non-free non-free-firmware
    #deb-src http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
    
    $ cat /etc/apt/sources.list.d/raspi.list
    deb http://archive.raspberrypi.com/debian/ bookworm main
    # Uncomment line below then 'apt-get update' to enable 'apt-get source'
    #deb-src http://archive.raspberrypi.com/debian/ bookworm main
    

    执行替换源

    sudo sed -e 's|deb.debian.org|mirrors.tuna.tsinghua.edu.cn|g' -i.bak /etc/apt/sources.list
    
    sudo sed -e 's|archive.raspberrypi.com/debian|mirrors.tuna.tsinghua.edu.cn/raspberrypi|g' -i.bak /etc/apt/sources.list.d/raspi.list
    
  5. 更新

    sudo apt-get update
    
    sudo apt-get upgrade