若“FetchDebian”指Debian系統軟件包下載性能優化(而非特定工具),可通過以下方法提升apt
/apt-get
的下載效率:
國內鏡像源(如清華大學、中國科學技術大學)的服務器更靠近國內用戶,能顯著提升下載速度。
/etc/apt/sources.list
文件,替換為國內鏡像源(以清華大學為例):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 clean
sudo apt autoclean
sudo apt autoremove
若處于網絡受限環境(如公司內網),可通過代理服務器提升下載速度。
/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/";
通過多線程下載工具(如gopeed
)可加速軟件包下載。
gopeed
:sudo apt install gopeed
gopeed
后,將apt
的下載鏈接復制到gopeed
中,即可實現多線程加速。修改內核參數可提升網絡傳輸效率,減少下載延遲。
/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
。舊內核版本會占用磁盤空間,且不會被apt
再次使用,刪除后可釋放空間。
uname -r
sudo apt autoremove --purge $(dpkg --list | grep linux-image | awk '{print $2}' | grep -v $(uname -r))
通過限制緩存大小,避免緩存占用過多磁盤空間。
/etc/apt/apt.conf.d/95local
文件(若不存在則創建),添加以下內容(限制緩存為500MB):APT::Cache-Limit "500000000"; # 單位:字節
以上方法均針對Debian系統軟件包下載性能優化,若“FetchDebian”為特定工具,建議參考其官方文檔獲取針對性優化方案。