LFS: http://www.linuxfromscratch.org/lfs/
Chinese Book: 中文翻譯版
宿主系統(tǒng)需求
Host OS: Ubuntu 20.04
root
$ sudo passwd root
New password:
Retype new password:
passwd: password updated successfully
$ su - root
#
- Bash-3.2 (/bin/sh 必須是到 bash 的符號(hào)鏈接或硬連接)
# ls -l /bin/sh
lrwxrwxrwx 1 root root 4 9月 2 21:13 /bin/sh -> dash
# rm /bin/sh
# ln -s /bin/bash /bin/sh
# ls -l /bin/sh
lrwxrwxrwx 1 root root 9 9月 3 10:50 /bin/sh -> /bin/bash
Binutils-2.25 (比 2.35 更新的版本未經(jīng)測(cè)試,不推薦使用)
Bison-2.7 (/usr/bin/yacc 必須是到 bison 的鏈接肉盹,或者是一個(gè)執(zhí)行 bison 的小腳本)
Bison-2.7 (/usr/bin/yacc 必須是到 bison 的鏈接,或者是一個(gè)執(zhí)行 bison 的小腳本)
Coreutils-6.9
Diffutils-2.8.1
Findutils-4.2.31
Gawk-4.0.1 (/usr/bin/awk 必須是到 gawk 的鏈接)
GCC-6.2 包括 C++ 編譯器, g++ (比 10.2.0 更新的版本未經(jīng)測(cè)試逛绵,不推薦使用)
Glibc-2.11 (比 2.32 更新的版本未經(jīng)測(cè)試,不推薦使用)
Grep-2.5.1a
Gzip-1.3.12
-
Linux Kernel-3.2
內(nèi)核版本的要求是為了符合第 6 章中編譯 glibc 時(shí)開(kāi)發(fā)者推薦的配置選項(xiàng)倔韭。udev 也要求一定的內(nèi)核版本术浪。
如果宿主內(nèi)核比 3.2 更早,您需要將內(nèi)核升級(jí)到較新的版本寿酌。升級(jí)內(nèi)核有兩種方法胰苏,如果您的發(fā)行版供應(yīng)商提供了 3.2 或更新的內(nèi)核軟件包,您可以直接安裝它醇疼。如果供應(yīng)商沒(méi)有提供一個(gè)足夠新的內(nèi)核包硕并,或者您不想安裝它法焰,您可以自己編譯內(nèi)核。編譯內(nèi)核和配置啟動(dòng)引導(dǎo)器 (假設(shè)宿主使用 GRUB) 的步驟在第 10 章中倔毙。
M4-1.4.10
Make-4.0
Patch-2.5.4
Perl-5.8.8
Python-3.4
Sed-4.1.5
Tar-1.22
Texinfo-4.7
Xz-5.0.0
cat version-check.sh
#!/bin/bash
# Simple script to list version numbers of critical development tools
export LC_ALL=C
bash --version | head -n1 | cut -d" " -f2-4
MYSH=$(readlink -f /bin/sh)
echo "/bin/sh -> $MYSH"
echo $MYSH | grep -q bash || echo "ERROR: /bin/sh does not point to bash"
unset MYSH
echo -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3-
bison --version | head -n1
if [ -h /usr/bin/yacc ]; then
echo "/usr/bin/yacc -> `readlink -f /usr/bin/yacc`";
elif [ -x /usr/bin/yacc ]; then
echo yacc is `/usr/bin/yacc --version | head -n1`
else
echo "yacc not found"
fi
bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f1,6-
echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2
diff --version | head -n1
find --version | head -n1
gawk --version | head -n1
if [ -h /usr/bin/awk ]; then
echo "/usr/bin/awk -> `readlink -f /usr/bin/awk`";
elif [ -x /usr/bin/awk ]; then
echo awk is `/usr/bin/awk --version | head -n1`
else
echo "awk not found"
fi
gcc --version | head -n1
g++ --version | head -n1
ldd --version | head -n1 | cut -d" " -f2- # glibc version
grep --version | head -n1
gzip --version | head -n1
cat /proc/version
m4 --version | head -n1
make --version | head -n1
patch --version | head -n1
echo Perl `perl -V:version`
python3 --version
sed --version | head -n1
tar --version | head -n1
makeinfo --version | head -n1 # texinfo version
xz --version | head -n1
echo 'int main(){}' > dummy.c && g++ -o dummy dummy.c
if [ -x dummy ]
then echo "g++ compilation OK";
else echo "g++ compilation failed"; fi
rm -f dummy.c dummy
bash bash version-check.sh
分區(qū) GPT
sudo cfdisk
Device | Size | Type | Mount |
---|---|---|---|
/dev/sda1 | 100M | ext2 | /boot |
/dev/sda2 | 4G | swap | - |
/dev/sda3 | 35.9G | ext4 | / |
mkfs -v -t ext2 /dev/sda1
mkswap /dev/sda2
swapon /dev/sda2
mkfs -v -t ext4 /dev/sda3
GParted Live on USB
Windows Method A: Tuxboot
- Download Tuxboot on your MS Windows computer.
- Follow the USB setup with MS Windows instructions to install GParted Live on your USB flash drive.
version
./version-check.sh
bash, version 5.0.17(1)-release
/bin/sh -> /usr/bin/bash
Binutils: (GNU Binutils for Ubuntu) 2.34
bison (GNU Bison) 3.5.1
/usr/bin/yacc -> /usr/bin/bison.yacc
bzip2, Version 1.0.8, 13-Jul-2019.
Coreutils: 8.30
diff (GNU diffutils) 3.7
find (GNU findutils) 4.7.0
GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.2.0)
/usr/bin/awk -> /usr/bin/gawk
gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0
g++ (Ubuntu 9.3.0-10ubuntu2) 9.3.0
(Ubuntu GLIBC 2.31-0ubuntu9) 2.31
grep (GNU grep) 3.4
gzip 1.10
Linux version 5.4.0-47-generic (buildd@lcy01-amd64-014) (gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2)) #51-Ubuntu SMP Fri Sep 4 19:50:52 UTC 2020
m4 (GNU M4) 1.4.18
GNU Make 4.2.1
GNU patch 2.7.6
Perl version='5.30.0';
Python 3.8.2
sed (GNU sed) 4.7
tar (GNU tar) 1.30
texi2any (GNU texinfo) 6.7
xz (XZ Utils) 5.2.4
g++ compilation OK
glibc
collect2: error: ld returned 1 exit status
case $(uname -m) in
i?86) ln -sfv ld-linux.so.2 $LFS/lib/ld-lsb.so.3
;;
x86_64) ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64
ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3
;;
esac
ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64
ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3
gcc
../../../libstdc++-v3/src/c++98/strstream.cc:324:63: error: 'INT_MAX' was not declared in this scope
source ~/.bashrc
grub
# grub-install /dev/sda --target i386-pc
正在為 i386-pc 平臺(tái)進(jìn)行安裝埃仪。
grub-install:警告: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible.
grub-install:警告: 無(wú)法嵌入。在此次安裝中 GRUB 只能通過(guò)使用塊列表安裝陕赃。但是塊列表是不可信賴的卵蛉,不推薦使用。.
grub-install:錯(cuò)誤: 停止進(jìn)行塊列表安裝.
http://www.linuxfromscratch.org/blfs/view/svn/postlfs/parted.html
parted /dev/sda set 1 bios_grub on
parted /dev/sda print
grub-install /dev/sda --target i386-pc
Interface eth0 doesn't exist
注意
如果沒(méi)有使用前一節(jié)描述的自定義命名策略么库,udev 會(huì)根據(jù)系統(tǒng)物理特征命名網(wǎng)卡接口傻丝,例如enp2s1
。如果您不能確定接口名诉儒,可以在引導(dǎo)您的LFS
系統(tǒng)后使用ip link
或ls /sys/class/net
命令確認(rèn)葡缰。
參考:http://www.linuxfromscratch.org/lfs/view/8.4/chapter07/network.html
cd /etc/sysconfig/
cat > ifconfig.enp2s0 << "EOF"
ONBOOT=yes
IFACE=enp2s0
SERVICE=ipv4-static
IP=192.168.1.222
GATEWAY=192.168.1.1
PREFIX=24
BROADCAST=192.168.1.255
EOF
ping
cat > /etc/resolv.conf << "EOF"
# Begin /etc/resolv.conf
nameserver 192.168.1.1
nameserver 8.8.8.8
# End /etc/resolv.conf
EOF
BLFS
curl
SSL certificate problem: unable to get local issuer certificate
https://curl.haxx.se/docs/sslcerts.html
curl https://curl.haxx.se/ca/cacert.pem --output cacert.pem
scp cacert.pem xxx@lfs:/etc/curlssl/cacert.pem
export CURL_CA_BUNDLE=/etc/curlssl/cacert.pem
https://mirror-hk.koddos.net/blfs/10.0/u/unzip60.tgz