Site officiel : Linux From Scratch
Cette phase doit absolument être exécutée en tant que super-utilisateur root.
Chrootage
mount -v --bind /dev $LFS/dev mount -vt devpts devpts $LFS/dev/pts -o gid=5,mode=620 mount -vt proc proc $LFS/proc mount -vt sysfs sysfs $LFS/sys mount -vt tmpfs tmpfs $LFS/run
chroot "$LFS" /usr/bin/env -i \ HOME=/root TERM="$TERM" \ PS1='(lfs chroot) \u:\w\$ ' \ PATH=/bin:/usr/bin:/sbin:/usr/sbin \ /bin/bash --login
/dev/sdb2 on / type ext4 (rw,relatime,data=ordered) /dev/sdb3 on /home type ext4 (rw,relatime,data=ordered) /dev/sdb1 on /boot type ext2 (rw,relatime,block_validity,barrier,user_xattr,acl) udev on /dev type devtmpfs (rw,nosuid,relatime,size=1014992k,nr_inodes=253748,mode=755) devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000) proc on /proc type proc (rw,relatime) sysfs on /sys type sysfs (rw,relatime) tmpfs on /run type tmpfs (rw,relatime)
Les fichiers de périphérique sont créés par le noyau avec le système de fichiers devtmpfs. Quand une instance devtmpfs est montée sur /dev, le nœud de périphérique sera créé dès le départ avec un nom, des droits et un propriétaire figés.
Le rôle de sysfs, monté su /sys, est d’exporter une vue de la configuration matérielle du système pour les processus en espace utilisateur.
Configuration en IP statique
cat > /etc/systemd/network/10-eth-static.network << "EOF" [Match] Name=enp0s3 [Network] Address=192.168.1.10/24 Gateway=192.168.1.1 EOF
OU Configuration du DHCP
cat > /etc/systemd/network/10-eth-dhcp.network << "EOF" [Match] Name=enp0s3 [Network] DHCP=ipv4 [DHCP] UseDomains=true EOF
Configuration d’un fichier resolv.conf statique
cat > /etc/resolv.conf << "EOF" # Début de /etc/resolv.conf domain opensharing.priv nameserver 8.8.8.8 nameserver 8.8.4.4 # Fin de /etc/resolv.conf EOF
Fichier /etc/hostname
echo "mylfs" > /etc/hostname
Fichier /etc/hosts
cat > /etc/hosts << "EOF" # Begin /etc/hosts 127.0.0.1 localhost 127.0.1.1 mylfs.opensharing.priv mylfs 192.168.1.10 mylfs.opensharing.priv mylfs ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters # End /etc/hosts EOF
Disposition du clavier en azerty
cat > /etc/vconsole.conf << "EOF" KEYMAP=fr EOF
Fichier /etc/locale.conf
cat > /etc/locale.conf << "EOF" LANG=en_GB.UTF-8 EOF
Fichier /etc/inputrc
cat > /etc/inputrc << "EOF" # Début de /etc/inputrc # Modifié par Chris Lynn <roryo@roryo.dynup.net> # Permettre à l'invite de commande d'aller à la ligne set horizontal-scroll-mode Off # Activer l'entrée sur 8 bits set meta-flag On set input-meta On # Ne pas supprimer le 8ème bit set convert-meta Off # Conserver le 8ème bit à l'affichage set output-meta On # none, visible ou audible set bell-style none # Toutes les indications qui suivent font correspondre la séquence # d'échappement contenue dans le 1er argument à la fonction # spécifique de readline "\eOd": backward-word "\eOc": forward-word # Pour la console linux "\e[1~": beginning-of-line "\e[4~": end-of-line "\e[5~": beginning-of-history "\e[6~": end-of-history "\e[3~": delete-char "\e[2~": quoted-insert # pour xterm "\eOH": beginning-of-line "\eOF": end-of-line # pour Konsole "\e[H": beginning-of-line "\e[F": end-of-line # Fin de /etc/inputrc EOF
Fichier /etc/shells
cat > /etc/shells << "EOF" # Begin /etc/shells /bin/sh /bin/bash # End /etc/shells EOF
Fichier /etc/fstab
cat > /etc/fstab << "EOF" # Begin /etc/fstab # file system mount-point type options dump fsck /dev/sbd2 / ext4 defaults 0 0 /dev/sdb1 /boot ext2 defaults 0 0 /dev/sdb3 /home ext4 defaults 0 0 /dev/sdb5 swap swap pri=1 0 0 # End /etc/fstab EOF
Noyau Linux
Source : 8.3. Linux-4.20.12
Le paquet Linux contient le noyau Linux.
cd /sources/ tar Jxvf linux-4.20.12.tar.xz cd linux-4.20.12/
make mrproper
make defconfig
make menuconfig
General setup --> [ ] Enable deprecated sysfs features to support old userspace tools [CONFIG_SYSFS_DEPRECATED] [ ] Enable deprecated sysfs features by default [CONFIG_SYSFS_DEPRECATED_V2] [*] open by fhandle syscalls [CONFIG_FHANDLE] [ ] Auditing support [CONFIG_AUDIT] [*] Control Group support [CONFIG_CGROUPS] Processor type and features ---> [*] Enable seccomp to safely compute untrusted bytecode [CONFIG_SECCOMP] Networking support ---> Networking options ---> <*> The IPv6 protocol [CONFIG_IPV6] Device Drivers ---> Generic Driver Options ---> [ ] Support for uevent helper [CONFIG_UEVENT_HELPER] [*] Maintain a devtmpfs filesystem to mount at /dev [CONFIG_DEVTMPFS] [ ] Fallback user-helper invocation for firmware loading [CONFIG_FW_LOADER_USER_HELPER] Firmware Drivers ---> [*] Export DMI identification via sysfs to userspace [CONFIG_DMIID] File systems ---> [*] Inotify support for userspace [CONFIG_INOTIFY_USER] <*> Kernel automounter version 4 support (also supports v3) [CONFIG_AUTOFS4_FS] Pseudo filesystems ---> [*] Tmpfs POSIX Access Control Lists [CONFIG_TMPFS_POSIX_ACL] [*] Tmpfs extended attributes [CONFIG_TMPFS_XATTR] Kernel hacking ---> Choose kernel unwinder (Frame pointer unwinder) ---> [CONFIG_UNWINDER_FRAME_POINTER]
make
make modules_install
cp -iv arch/x86_64/boot/bzImage /boot/vmlinuz-4.20.12-lfs-8.4-systemd
'arch/x86_64/boot/bzImage' -> '/boot/vmlinuz-4.20.12-lfs-8.4-systemd'
cp -iv System.map /boot/System.map-4.20.12
'System.map' -> '/boot/System.map-4.20.12'
cp -iv .config /boot/config-4.20.12
'.config' -> '/boot/config-4.20.12'
install -d /usr/share/doc/linux-4.20.12 cp -r Documentation/* /usr/share/doc/linux-4.20.12
chown -Rv 0:0 .
install -v -m755 -d /etc/modprobe.d
install: creating directory '/etc/modprobe.d'
cat > /etc/modprobe.d/usb.conf << "EOF" # Début de /etc/modprobe.d/usb.conf install ohci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i ohci_hcd ; true install uhci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i uhci_hcd ; true # Fin de /etc/modprobe.d/usb.conf EOF
GRUB
cat > /boot/grub/grub.cfg << "EOF" # Begin /boot/grub/grub.cfg set default=0 set timeout=5 insmod ext2 set root=(hd1,1) menuentry "GNU/Linux, Linux 4.20.12-lfs-8.4-systemd" { linux /vmlinuz-4.20.12-lfs-8.4-systemd root=/dev/sdb2 ro } EOF
Sur l’hôte :
update-grub
Found background image: /usr/share/images/desktop-base/desktop-grub.png Found linux image: /boot/vmlinuz-4.9.0-9-amd64 Found initrd image: /boot/initrd.img-4.9.0-9-amd64 Found linux image: /boot/vmlinuz-4.9.0-8-amd64 Found initrd image: /boot/initrd.img-4.9.0-8-amd64 Found Linux From Scratch (8.4-systemd) on /dev/sdb2 done
Fichier /etc/os-release
cat > /etc/os-release << "EOF" NAME="Linux From Scratch" VERSION="8.4-systemd" ID=lfs PRETTY_NAME="Linux From Scratch 8.4-systemd" VERSION_CODENAME="DarwinOS" EOF
Fichier /etc/lfs-release
echo 8.4-systemd > /etc/lfs-release
Fichier /etc/lsb-release
cat > /etc/lsb-release << "EOF" DISTRIB_ID="Linux From Scratch" DISTRIB_RELEASE="8.4-systemd" DISTRIB_CODENAME="DarwinOS" DISTRIB_DESCRIPTION="Linux From Scratch" EOF
Redémarrage
logout
umount -v $LFS/dev/pts
umount: /mnt/lfs/dev/pts unmounted
umount -v $LFS/dev
umount: /mnt/lfs/dev unmounted
umount -v $LFS/run
umount: /mnt/lfs/run unmounted
umount -v $LFS/proc
umount: /mnt/lfs/proc unmounted
umount -v $LFS/sys
umount: /mnt/lfs/sys unmounted
umount -v $LFS/boot
umount: /mnt/lfs/boot unmounted
umount -v $LFS/home
umount: /mnt/lfs/home unmounted
umount -v $LFS
umount: /mnt/lfs unmounted
shutdown -r now