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

CentOS内核定制时/usr/src/linux目录不存在问题求助

Fixing "/usr/src/linux no such file or directory" Error When Compiling CentOS Kernel in VirtualBox

Hey there, let's troubleshoot this frustrating error together. You mentioned you can see the linux and linux-3.10.0-693.1.1.el7.x86_64 entries in /usr/src, but the system still throws a "no such file or directory" error when you try to compile the kernel. Here are the most likely fixes, ordered by how common they are:


First, let's check if the linux soft link actually points to the correct kernel source directory. Sometimes when creating links with relative paths or typos, the link can break even if it shows up in ls output.

Run this command to inspect the link:

ls -l /usr/src/linux

You should see output like this (the arrow points to your actual kernel source directory):

lrwxrwxrwx 1 root root 30 Aug 10 14:22 /usr/src/linux -> linux-3.10.0-693.1.1.el7.x86_64

Delete the old link and recreate it with absolute paths (this avoids relative path issues):

sudo rm /usr/src/linux
sudo ln -s /usr/src/linux-3.10.0-693.1.1.el7.x86_64 /usr/src/linux

2. Check the Kernel Source Directory Integrity

Even if the link looks good, the target directory might be missing critical files (like the Makefile or core source folders) if the RPM extraction failed silently.

Navigate to the source directory and verify key files exist:

cd /usr/src/linux-3.10.0-693.1.1.el7.x86_64
ls -l | grep -E "(Makefile|arch|include)"

You should see entries for Makefile, arch/, and include/. If any are missing, reinstall the kernel-devel RPM to fix the extraction:

sudo rpm -ivh --force kernel-devel-3.10.0-693.1.1.el7.x86_64.rpm

(Replace the RPM name with the exact one you downloaded earlier.)


3. Ensure You Have Proper Permissions

Compiling the kernel requires root-level access. If you're running commands as a regular user, you might not have permission to access /usr/src/linux even if it exists.

Switch to root first before running compile commands:

sudo su -
cd /usr/src/linux
# Now run your compile command, e.g.:
# make menuconfig
# make

Alternatively, prefix each compile command with sudo to inherit root permissions:

sudo make -C /usr/src/linux menuconfig

4. Rule Out SELinux Interference

CentOS uses SELinux by default, and sometimes it can block access to soft links or source directories even if file permissions look correct.

Temporarily disable SELinux to test if this is the issue:

sudo setenforce 0

Try accessing /usr/src/linux and running your compile command again. If it works, restore SELinux and fix the directory context permanently:

sudo setenforce 1
sudo restorecon -Rv /usr/src/linux

5. Double-Check Your Compile Command Path

Make sure you're using the correct absolute path in your compile command. For example, if you're running make from another directory, use the -C flag to specify the kernel source directory explicitly:

make -C /usr/src/linux

Instead of relying on a relative path that might point to the wrong location.


Most of the time, the issue boils down to a broken soft link or permission problem. Start with step 1, as that's the most common culprit.

内容的提问来源于stack exchange,提问作者Abdul Balogun

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.28 09:58:00