“Ubuntu From Scratch(UFS)”或类似“Linux From Scratch(LFS)在 Ubuntu 上构建”出错的原因非常多,需要看具体报错才能精准解决。不过我可以先给你一套通用排查流程 + 常见错误及解决办法。
不同情况处理方式不同。
./your-build-command 2>&1 | tee build.log
然后搜索关键报错,例如:
command not foundpermission deniedconfigure: errorNo space left on deviceuname -a
gcc --version
make --version
bash --version
LFS 要求:
lfs 用户)df -h
构建过程很容易吃掉 10–20GB
configure: error: C compiler cannot create executables原因:
/proc /sys解决:
sudo apt install build-essential
chroot 前:
mount -v --bind /dev $LFS/dev
mount -v --bind /dev/pts $LFS/dev/pts
mount -v -t proc proc $LFS/proc
mount -v -t sysfs sysfs $LFS/sys
make: *** [Makefile:xx] Error 2通常是:
解决:
export CFLAGS="-std=gnu17"
chroot: failed to run command ‘/bin/bash’: No such file
原因:
bash解决:
ldd $LFS/bin/bash
确认动态库存在。
E: Unable to locate package
解决:
sudo apt install debootstrap
sudo debootstrap --arch=amd64 noble /mnt/ubuntu http://archive.ubuntu.com/ubuntu
请把以下信息发出来:
例如:
Ubuntu 22.04,LFS 11.3,在编译 binutils 时报
collect2: error: ld returned 1 exit status
我可以直接给你精确命令级别解决方案。