When running the FreePBX Sangoma OS distro inside a VirtualBox virtual machine, installing VirtualBox Guest Additions fails with "Kernel headers not found for target kernel" even after installing kernel-devel and kernel-headers via yum.
Root Cause: In FreePBX Sangoma OS installations, the build directory symlink
/lib/modules/$(uname -r)/build is missing from the active kernel directory.
The 1-Line Fix
Create the missing build symlink pointing to the kernel source directory:
# 1. Install development packages
yum install dkms gcc kernel-devel kernel-headers -y
# 2. Fix the missing module build symlink
ln -s /usr/src/kernels/$(uname -r) /lib/modules/$(uname -r)/build
# 3. Mount and build Guest Additions
mount /dev/cdrom /media/cdrom
cd /media/cdrom
./VBoxLinuxAdditions.run
The kernel module compilation will complete cleanly, enabling dynamic display resizing and shared folders.