DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Linux From Scratch Notes


Linux from Scratch (LFS) version: 7.5.

Host: Dell PC, ArchLinux.

Partition Scheme

The host is GPT, so use cgdisk to create 2 new partitions (after 2 existing partitions): root 10GB, and swap 4GB. When asked for partition type, input "L", it will list all type code, where code of linux swap is 8200. Reboot and build as root:

mkfs.ext4 /dev/sda3
mkswap /dev/sda4
export LFS=/mnt/lfs
mkdir -pv $LFS
mount -v -t ext4 /dev/sda3 $LFS
swapon -v /dev/sda4
mkdir $LFS/sources
chmod -v a+wt $LFS/sources
mkdir -v $LFS/tools
groupadd lfs
useradd -s /bin/bash -g lfs -m -k /dev/null lfs
passwd lfs
chown -R lfs:lfs $LFS
chown -v lfs $LFS/tools
ln -sv $LFS/tools /
chown -v lfs $LFS/sources
su - lfs

cat > ~/.bash_profile << "EOF"
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
EOF
cat > ~/.bashrc << "EOF"
set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
LFS_TGT=$(uname -m)-lfs-linux-gnu
PATH=/tools/bin:/bin:/usr/bin
export LFS LC_ALL LFS_TGT PATH
EOF

wget -O wget-list http://www.linuxfromscratch.org/lfs/downloads/stable/wget-list
wget -i wget-list -P $LFS/sources

cd $LFS
tar xf sources/binutils-2.24.tar.bz2
cd binutils-2.24
./configure --prefix=/tools --with-sysroot=$LFS --with-lib-path=/tools/lib --target=$LFS_TGT --disable-nls --disable-werror 
make
mkdir -v /tools/lib
ln -sv lib /tools/lib64
make install
cd $LFS
tar xf sources/gcc-4.8.2.tar.bz2
tar xf sources/mpfr-3.1.2.tar.xz
tar xf sources/gmp-5.1.3.tar.xz
tar xf sources/mpc-1.0.2.tar.xz
mv mpfr* mpfr
mv gmp* gmp
mv mpc* mpc
mv mpfr gmp mpc gcc-4.8.2
cd gcc-4.8.2
cat > runme.sh <<EOF
for file in $(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)
do
    cp -uv $file{,.orig}
    sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
        -e 's@/usr@/tools@g' $file.orig > $file
    echo '
#undef STANDARD_STARTFILE_PREFIX_1
#undef STANDARD_STARTFILE_PREFIX_2
#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file
    touch $file.orig
done
EOF
chmod 755 runme.sh
./runme.sh


Published

Sep 19, 2014

Last Updated

Sep 19, 2014

Category

Tech

Tags

  • build 4
  • linux 158
  • system 1

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor