Linux From Scratch

2020-09-24  本文已影响0人  iOSDevLog
LFS_10.0.jpg

LFS: http://www.linuxfromscratch.org/lfs/

Chinese Book: 中文翻译版

宿主系统需求

Host OS: Ubuntu 20.04

root

$ sudo passwd root
New password: 
Retype new password: 
passwd: password updated successfully
$ su - root
# 
# 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

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

分区 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

  1. Download Tuxboot on your MS Windows computer.
  2. Follow the USB setup with MS Windows instructions to install GParted Live on your USB flash drive.
Gparted.png
Gpared_disk.png

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 平台进行安装。
grub-install:警告: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible.
grub-install:警告: 无法嵌入。在此次安装中 GRUB 只能通过使用块列表安装。但是块列表是不可信赖的,不推荐使用。.
grub-install:错误: 停止进行块列表安装.

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

eth0.jpg

注意
如果没有使用前一节描述的自定义命名策略,udev 会根据系统物理特征命名网卡接口,例如 enp2s1。如果您不能确定接口名,可以在引导您的 LFS 系统后使用 ip linkls /sys/class/net 命令确认。

参考: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
上一篇下一篇

猜你喜欢

热点阅读