LFS 10.0 super detailed construction process (2)

Seven, prepare the host system:
1. Check the host system:

cat > version-check.sh << "EOF"
#!/bin/bash
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
EOF

Input:
bash version-check.sh The
LFS 10.0 super detailed construction process (2)
above command output:
![]( https://s4.51cto.com/images/blog/202101/root@debian :~# chmod -v a+wt $LFS/sources15/8421e58bb4aa620fa134e6c5f0a0e698 .jpg?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
You can see the missing software and links. Install the software and links below.
2. Modify the link and install the required software:
(1) ln -sf bash /bin/sh // modify bash to point to /bin/sh
(2) apt-get install bison // install bison
(3) apt-get install g++ // install g++
(4) apt-get install texinfo // install texinfo
(5) apt-get install gawk // install gawk
Note: The above software is only installed on the live-cd system, that is, in the memory, but not installed To the hard drive.
3. Run version-check.sh again and enter:
bash version-check.sh
as shown in the figure below:
LFS 10.0 super detailed construction process (2)
Compared with the software required in the LFS 10.0 manual, it should not be lower or much higher than the software version required in the manual.
LFS 10.0 super detailed construction process (2)
If you use the software required by this tutorial, it will pass.
8. Create partition, file system download source code
1. Create partition:
cfdisk /dev/sda and press
Enter, select DOS partition format.
LFS 10.0 super detailed construction process (2)
Enter the partition after pressing Enter.
LFS 10.0 super detailed construction process (2)
Press Enter directly to create a new partition. Enter 2048M and press Enter:
LFS 10.0 super detailed construction process (2)
select the main partition and press Enter. Then, press the T key on the keyboard, and the following picture will pop up:
LFS 10.0 super detailed construction process (2)
Move the cursor up to the picture below:
LFS 10.0 super detailed construction process (2)
Enter, so that the swap partition is created successfully.
After the swap partition is created, press the downward cursor to select the undivided space, which is similar to the swap space partition, press Enter directly, then select all the spaces, press Enter, set as the main partition, and press Enter. Then press the T key like that and press Enter.
At this point, the partition establishment is complete. As shown in the figure below:
LFS 10.0 super detailed construction process (2)
Press the B key on the keyboard to set the boot partition. As shown in the figure below:
LFS 10.0 super detailed construction process (2)
Note: There is a number in /dev/sda2. Indicates that it is the boot partition.
Press the right cursor key. Choose Write to enter, and enter yes to enter, so that the partition is saved.
Then, press the Q key on the keyboard to exit the partition software.
2. Create a partition system:
mkfs -v -t ext4 /dev/sda2
creates the primary partition as an ext4 file system.
3. Format the swap partition:
mkswap /dev/sda1
4. Set the $LFS variable
export LFS=/mnt/lfs
5. Create a directory, mount the primary partition, and the swap partition
mkdir -pv $LFSS
mount -v -t ext4 /dev/sda2 $LFS
/sbin/swapon -v /dev/sda1
6. Create a source code directory, change permissions, and enter the directory
mkdir -v $LFS/sources
chmod -v a +wt $LFS/sources
cd $LFS/sources/
7. Download the source code:
I chose the domestic mirror site: University of Science and Technology of China, website: http://mirrors.ustc.edu.cn/lfs/lfs-packages/ 10.0/
(1) First download the wget-list file (Note: download to this machine, not in a virtual machine)
http://mirrors.ustc.edu.cn/lfs/lfs-packages/10.0/wget-list
(2) Open the wget-list file and modify it. Change the download URL in front of the link file name to http://mirrors.ustc.edu.cn/lfs/lfs-packages/10.0/.
As shown:

LFS 10.0 super detailed construction process (2)

(3) Select all the download link addresses and copy them.
(4) Enter in the putty terminal:
nano wget-list to
create a new wget-list file. Click the middle mouse button in this window and paste the link you just copied into the wget-list file of the virtual machine. As shown below:
LFS 10.0 super detailed construction process (2)
Then, connect the Ctrl+O key on the keyboard and press Enter. Press Ctrl+X again to exit.
5. Download the source code:
wget --input-file=wget-list --continue --directory-prefix=$LFS/sources
6. Perform MDs code to verify whether all software packages are available
pushd $LFS/sources
md5sum -c md5sums
popd
If there is a wrong link, please download again. Or download from another mirror site.
Nine, create directory, lfs user, build environment
(1) create the required directory
mkdir -pv $LFS/{bin,etc,lib,sbin,usr,var}
case $(uname -m) in
x86_64) mkdir -pv $LFS/lib64 ;;
esac
(2) Create cross-compilation directory
mkdir -pv $LFS/tools
(3) Create lfs users, groups and permissions
groupadd lfs
useradd -s /bin/bash -g lfs -m -k /dev/ null lfs
passwd lfs
Set a password for the lfs user. The password must be the same twice.
chown -v lfs $LFS/(usr,lib,var,etc,bin,sbin,tools)
case $(uname -m) in
x86_64) chown -v lfs $LFS/lib64 ;;
esac
chown -v lfs $LFS/ sources
su-lfs
(4) Set up the environment and
create the .bash_profile file:
cat> ~/.bash_profile << "EOF"
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ '/bin /bash
EOF
creates a .bashrc file:
cat> ~/.bashrc << "EOF"
set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
LFS_TGT=$(uname -m)-lfs-linux-gnu
PATH=/ usr/bin
if [! -L /bin ]; then PATH=/bin:$PATH; fi
PATH=$LFS/tools/bin:$PATH
export LFS LC_ALL LFS_TGT PATH
EOF to
enable the configuration file just created:
source ~/.bash_profile

Guess you like

Origin blog.51cto.com/9828355/2592695