使用地理位置靠近的镜像源(如清华大学、中国科学技术大学)可显著提升下载速度。以清华大学镜像源为例,编辑/etc/apt/sources.list文件,替换为以下内容(以Debian 12 bookworm为例):
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
更新软件包列表:sudo apt update。
定期清理缓存可释放磁盘空间,避免旧缓存影响新软件包下载:
sudo apt cleansudo apt autocleansudo apt autoremovesudo apt autoremove --purge $(dpkg --list | grep linux-image | awk '{print $2}' | grep -v $(uname -r))。若处于网络受限环境(如公司内网),可通过代理服务器提升下载速度:
/etc/environment文件,添加以下内容(替换为代理服务器IP和端口):http_proxy="http://proxy_server_ip:proxy_server_port/"
https_proxy="https://proxy_server_ip:proxy_server_port/"
运行source /etc/environment使配置生效。/etc/apt/apt.conf文件,添加以下内容:Acquire::http::Proxy "http://proxy_server_ip:proxy_server_port/";
Acquire::https::Proxy "https://proxy_server_ip:proxy_server_port/";
修改内核参数可提升网络传输效率,减少下载延迟:
编辑/etc/sysctl.conf文件,添加以下内容:
net.core.rmem_max=16777216 # 增加接收缓冲区大小
net.core.wmem_max=16777216 # 增加发送缓冲区大小
net.ipv4.tcp_window_scaling=1 # 启用TCP窗口缩放
net.ipv4.tcp_sack=1 # 启用TCP选择性确认
应用配置:sudo sysctl -p。
-d选项指定缓存目录,避免重复下载:fetchdebian -d /path/to/cache package_namefetchdebian package1 package2 package3/etc/fetchdebian.conf文件,设置threads参数(如threads = 4),提升多线程下载速度。通过限制缓存大小,避免缓存占用过多磁盘空间:
编辑/etc/apt/apt.conf.d/95local文件(若不存在则创建),添加以下内容(限制缓存为500MB):
APT::Cache-Limit "500000000"; # 单位:字节。
通过多线程下载工具(如gopeed)加速软件包下载:
gopeed:sudo apt install gopeedgopeed后,将APT的下载链接复制到gopeed中,即可实现多线程加速。以上方法可根据实际网络环境和需求组合使用,显著提升FetchDebian的下载效率和体验。操作前建议备份重要数据,以防意外。