You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法通过apt安装内核源码以进行重建的求助

无法通过apt安装内核源码以进行重建的求助

Hey tiger, sorry to hear you're hitting this roadblock when trying to install the kernel source via apt—let's figure this out step by step!

先排查apt源的问题

The error E: Unable to locate package linux-source-5.19.0-32-generic usually pops up because either the required repository isn't enabled on your system, or the specific version's source package has been removed from the default apt repositories. Here's what you can try first:

  • Enable the universe repository (since kernel source packages live here for Ubuntu-based systems):
    sudo add-apt-repository universe
    sudo apt update
    
  • Try running your original install command again:
    sudo apt install linux-source-$(uname -r)
    

如果还是失败,直接从内核仓库获取源码

If the above doesn't work, you can grab the source code directly from the official kernel repository. Here's how:

  1. First, make sure you have Git installed (if not, install it):
    sudo apt install git
    
  2. Clone the stable kernel source repository:
    git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
    
  3. Navigate into the cloned directory and check out the exact version matching your kernel (your 5.19.0-32-generic corresponds to kernel tag v5.19.32):
    cd linux
    git checkout v5.19.32
    

想要带Ubuntu补丁的匹配源码?

If you need the exact source code with Ubuntu's custom patches (to ensure full compatibility with your system), you can use the apt-src tool:

  1. Install apt-src first:
    sudo apt install apt-src
    
  2. Use it to download and prepare the matching source package:
    apt-src install linux-source-$(uname -r)
    

This will automatically download the source tarball and apply all Ubuntu-specific patches for your kernel version.

额外提示

If you're only looking to rebuild kernel modules (not the entire kernel), you might just need the kernel headers instead—install them with sudo apt install linux-headers-$(uname -r). But since you mentioned rebuilding the kernel, the full source steps above should work for you.

备注:内容来源于stack exchange,提问作者dxyzhou-tiger

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 08:28:11