Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| elearning:workbooks:centos:8:junior:l118 [2023/08/24 15:31] – removed admin | elearning:workbooks:centos:8:junior:l118 [2024/09/12 09:09] (Version actuelle) – admin | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | ~~PDF: | ||
| + | Version : **2024.01** | ||
| + | |||
| + | Dernière mise-à-jour : ~~LASTMOD~~ | ||
| + | |||
| + | ======LCF512 - Gestion du Noyau et des Quotas====== | ||
| + | |||
| + | =====Contenu du Module===== | ||
| + | |||
| + | * **LCF512 - Gestion du Noyau et des Quotas** | ||
| + | * Contenu du Module | ||
| + | * Rôle du noyau | ||
| + | * LAB #1 - Modules | ||
| + | * LAB #2 - Compilation et installation du noyau et des modules | ||
| + | * 2.1 - Déplacer /home | ||
| + | * 2.2 - Préparer l' | ||
| + | * 2.3 - Préparer l' | ||
| + | * Le Fichier .config | ||
| + | * Le Fichier Makefile | ||
| + | * 2.4 - Paramétrage du noyau | ||
| + | * 2.5 - Compiler le Noyau | ||
| + | * 2.6 - Installer le Nouveau Noyau | ||
| + | * LAB #3 - Gestion des Quotas | ||
| + | * 3.1 - La Commande quotacheck | ||
| + | * 3.2 - La Commande edquota | ||
| + | * 3.3 - La Commande quotaon | ||
| + | * 3.4 - La Commande repquota | ||
| + | * 3.5 - La Commande quota | ||
| + | * 3.6 - La Commande warnquota | ||
| + | |||
| + | =====Rôle du noyau===== | ||
| + | |||
| + | Le noyau ou //kernel// est la partie du système d' | ||
| + | |||
| + | * la diminution de la taille du noyau, | ||
| + | * la prise en charge de nouveau matériel, | ||
| + | * l' | ||
| + | * l' | ||
| + | * la correction de bogues, | ||
| + | * le besoin d'une fonctionnalité expérimentale. | ||
| + | | ||
| + | Commencez par mettre à jour CentOS 8 : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# dnf update | ||
| + | ... | ||
| + | [root@centos8 ~]# reboot | ||
| + | </ | ||
| + | |||
| + | Identifiez ensuite le noyau utilisé par votre machine virtuelle : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# uname -r | ||
| + | 4.18.0-305.7.1.el8_4.x86_64 | ||
| + | </ | ||
| + | |||
| + | =====LAB #1 - Modules===== | ||
| + | |||
| + | Dans le cas d'une utilisation courante de Linux, il est cependant préférable de faire appel aux **modules**. Les modules se trouvent dans le répertoire **/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# ls / | ||
| + | bls.conf | ||
| + | build modules.builtin.bin | ||
| + | config | ||
| + | kernel | ||
| + | modules.alias | ||
| + | modules.alias.bin | ||
| + | modules.block | ||
| + | </ | ||
| + | |||
| + | Les commandes pour manipuler les modules sont : | ||
| + | |||
| + | * insmod | ||
| + | * rmmod | ||
| + | * lsmod | ||
| + | * modprobe | ||
| + | |||
| + | Par exemple : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# lsmod | ||
| + | Module | ||
| + | xt_CHECKSUM | ||
| + | ipt_MASQUERADE | ||
| + | xt_conntrack | ||
| + | ipt_REJECT | ||
| + | nft_compat | ||
| + | nf_nat_tftp | ||
| + | nft_objref | ||
| + | nf_conntrack_tftp | ||
| + | nft_counter | ||
| + | tun 53248 1 | ||
| + | bridge | ||
| + | stp 16384 1 bridge | ||
| + | llc 16384 2 bridge,stp | ||
| + | nft_fib_inet | ||
| + | nft_fib_ipv4 | ||
| + | nft_fib_ipv6 | ||
| + | nft_fib | ||
| + | nft_reject_inet | ||
| + | nf_reject_ipv4 | ||
| + | nf_reject_ipv6 | ||
| + | nft_reject | ||
| + | nft_ct | ||
| + | nf_tables_set | ||
| + | nft_chain_nat | ||
| + | nf_nat | ||
| + | nf_conntrack | ||
| + | nf_defrag_ipv6 | ||
| + | nf_defrag_ipv4 | ||
| + | ip_set | ||
| + | nf_tables | ||
| + | nfnetlink | ||
| + | sunrpc | ||
| + | ext4 761856 | ||
| + | mbcache | ||
| + | jbd2 131072 | ||
| + | virtio_balloon | ||
| + | pcspkr | ||
| + | i2c_piix4 | ||
| + | joydev | ||
| + | ip_tables | ||
| + | xfs 1515520 | ||
| + | libcrc32c | ||
| + | sr_mod | ||
| + | sd_mod | ||
| + | cdrom 65536 1 sr_mod | ||
| + | t10_pi | ||
| + | sg | ||
| + | ata_generic | ||
| + | bochs_drm | ||
| + | drm_vram_helper | ||
| + | drm_kms_helper | ||
| + | syscopyarea | ||
| + | sysfillrect | ||
| + | sysimgblt | ||
| + | fb_sys_fops | ||
| + | drm_ttm_helper | ||
| + | ttm | ||
| + | drm | ||
| + | ahci | ||
| + | libahci | ||
| + | virtio_net | ||
| + | net_failover | ||
| + | ata_piix | ||
| + | serio_raw | ||
| + | failover | ||
| + | libata | ||
| + | dm_mirror | ||
| + | dm_region_hash | ||
| + | dm_log | ||
| + | dm_mod | ||
| + | fuse 151552 | ||
| + | </ | ||
| + | |||
| + | Pour ajouter un module, on peut utiliser la commande **insmod** ou **modprobe**. Cette dernière ajoute non seulement le module passé en argument mais également ses dépendances : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# modprobe bonding | ||
| + | [root@centos8 ~]# lsmod | more | ||
| + | Module | ||
| + | bonding | ||
| + | xt_CHECKSUM | ||
| + | ipt_MASQUERADE | ||
| + | xt_conntrack | ||
| + | ipt_REJECT | ||
| + | nft_compat | ||
| + | nf_nat_tftp | ||
| + | nft_objref | ||
| + | nf_conntrack_tftp | ||
| + | nft_counter | ||
| + | tun 53248 1 | ||
| + | bridge | ||
| + | stp 16384 1 bridge | ||
| + | llc 16384 2 bridge,stp | ||
| + | nft_fib_inet | ||
| + | nft_fib_ipv4 | ||
| + | nft_fib_ipv6 | ||
| + | nft_fib | ||
| + | nft_reject_inet | ||
| + | nf_reject_ipv4 | ||
| + | nf_reject_ipv6 | ||
| + | --More-- | ||
| + | </ | ||
| + | |||
| + | Pour supprimer un module, on peut utiliser la commande **rmmod** ou **modprobe -r**. Cette dernière essaie de supprimer les dépendances non-utilisées : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# modprobe -r bonding | ||
| + | [root@centos8 ~]# lsmod | more | ||
| + | Module | ||
| + | xt_CHECKSUM | ||
| + | ipt_MASQUERADE | ||
| + | xt_conntrack | ||
| + | ipt_REJECT | ||
| + | nft_compat | ||
| + | nf_nat_tftp | ||
| + | nft_objref | ||
| + | nf_conntrack_tftp | ||
| + | nft_counter | ||
| + | tun 53248 1 | ||
| + | bridge | ||
| + | stp 16384 1 bridge | ||
| + | llc 16384 2 bridge,stp | ||
| + | nft_fib_inet | ||
| + | nft_fib_ipv4 | ||
| + | nft_fib_ipv6 | ||
| + | nft_fib | ||
| + | nft_reject_inet | ||
| + | nf_reject_ipv4 | ||
| + | nf_reject_ipv6 | ||
| + | nft_reject | ||
| + | --More-- | ||
| + | </ | ||
| + | |||
| + | Les dépendances des modules sont résolues par la commande **modprobe** grâce aux fichier **/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# more / | ||
| + | kernel/ | ||
| + | kernel/ | ||
| + | kernel/ | ||
| + | kernel/ | ||
| + | kernel/ | ||
| + | kernel/ | ||
| + | kernel/ | ||
| + | kernel/ | ||
| + | kernel/ | ||
| + | kernel/ | ||
| + | xz kernel/ | ||
| + | kernel/ | ||
| + | kernel/ | ||
| + | kernel/ | ||
| + | kernel/ | ||
| + | kernel/ | ||
| + | kernel/ | ||
| + | kernel/ | ||
| + | kernel/ | ||
| + | kernel/ | ||
| + | _64.ko.xz | ||
| + | kernel/ | ||
| + | --More--(0%) | ||
| + | </ | ||
| + | |||
| + | Il est possible d' | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# modinfo bonding | ||
| + | filename: | ||
| + | author: | ||
| + | description: | ||
| + | license: | ||
| + | alias: | ||
| + | rhelversion: | ||
| + | srcversion: | ||
| + | depends: | ||
| + | intree: | ||
| + | name: | ||
| + | vermagic: | ||
| + | sig_id: | ||
| + | signer: | ||
| + | sig_key: | ||
| + | sig_hashalgo: | ||
| + | signature: | ||
| + | B7: | ||
| + | 3F: | ||
| + | BE: | ||
| + | 44: | ||
| + | DE: | ||
| + | 7F: | ||
| + | D8: | ||
| + | BA: | ||
| + | B8: | ||
| + | 8F: | ||
| + | 58: | ||
| + | 6E: | ||
| + | 50: | ||
| + | 2F: | ||
| + | CA: | ||
| + | 0C: | ||
| + | A6: | ||
| + | AE: | ||
| + | 59:86:75:31 | ||
| + | parm: | ||
| + | parm: | ||
| + | parm: | ||
| + | parm: | ||
| + | parm: | ||
| + | parm: | ||
| + | parm: | ||
| + | parm: | ||
| + | parm: | ||
| + | parm: | ||
| + | parm: | ||
| + | parm: | ||
| + | parm: | ||
| + | parm: | ||
| + | parm: | ||
| + | parm: | ||
| + | parm: | ||
| + | parm: | ||
| + | parm: | ||
| + | parm: | ||
| + | parm: | ||
| + | parm: | ||
| + | parm: | ||
| + | parm: | ||
| + | </ | ||
| + | |||
| + | Dernièrement, | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# ls / | ||
| + | firewalld-sysctls.conf | ||
| + | kvm.conf | ||
| + | |||
| + | [root@centos8 ~]# cat / | ||
| + | # Setting modprobe kvm_intel/ | ||
| + | # only enables Nested Virtualization until the next reboot or | ||
| + | # module reload. Uncomment the option applicable | ||
| + | # to your system below to enable the feature permanently. | ||
| + | # | ||
| + | # User changes in this file are preserved across upgrades. | ||
| + | # | ||
| + | # For Intel | ||
| + | #options kvm_intel nested=1 | ||
| + | # | ||
| + | # For AMD | ||
| + | #options kvm_amd nested=1 | ||
| + | </ | ||
| + | |||
| + | =====LAB #2 - Compilation et installation du noyau et des modules===== | ||
| + | |||
| + | Activez le dépôt **CentOS-Linux-PowerTools** en passant la directive **enabled** à **1** : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# vi / | ||
| + | [root@centos8 ~]# cat / | ||
| + | # CentOS-Linux-PowerTools.repo | ||
| + | # | ||
| + | # The mirrorlist system uses the connecting IP address of the client and the | ||
| + | # update status of each mirror to pick current mirrors that are geographically | ||
| + | # close to the client. | ||
| + | # manually picking other mirrors. | ||
| + | # | ||
| + | # If the mirrorlist does not work for you, you can try the commented out | ||
| + | # baseurl line instead. | ||
| + | |||
| + | [powertools] | ||
| + | name=CentOS Linux $releasever - PowerTools | ||
| + | mirrorlist=http:// | ||
| + | # | ||
| + | gpgcheck=1 | ||
| + | enabled=1 | ||
| + | gpgkey=file:/// | ||
| + | </ | ||
| + | |||
| + | Installez maintenant les paquets nécessaires : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# dnf groupinstall " | ||
| + | ... | ||
| + | [root@centos8 ~]# dnf install asciidoc audit-libs-devel bash bc binutils binutils-devel bison diffutils elfutils elfutils-devel elfutils-libelf-devel findutils flex gawk gcc gettext gzip hmaccalc hostname make module-init-tools ncurses-devel net-tools newt-devel numactl-devel openssl patch pciutils-devel perl perl-ExtUtils-Embed pesign redhat-rpm-config rpm-build rpmdevtools sh-utils tar xmlto xz zlib-devel rpmdevtools | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | ====2.1 - Déplacer /home==== | ||
| + | |||
| + | <WRAP center round alert 60%> | ||
| + | **Important** - Il n'est pas conseillé de compiler en tant que root pour des raisons de sécurité. Pour pouvoir utiliser le compte d'un utilisateur pour créer un nouveau noyau, celui-ci doit disposer de plus de 10 Go d' | ||
| + | </ | ||
| + | |||
| + | <WRAP center round todo 60%> | ||
| + | **A faire** - **Déconnectez-vous** de votre session **CentOS8_SSH_10.0.2.45** et re-connectez-vous à la VM en tant que root en utilisant la connexion **CentOS8_ROOT_10.0.2.45**. | ||
| + | </ | ||
| + | |||
| + | Créez ensuite une seule partition sur **/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# fdisk /dev/sdc | ||
| + | |||
| + | Welcome to fdisk (util-linux 2.32.1). | ||
| + | Changes will remain in memory only, until you decide to write them. | ||
| + | Be careful before using the write command. | ||
| + | |||
| + | Device does not contain a recognized partition table. | ||
| + | Created a new DOS disklabel with disk identifier 0xc321702b. | ||
| + | |||
| + | Command (m for help): n | ||
| + | Partition type | ||
| + | | ||
| + | | ||
| + | Select (default p): | ||
| + | |||
| + | Using default response p. | ||
| + | Partition number (1-4, default 1): | ||
| + | First sector (2048-41943039, | ||
| + | Last sector, +sectors or +size{K, | ||
| + | |||
| + | Created a new partition 1 of type ' | ||
| + | |||
| + | Command (m for help): w | ||
| + | The partition table has been altered. | ||
| + | Calling ioctl() to re-read partition table. | ||
| + | Syncing disks. | ||
| + | </ | ||
| + | |||
| + | Créez maintenant un système de fichiers ext4 sur **/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# mkfs.ext4 /dev/sdc1 | ||
| + | mke2fs 1.45.6 (20-Mar-2020) | ||
| + | Discarding device blocks: done | ||
| + | Creating filesystem with 16776960 4k blocks and 4194304 inodes | ||
| + | Filesystem UUID: dc92c0d7-919b-4fff-8719-53e9e7e628dd | ||
| + | Superblock backups stored on blocks: | ||
| + | 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, | ||
| + | 4096000, 7962624, 11239424 | ||
| + | |||
| + | Allocating group tables: done | ||
| + | Writing inode tables: done | ||
| + | Creating journal (65536 blocks): done | ||
| + | Writing superblocks and filesystem accounting information: | ||
| + | </ | ||
| + | |||
| + | Montez **/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# mount /dev/sdc1 /mnt | ||
| + | </ | ||
| + | |||
| + | Copiez le contenu de /home vers /mnt : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cp -a /home/* /mnt | ||
| + | </ | ||
| + | |||
| + | Démontez /dev/sdc1 et déplacez /home vers /root : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# umount /mnt | ||
| + | [root@centos8 ~]# mv /home /root | ||
| + | </ | ||
| + | |||
| + | Identifiez l'UUID de /dev/sdc1 : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# ls -l / | ||
| + | lrwxrwxrwx. 1 root root 10 Jul 19 12:02 f76d6b66-985b-4a91-af9c-4987e8c1443c -> ../../sdc | ||
| + | [root@centos8 ~]# | ||
| + | </ | ||
| + | |||
| + | Editez le fichier **/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# vi /etc/fstab | ||
| + | [root@centos8 ~]# cat /etc/fstab | ||
| + | |||
| + | # | ||
| + | # /etc/fstab | ||
| + | # Created by anaconda on Wed Jun 16 06:21:32 2021 | ||
| + | # | ||
| + | # Accessible filesystems, | ||
| + | # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info. | ||
| + | # | ||
| + | # After editing this file, run ' | ||
| + | # units generated from this file. | ||
| + | # | ||
| + | / | ||
| + | UUID=1c04981e-5317-4b73-9695-3ce25246835d /boot | ||
| + | / | ||
| + | UUID=f76d6b66-985b-4a91-af9c-4987e8c1443c /home | ||
| + | </ | ||
| + | |||
| + | Créez le point de montage /home : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# mkdir /home | ||
| + | </ | ||
| + | |||
| + | Montez /dev/sdc1 : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# mount -a | ||
| + | [root@centos8 ~]# mount | ||
| + | sysfs on /sys type sysfs (rw, | ||
| + | proc on /proc type proc (rw, | ||
| + | devtmpfs on /dev type devtmpfs (rw, | ||
| + | securityfs on / | ||
| + | tmpfs on /dev/shm type tmpfs (rw, | ||
| + | devpts on /dev/pts type devpts (rw, | ||
| + | tmpfs on /run type tmpfs (rw, | ||
| + | tmpfs on / | ||
| + | cgroup on / | ||
| + | pstore on / | ||
| + | bpf on /sys/fs/bpf type bpf (rw, | ||
| + | cgroup on / | ||
| + | cgroup on / | ||
| + | cgroup on / | ||
| + | cgroup on / | ||
| + | cgroup on / | ||
| + | cgroup on / | ||
| + | cgroup on / | ||
| + | cgroup on / | ||
| + | cgroup on / | ||
| + | cgroup on / | ||
| + | cgroup on / | ||
| + | none on / | ||
| + | configfs on / | ||
| + | / | ||
| + | selinuxfs on / | ||
| + | mqueue on /dev/mqueue type mqueue (rw, | ||
| + | hugetlbfs on / | ||
| + | debugfs on / | ||
| + | systemd-1 on / | ||
| + | fusectl on / | ||
| + | /dev/sda1 on /boot type ext4 (rw, | ||
| + | sunrpc on / | ||
| + | tmpfs on / | ||
| + | tmpfs on / | ||
| + | gvfsd-fuse on / | ||
| + | tmpfs on /run/user/0 type tmpfs (rw, | ||
| + | gvfsd-fuse on / | ||
| + | /dev/sdc1 on /home type ext4 (rw, | ||
| + | </ | ||
| + | |||
| + | Notez la taille de /home : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# df -h | ||
| + | Filesystem | ||
| + | devtmpfs | ||
| + | tmpfs 1.9G | ||
| + | tmpfs 1.9G 9.4M 1.9G 1% /run | ||
| + | tmpfs 1.9G | ||
| + | / | ||
| + | / | ||
| + | tmpfs 374M | ||
| + | tmpfs 374M 1.2M 373M 1% / | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | <WRAP center round todo 60%> | ||
| + | **A faire** - **Déconnectez-vous** de votre session **CentOS8_ROOT_10.0.2.45** et re-connectez-vous à la VM en tant que trainee en utilisant la connexion **CentOS8_SSH_10.0.2.45**. | ||
| + | </ | ||
| + | |||
| + | ====2.2 - Préparer l' | ||
| + | |||
| + | Pour créer l' | ||
| + | |||
| + | < | ||
| + | [trainee@centos8 ~]$ rpmdev-setuptree | ||
| + | ...> | ||
| + | [trainee@centos8 ~]$ ls -laR rpmbuild/ | ||
| + | rpmbuild/: | ||
| + | total 28 | ||
| + | drwxrwxr-x. | ||
| + | drwxr-xr-x. 17 trainee trainee 4096 Jul 19 12:10 .. | ||
| + | drwxrwxr-x. | ||
| + | drwxrwxr-x. | ||
| + | drwxrwxr-x. | ||
| + | drwxrwxr-x. | ||
| + | drwxrwxr-x. | ||
| + | |||
| + | rpmbuild/ | ||
| + | total 8 | ||
| + | drwxrwxr-x. 2 trainee trainee 4096 Jul 19 12:10 . | ||
| + | drwxrwxr-x. 7 trainee trainee 4096 Jul 19 12:10 .. | ||
| + | |||
| + | rpmbuild/ | ||
| + | total 8 | ||
| + | drwxrwxr-x. 2 trainee trainee 4096 Jul 19 12:10 . | ||
| + | drwxrwxr-x. 7 trainee trainee 4096 Jul 19 12:10 .. | ||
| + | |||
| + | rpmbuild/ | ||
| + | total 8 | ||
| + | drwxrwxr-x. 2 trainee trainee 4096 Jul 19 12:10 . | ||
| + | drwxrwxr-x. 7 trainee trainee 4096 Jul 19 12:10 .. | ||
| + | |||
| + | rpmbuild/ | ||
| + | total 8 | ||
| + | drwxrwxr-x. 2 trainee trainee 4096 Jul 19 12:10 . | ||
| + | drwxrwxr-x. 7 trainee trainee 4096 Jul 19 12:10 .. | ||
| + | |||
| + | rpmbuild/ | ||
| + | total 8 | ||
| + | drwxrwxr-x. 2 trainee trainee 4096 Jul 19 12:10 . | ||
| + | drwxrwxr-x. 7 trainee trainee 4096 Jul 19 12:10 .. | ||
| + | </ | ||
| + | |||
| + | Téléchargez le rpm source du noyau : | ||
| + | |||
| + | < | ||
| + | [trainee@centos8 ~]$ uname -a | ||
| + | Linux centos8.ittraining.loc 4.18.0-305.7.1.el8_4.x86_64 #1 SMP Tue Jun 29 21:55:12 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux | ||
| + | |||
| + | [trainee@centos8 ~]$ cat / | ||
| + | CentOS Linux release 8.4.2105 | ||
| + | |||
| + | [trainee@centos8 ~]$ wget https:// | ||
| + | --2021-07-14 02: | ||
| + | Resolving vault.centos.org (vault.centos.org)... 81.171.33.194, | ||
| + | Connecting to vault.centos.org (vault.centos.org)|81.171.33.194|: | ||
| + | HTTP request sent, awaiting response... 200 OK | ||
| + | Length: 123000617 (117M) [application/ | ||
| + | Saving to: ‘kernel-4.18.0-305.7.1.el8_4.src.rpm’ | ||
| + | |||
| + | kernel-4.18.0-305.7.1. 100%[===========================> | ||
| + | |||
| + | 2021-07-14 02:55:33 (1.49 MB/s) - ‘kernel-4.18.0-305.7.1.el8_4.src.rpm’ saved [123000617/ | ||
| + | </ | ||
| + | |||
| + | Installez maintenant les dépendances pour le rpm source en tant que root : | ||
| + | |||
| + | < | ||
| + | [trainee@centos8 ~]$ su - | ||
| + | Mot de passe : fenestros | ||
| + | |||
| + | [root@centos8 ~]# dnf install yum-utils | ||
| + | ... | ||
| + | |||
| + | [root@centos8 ~]# yum-builddep / | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | Installez maintenant le paquet **kernel-4.18.0-305.7.1.el8_4.src.rpm** : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# exit | ||
| + | logout | ||
| + | [trainee@centos8 ~]$ rpm -Uvh kernel-4.18.0-305.7.1.el8_4.src.rpm | ||
| + | Updating / installing... | ||
| + | | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | ################################# | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | warning: user mockbuild does not exist - using root | ||
| + | warning: group mockbuild does not exist - using root | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | **Important** - Les erreurs sont sans importance. | ||
| + | </ | ||
| + | |||
| + | ====2.3 - Préparer l' | ||
| + | |||
| + | Naviguez vers le repertoire **~/ | ||
| + | |||
| + | < | ||
| + | [trainee@centos7 ~]$ cd ~/ | ||
| + | [trainee@centos7 SPECS]$ rpmbuild -bp --target=$(uname -m) kernel.spec | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | A l'issu du processus, examinez l' | ||
| + | |||
| + | < | ||
| + | [trainee@centos8 SPECS]$ ls -la ~/ | ||
| + | total 812 | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | -rw-r--r--. | ||
| + | -rw-r--r--. | ||
| + | drwxr-xr-x. | ||
| + | -rw-r--r--. | ||
| + | -rw-r--r--. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. 119 trainee trainee | ||
| + | drwxr-xr-x. 137 trainee trainee | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | -rw-r--r--. | ||
| + | -rw-r--r--. | ||
| + | -rw-r--r--. | ||
| + | -rw-r--r--. | ||
| + | -rw-r--r--. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | -rw-r--r--. | ||
| + | -rw-r--r--. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | -rw-r--r--. | ||
| + | -rw-r--r--. | ||
| + | -rw-r--r--. | ||
| + | -rw-r--r--. | ||
| + | -rw-r--r--. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | -rw-r--r--. | ||
| + | drwxr-xr-x. | ||
| + | -rw-r--r--. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | </ | ||
| + | |||
| + | ===Le Fichier .config=== | ||
| + | |||
| + | Changez de répertoire de travail : | ||
| + | |||
| + | < | ||
| + | [trainee@centos8 SPECS]$ cd ~/ | ||
| + | </ | ||
| + | |||
| + | Copiez le fichier **configs/ | ||
| + | |||
| + | < | ||
| + | [trainee@centos8 linux-4.18.0-305.7.1.el8.x86_64]$ cp configs/ | ||
| + | </ | ||
| + | |||
| + | Mettez à jour le fichier .config par rapport à la configuration actuelle du noyau : | ||
| + | |||
| + | < | ||
| + | [trainee@centos8 linux-4.18.0-305.7.1.el8.x86_64]$ make oldconfig | ||
| + | scripts/ | ||
| + | # | ||
| + | # configuration written to .config | ||
| + | # | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | **Important** - Cette commande lit le fichier .config du noyau actuel et le compare avec celui des sources du noyau. S'il existent des nouvelles configurations à effectuer dans les sources du noyau, la commande vous pose des questions. | ||
| + | </ | ||
| + | |||
| + | La configuration du noyau se trouve dans un fichier dénommé **.config**. Le fichier **.config** est généré par une des trois commandes suivantes et ne doit **pas** être édité manuellement : | ||
| + | |||
| + | * make config | ||
| + | * make menuconfig | ||
| + | * make xconfig | ||
| + | | ||
| + | Exécutez la commande **make menuconfig** : | ||
| + | |||
| + | < | ||
| + | [trainee@centos8 linux-4.18.0-305.7.1.el8.x86_64]$ make menuconfig | ||
| + | UPD | ||
| + | HOSTCC | ||
| + | HOSTCC | ||
| + | HOSTCC | ||
| + | HOSTCC | ||
| + | HOSTCC | ||
| + | HOSTCC | ||
| + | HOSTCC | ||
| + | HOSTLD | ||
| + | scripts/ | ||
| + | # | ||
| + | # using defaults found in / | ||
| + | # | ||
| + | </ | ||
| + | |||
| + | Dans l' | ||
| + | |||
| + | * **y**, | ||
| + | * la fonctionalité est incluse dans le noyau monolithique ou dans le cas d'une dépendance d'un module, dans le module concerné, | ||
| + | * **m**, | ||
| + | * la fonctionalité est incluse en tant que module, | ||
| + | * **n**, | ||
| + | * la fonctionalité n'est pas incluse. | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | **Important** - Cette commande permet la modification de la configuration du noyau. | ||
| + | </ | ||
| + | |||
| + | Sauvegardez simplement la configuration actuelle et sortez de l' | ||
| + | |||
| + | < | ||
| + | *** End of the configuration. | ||
| + | *** Execute ' | ||
| + | </ | ||
| + | |||
| + | Vérifiez que le fichier **.config** a été" créé par l' | ||
| + | |||
| + | < | ||
| + | [trainee@centos8 linux-4.18.0-305.7.1.el8.x86_64]$ ls -a | ||
| + | . certs configs | ||
| + | .. | ||
| + | arch | ||
| + | block .config | ||
| + | </ | ||
| + | |||
| + | Consultez ce fichier : | ||
| + | |||
| + | < | ||
| + | [trainee@centos8 linux-4.18.0-305.7.1.el8.x86_64]$ more .config | ||
| + | # | ||
| + | # Automatically generated file; DO NOT EDIT. | ||
| + | # Linux/x86 4.18.0 Kernel Configuration | ||
| + | # | ||
| + | |||
| + | # | ||
| + | # Compiler: gcc (GCC) 8.4.1 20200928 (Red Hat 8.4.1-1) | ||
| + | # | ||
| + | CONFIG_64BIT=y | ||
| + | CONFIG_X86_64=y | ||
| + | CONFIG_X86=y | ||
| + | CONFIG_INSTRUCTION_DECODER=y | ||
| + | CONFIG_OUTPUT_FORMAT=" | ||
| + | CONFIG_ARCH_DEFCONFIG=" | ||
| + | CONFIG_LOCKDEP_SUPPORT=y | ||
| + | CONFIG_STACKTRACE_SUPPORT=y | ||
| + | CONFIG_MMU=y | ||
| + | CONFIG_ARCH_MMAP_RND_BITS_MIN=28 | ||
| + | CONFIG_ARCH_MMAP_RND_BITS_MAX=32 | ||
| + | CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=8 | ||
| + | CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=16 | ||
| + | CONFIG_GENERIC_ISA_DMA=y | ||
| + | CONFIG_GENERIC_BUG=y | ||
| + | CONFIG_GENERIC_BUG_RELATIVE_POINTERS=y | ||
| + | CONFIG_GENERIC_HWEIGHT=y | ||
| + | CONFIG_ARCH_MAY_HAVE_PC_FDC=y | ||
| + | CONFIG_GENERIC_CALIBRATE_DELAY=y | ||
| + | CONFIG_ARCH_HAS_CPU_RELAX=y | ||
| + | CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y | ||
| + | CONFIG_ARCH_HAS_FILTER_PGPROT=y | ||
| + | CONFIG_HAVE_SETUP_PER_CPU_AREA=y | ||
| + | CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK=y | ||
| + | CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y | ||
| + | CONFIG_ARCH_HIBERNATION_POSSIBLE=y | ||
| + | CONFIG_ARCH_SUSPEND_POSSIBLE=y | ||
| + | CONFIG_ARCH_WANT_HUGE_PMD_SHARE=y | ||
| + | CONFIG_ARCH_WANT_GENERAL_HUGETLB=y | ||
| + | CONFIG_ZONE_DMA32=y | ||
| + | CONFIG_AUDIT_ARCH=y | ||
| + | CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y | ||
| + | CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y | ||
| + | CONFIG_HAVE_INTEL_TXT=y | ||
| + | CONFIG_X86_64_SMP=y | ||
| + | --More--(0%) | ||
| + | </ | ||
| + | |||
| + | ===Le Fichier Makefile=== | ||
| + | |||
| + | Le fichier **Makefile** contient le nom du noyau et spécifie les informations suivantes : | ||
| + | |||
| + | * VERSION, | ||
| + | * PATCHLEVEL, | ||
| + | * SUBLEVEL, | ||
| + | * EXTRAVERSION. | ||
| + | |||
| + | Les trois premières informations sont gérées par **kernel.org** et Linus Torvalds en personne tandis que l' | ||
| + | |||
| + | < | ||
| + | [trainee@centos8 linux-4.18.0-305.7.1.el8.x86_64]$ more Makefile | ||
| + | # SPDX-License-Identifier: | ||
| + | VERSION = 4 | ||
| + | PATCHLEVEL = 18 | ||
| + | SUBLEVEL = 0 | ||
| + | EXTRAVERSION = | ||
| + | NAME = Merciless Moray | ||
| + | |||
| + | # | ||
| + | # DRM backport version | ||
| + | # | ||
| + | RHEL_DRM_VERSION = 5 | ||
| + | RHEL_DRM_PATCHLEVEL = 9 | ||
| + | RHEL_DRM_SUBLEVEL = 14 | ||
| + | |||
| + | # *DOCUMENTATION* | ||
| + | # To see a list of typical targets execute "make help" | ||
| + | # More info can be located in ./README | ||
| + | # Comments in this file are targeted only to the developer, do not | ||
| + | # expect to learn how to build the kernel reading this file. | ||
| + | |||
| + | # That's our default target when none is given on the command line | ||
| + | PHONY := _all | ||
| + | _all: | ||
| + | |||
| + | # o Do not use make's built-in rules and variables | ||
| + | # (this increases performance and avoids hard-to-debug behaviour); | ||
| + | # o Look for make include files relative to root of kernel src | ||
| + | MAKEFLAGS += -rR --include-dir=$(CURDIR) | ||
| + | |||
| + | # Avoid funny character set dependencies | ||
| + | unexport LC_ALL | ||
| + | LC_COLLATE=C | ||
| + | LC_NUMERIC=C | ||
| + | export LC_COLLATE LC_NUMERIC | ||
| + | |||
| + | # Avoid interference with shell env settings | ||
| + | unexport GREP_OPTIONS | ||
| + | |||
| + | # Set RHEL variables | ||
| + | # Use this spot to avoid future merge conflicts | ||
| + | include Makefile.rhelver | ||
| + | |||
| + | # We are using a recursive build, so we need to do a little thinking | ||
| + | --Plus--(2%) | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | **Important** - La version 2.6 du noyau a vu le jour en **2003**. Les **SUBLEVEL** se suivaient régulièrement. Avec la version 2.6 du noyau, la valeur paire du **PATCHLEVEL** indiquait que le noyau était stable. Quand vous recompilez le noyau à partir des sources, vous devez modifier la valeur de l' | ||
| + | </ | ||
| + | |||
| + | ====2.4 - Paramétrage du noyau==== | ||
| + | |||
| + | Insérez la sortie de la commande **uname -i** sur la première ligne du fichier .config : | ||
| + | |||
| + | < | ||
| + | [trainee@centos8 linux-4.18.0-305.7.1.el8.x86_64]$ uname -i | ||
| + | x86_64 | ||
| + | [trainee@centos8 linux-4.18.0-305.7.1.el8.x86_64]$ vi .config | ||
| + | [trainee@centos8 linux-4.18.0-305.7.1.el8.x86_64]$ head .config | ||
| + | # x86_64 | ||
| + | # | ||
| + | # Automatically generated file; DO NOT EDIT. | ||
| + | # Linux/x86 4.18.0 Kernel Configuration | ||
| + | # | ||
| + | |||
| + | # | ||
| + | # Compiler: gcc (GCC) 8.4.1 20200928 (Red Hat 8.4.1-1) | ||
| + | # | ||
| + | CONFIG_64BIT=y | ||
| + | </ | ||
| + | |||
| + | Renommez le fichier .config en le plaçant dans le répertoire **~/ | ||
| + | |||
| + | < | ||
| + | [trainee@centos8 linux-4.18.0-305.7.1.el8.x86_64]$ cp .config ~/ | ||
| + | [trainee@centos8 linux-4.18.0-305.7.1.el8.x86_64]$ ls ~/ | ||
| + | centos-ca-secureboot.der | ||
| + | centos-dup.x509 | ||
| + | centos-kpatch.x509 | ||
| + | centos.pem | ||
| + | centossecureboot001.der | ||
| + | centossecureboot201.der | ||
| + | centossecurebootca2.der | ||
| + | check-kabi | ||
| + | config-x86_64-generic | ||
| + | </ | ||
| + | |||
| + | Copiez le contenu du répertoire **configs** vers le répertoire **~/ | ||
| + | |||
| + | < | ||
| + | [trainee@centos8 linux-4.18.0-305.7.1.el8.x86_64]$ cp configs/* ~/ | ||
| + | </ | ||
| + | |||
| + | Editez la directive **buildid** dans le fichier **~/ | ||
| + | |||
| + | < | ||
| + | [trainee@centos8 linux-4.18.0-305.7.1.el8.x86_64]$ cd ~/ | ||
| + | |||
| + | [trainee@centos8 SPECS]$ vi kernel.spec | ||
| + | |||
| + | [trainee@centos8 SPECS]$ head -n 50 kernel.spec | ||
| + | # We have to override the new %%install behavior because, well... the kernel is special. | ||
| + | %global __spec_install_pre %{___build_pre} | ||
| + | |||
| + | # At the time of this writing (2019-03), RHEL8 packages use w2.xzdio | ||
| + | # compression for rpms (xz, level 2). | ||
| + | # Kernel has several large (hundreds of mbytes) rpms, they take ~5 mins | ||
| + | # to compress by single-threaded xz. Switch to threaded compression, | ||
| + | # and from level 2 to 3 to keep compressed sizes close to " | ||
| + | # | ||
| + | # NB: if default compression in / | ||
| + | # this one might need tweaking (e.g. if default changes to w3.xzdio, | ||
| + | # change below to w4T.xzdio): | ||
| + | %define _binary_payload w3T.xzdio | ||
| + | |||
| + | # For a kernel released for public testing, released_kernel should be 1. | ||
| + | # For internal testing builds during development, | ||
| + | %global released_kernel 1 | ||
| + | |||
| + | %global distro_build 305 | ||
| + | |||
| + | # Sign the x86_64 kernel for secure boot authentication | ||
| + | %ifarch x86_64 aarch64 | ||
| + | %global signkernel 1 | ||
| + | %else | ||
| + | %global signkernel 0 | ||
| + | %endif | ||
| + | |||
| + | # Sign modules on all arches | ||
| + | %global signmodules 1 | ||
| + | |||
| + | # Compress modules only for architectures that build modules | ||
| + | %ifarch noarch | ||
| + | %global zipmodules 0 | ||
| + | %else | ||
| + | %global zipmodules 1 | ||
| + | %endif | ||
| + | |||
| + | %if %{zipmodules} | ||
| + | %global zipsed -e ' | ||
| + | %endif | ||
| + | |||
| + | %define buildid .i2tch | ||
| + | |||
| + | %define rpmversion 4.18.0 | ||
| + | %define pkgrelease 305.7.1.el8_4 | ||
| + | |||
| + | # allow pkg_release to have configurable %%{?dist} tag | ||
| + | %define specrelease 305.7.1%{? | ||
| + | |||
| + | %define pkg_release %{specrelease}%{? | ||
| + | </ | ||
| + | |||
| + | ====2.5 - Compiler le Noyau==== | ||
| + | |||
| + | La compilation du noyau peut prendre beaucoup de temps (~5 heures). La commande utilisée est la suivante : | ||
| + | |||
| + | < | ||
| + | [trainee@centos7 SPECS]$ rpmbuild -bb --target=`uname -m` kernel.spec 2> build-err.log | tee build-out.log & | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | **Important** - La compilation peut prendre des heures. Arrêtez donc le processus avec les touches ^C. Arrêtez ensuite votre VM. Demandez à votre formateur de démarrer la VM contenant le noyau déjà compilé. | ||
| + | </ | ||
| + | |||
| + | A l'issu du processus, les RPMs se trouvent dans le répertoire **/ | ||
| + | |||
| + | < | ||
| + | ... | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Wrote: / | ||
| + | Executing(%clean): | ||
| + | |||
| + | [1]+ Done rpmbuild -bb --target=`uname -m` kernel.spec 2> build-err.log | tee build-out.log | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | [trainee@centos8 SPECS]$ cd ../RPMS | ||
| + | [trainee@centos8 RPMS]$ ls | ||
| + | x86_64 | ||
| + | [trainee@centos8 RPMS]$ cd x86_64/ | ||
| + | [trainee@centos8 x86_64]$ ls | ||
| + | bpftool-4.18.0-305.7.1.el8.i2tch.x86_64.rpm | ||
| + | bpftool-debuginfo-4.18.0-305.7.1.el8.i2tch.x86_64.rpm | ||
| + | kernel-4.18.0-305.7.1.el8.i2tch.x86_64.rpm | ||
| + | kernel-core-4.18.0-305.7.1.el8.i2tch.x86_64.rpm | ||
| + | kernel-cross-headers-4.18.0-305.7.1.el8.i2tch.x86_64.rpm | ||
| + | kernel-debug-4.18.0-305.7.1.el8.i2tch.x86_64.rpm | ||
| + | kernel-debug-core-4.18.0-305.7.1.el8.i2tch.x86_64.rpm | ||
| + | kernel-debug-debuginfo-4.18.0-305.7.1.el8.i2tch.x86_64.rpm | ||
| + | kernel-debug-devel-4.18.0-305.7.1.el8.i2tch.x86_64.rpm | ||
| + | kernel-debuginfo-4.18.0-305.7.1.el8.i2tch.x86_64.rpm | ||
| + | </ | ||
| + | |||
| + | Notez que la génération du nouveau noyau peut consommer jusqu' | ||
| + | |||
| + | < | ||
| + | [trainee@centos8 x86_64]$ df -h | ||
| + | Filesystem | ||
| + | devtmpfs | ||
| + | tmpfs 1.9G | ||
| + | tmpfs 1.9G 9.4M 1.9G 1% /run | ||
| + | tmpfs 1.9G | ||
| + | / | ||
| + | / | ||
| + | tmpfs 374M | ||
| + | tmpfs 374M 1.2M 373M 1% / | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | ====2.6 - Installer le Nouveau Noyau==== | ||
| + | |||
| + | Installez maintenant les paquets **kernel***. L' | ||
| + | |||
| + | < | ||
| + | [root@centos8 x86_64]# dnf localinstall kernel-*.rpm | ||
| + | Last metadata expiration check: 2:25:32 ago on Tue 20 Jul 2021 08:37:00 EDT. | ||
| + | Dependencies resolved. | ||
| + | =============================================================================================================================================================================================================== | ||
| + | | ||
| + | =============================================================================================================================================================================================================== | ||
| + | Installing: | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | Downgrading: | ||
| + | | ||
| + | | ||
| + | | ||
| + | |||
| + | Transaction Summary | ||
| + | =============================================================================================================================================================================================================== | ||
| + | Install | ||
| + | Downgrade | ||
| + | |||
| + | Total size: 1.6 G | ||
| + | Is this ok [y/N]: y | ||
| + | </ | ||
| + | |||
| + | A l'issu de l' | ||
| + | |||
| + | < | ||
| + | [root@centos7 ~]# reboot | ||
| + | </ | ||
| + | |||
| + | Connectez-vous en tant que trainee et devenez root. Listez ensuite les noyaux installés : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# rpm -qa | grep kernel | ||
| + | kernel-modules-4.18.0-305.3.1.el8.x86_64 | ||
| + | kernel-tools-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | kernel-headers-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | kernel-debuginfo-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | kernel-debug-core-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | kernel-modules-internal-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | kernel-modules-4.18.0-305.7.1.el8_4.x86_64 | ||
| + | kernel-debug-modules-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | kernel-devel-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | kernel-tools-debuginfo-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | kernel-tools-libs-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | kernel-debug-modules-internal-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | kernel-cross-headers-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | kernel-core-4.18.0-305.7.1.el8_4.x86_64 | ||
| + | kernel-devel-4.18.0-305.7.1.el8_4.x86_64 | ||
| + | kernel-debuginfo-common-x86_64-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | kernel-debug-modules-extra-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | kernel-debug-devel-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | kernel-tools-libs-devel-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | kernel-modules-extra-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | kernel-4.18.0-305.7.1.el8_4.x86_64 | ||
| + | kernel-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | kernel-core-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | kernel-selftests-internal-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | kernel-debug-debuginfo-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | kernel-debug-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | kernel-4.18.0-305.3.1.el8.x86_64 | ||
| + | kernel-core-4.18.0-305.3.1.el8.x86_64 | ||
| + | kernel-modules-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | kernel-ipaclones-internal-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | </ | ||
| + | |||
| + | Constatez l' | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# grep i2tch / | ||
| + | saved_entry=95bd69e34a7444a7b58cb74fbfb86df2-4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | </ | ||
| + | |||
| + | Dernièrement, | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# uname -r | ||
| + | 4.18.0-305.7.1.el8.i2tch.x86_64 | ||
| + | </ | ||
| + | |||
| + | =====LAB #3 - Gestion des Quotas===== | ||
| + | |||
| + | Sous Linux il est possible de mettre en place des quotas par utilisateur et par groupe. Ceci étant, Linux ne sait pas gérer des quotas par répertoire, | ||
| + | quotas par partition. L' | ||
| + | |||
| + | Déconnectez-vous et reconnectez-vous **directement** en tant que root : | ||
| + | |||
| + | < | ||
| + | root@computeXX: | ||
| + | root@10.0.2.45' | ||
| + | Activate the web console with: systemctl enable --now cockpit.socket | ||
| + | |||
| + | Last login: Wed Jul 21 11:14:31 2021 | ||
| + | [root@centos8 ~]# | ||
| + | </ | ||
| + | |||
| + | Avant de mettre en place des quotas, configurer SELINUX en mode **permissive** afin de ne pas avoir d' | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# getenforce | ||
| + | Enforcing | ||
| + | [root@centos8 ~]# setenforce permissive | ||
| + | [root@centos8 ~]# getenforce | ||
| + | Permissive | ||
| + | [root@centos8 ~]# | ||
| + | </ | ||
| + | |||
| + | Editez ensuite le fichier / | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# vi / | ||
| + | [root@centos8 ~]# cat / | ||
| + | |||
| + | # This file controls the state of SELinux on the system. | ||
| + | # SELINUX= can take one of these three values: | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | SELINUX=permissive | ||
| + | # SELINUXTYPE= can take one of these three values: | ||
| + | # | ||
| + | # | ||
| + | # mls - Multi Level Security protection. | ||
| + | SELINUXTYPE=targeted | ||
| + | |||
| + | </ | ||
| + | |||
| + | Commencez par vérifiez que le paquet **quota** est bien installé : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# rpm -qa | grep quota | ||
| + | quota-4.04-12.el8.x86_64 | ||
| + | quota-nls-4.04-12.el8.noarch | ||
| + | </ | ||
| + | |||
| + | Editez le fichier **/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# vi /etc/fstab | ||
| + | [root@centos8 ~]# cat /etc/fstab | ||
| + | |||
| + | # | ||
| + | # /etc/fstab | ||
| + | # Created by anaconda on Wed Jun 16 06:21:32 2021 | ||
| + | # | ||
| + | # Accessible filesystems, | ||
| + | # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info. | ||
| + | # | ||
| + | # After editing this file, run ' | ||
| + | # units generated from this file. | ||
| + | # | ||
| + | / | ||
| + | UUID=1c04981e-5317-4b73-9695-3ce25246835d /boot | ||
| + | / | ||
| + | UUID=f76d6b66-985b-4a91-af9c-4987e8c1443c /home | ||
| + | </ | ||
| + | |||
| + | Redémarrez la VM : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# reboot | ||
| + | </ | ||
| + | |||
| + | Reconnectez-vous **directement** en tant que root : | ||
| + | |||
| + | < | ||
| + | root@computeXX: | ||
| + | root@10.0.2.45' | ||
| + | Activate the web console with: systemctl enable --now cockpit.socket | ||
| + | |||
| + | Last login: Wed Jul 21 11:19:46 2021 | ||
| + | [root@centos8 ~]# | ||
| + | </ | ||
| + | |||
| + | Vérifiez ensuite que les options **usrquota** et **grpquota** soient prises en compte : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cat /etc/mtab | grep /home | ||
| + | /dev/sdc1 /home ext4 rw, | ||
| + | </ | ||
| + | |||
| + | ====3.1 - La Commande quotacheck==== | ||
| + | |||
| + | Pour activer les quotas sur /home, il convient d' | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# quotacheck -cugvm -f /dev/sdc1 | ||
| + | quotacheck: Your kernel probably supports journaled quota but you are not using it. Consider switching to journaled quota to avoid running quotacheck after an unclean shutdown. | ||
| + | quotacheck: Scanning /dev/sdc1 [/home] done | ||
| + | quotacheck: Cannot stat old user quota file / | ||
| + | quotacheck: Cannot stat old group quota file / | ||
| + | quotacheck: Cannot stat old user quota file / | ||
| + | quotacheck: Cannot stat old group quota file / | ||
| + | quotacheck: Checked 6763 directories and 129772 files | ||
| + | quotacheck: Old file not found. | ||
| + | quotacheck: Old file not found. | ||
| + | </ | ||
| + | |||
| + | Les options de la commande quotacheck sont : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# quotacheck --help | ||
| + | Utility for checking and repairing quota files. | ||
| + | quotacheck [-gucbfinvdmMR] [-F < | ||
| + | |||
| + | -u, --user | ||
| + | -g, --group | ||
| + | -c, --create-files | ||
| + | -b, --backup | ||
| + | -f, --force | ||
| + | -i, --interactive | ||
| + | -n, --use-first-dquot | ||
| + | -v, --verbose | ||
| + | -d, --debug | ||
| + | -m, --no-remount | ||
| + | -M, --try-remount | ||
| + | continue even if it fails | ||
| + | -R, --exclude-root | ||
| + | -F, --format=formatname | ||
| + | -a, --all check all filesystems | ||
| + | -h, --help | ||
| + | -V, --version | ||
| + | |||
| + | Bugs to jack@suse.cz | ||
| + | </ | ||
| + | |||
| + | Les quotas ont été activés et les fichier **aquota.user** et **aquota.group** ont été créés dans le répertoire /home : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# ls -la /home | ||
| + | total 40 | ||
| + | drwxr-xr-x. | ||
| + | dr-xr-xr-x. 17 root root 224 Jul 19 12:05 .. | ||
| + | -rw-------. | ||
| + | -rw-------. | ||
| + | drwx------. | ||
| + | drwxr-xr-x. 17 trainee trainee | ||
| + | </ | ||
| + | |||
| + | Créez maintenant un utilisateur **fenestros** avec le mot de passe **fenestros** : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# groupadd fenestros && useradd fenestros -c FenestrOs -d / | ||
| + | [root@centos8 ~]# passwd fenestros | ||
| + | Changing password for user fenestros. | ||
| + | New password: | ||
| + | BAD PASSWORD: The password contains the user name in some form | ||
| + | Retype new password: | ||
| + | passwd: all authentication tokens updated successfully. | ||
| + | </ | ||
| + | |||
| + | ====3.2 - La Commande edquota==== | ||
| + | |||
| + | Mettez en place maintenant un quota de 10Mo pour l' | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# edquota -u fenestros -f /home | ||
| + | </ | ||
| + | |||
| + | L' | ||
| + | |||
| + | < | ||
| + | Disk quotas for user fenestros (uid 1001): | ||
| + | Filesystem | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | Modifiez ce fichier ainsi : | ||
| + | |||
| + | < | ||
| + | Disk quotas for user fenestros (uid 1001): | ||
| + | Filesystem | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | Sauvegardez et quittez le fichier. | ||
| + | |||
| + | Les options de la commande **edquota** sont : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# edquota --help | ||
| + | edquota: Usage: | ||
| + | edquota [-rm] [-u] [-F formatname] [-p username] [-f filesystem] username ... | ||
| + | edquota [-rm] -g [-F formatname] [-p groupname] [-f filesystem] groupname ... | ||
| + | edquota [-rm] -P [-F formatname] [-p projectname] [-f filesystem] projectname ... | ||
| + | edquota [-u|g|-P] [-F formatname] [-f filesystem] -t | ||
| + | edquota [-u|g|-P] [-F formatname] [-f filesystem] -T username|groupname|projectname ... | ||
| + | |||
| + | -u, --user | ||
| + | -g, --group | ||
| + | -P, --project | ||
| + | -r, --remote | ||
| + | -m, --no-mixed-pathnames | ||
| + | -F, --format=formatname | ||
| + | -p, --prototype=name | ||
| + | --always-resolve | ||
| + | composed only of digits | ||
| + | -f, --filesystem=filesystem | ||
| + | -t, --edit-period | ||
| + | -T, --edit-times | ||
| + | -h, --help | ||
| + | -V, --version | ||
| + | |||
| + | Bugs to: jack@suse.cz | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | **Important** - Pour mettre en place un quota par group, la procédure est similaire. Il suffit d' | ||
| + | </ | ||
| + | |||
| + | ====3.3 - La Commande quotaon==== | ||
| + | |||
| + | Appliquez maintenant les quotas : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# quotaon -a | ||
| + | </ | ||
| + | |||
| + | Les options de la commande **quotaon** sont : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# quotaon --help | ||
| + | quotaon: Usage: | ||
| + | quotaon [-guPvp] [-F quotaformat] [-x state] -a | ||
| + | quotaon [-guPvp] [-F quotaformat] [-x state] filesys ... | ||
| + | |||
| + | -a, --all turn quotas on for all filesystems | ||
| + | -f, --off turn quotas off | ||
| + | -u, --user | ||
| + | -g, --group | ||
| + | -P, --project | ||
| + | -p, --print-state | ||
| + | -x, --xfs-command=cmd | ||
| + | -F, --format=formatname | ||
| + | -v, --verbose | ||
| + | -h, --help | ||
| + | -V, --version | ||
| + | </ | ||
| + | |||
| + | De cette manière vous avez mis en place un quota **souple** pour fenestros de 8 000 Ko et un quota **stricte** de 10 000 Ko. | ||
| + | |||
| + | Quand l' | ||
| + | |||
| + | Il est à noter que vous pouvez soit mettre en place un quota en taille, soit mettre en place un quota basé sur le nombre d' | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | **important** - La commande pour désactivez les quotas est **quotaoff**. | ||
| + | </ | ||
| + | |||
| + | ====3.4 - La Commande repquota==== | ||
| + | |||
| + | Pour visualiser les quotas utilisez la commande **repquota** : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# repquota /home | ||
| + | *** Report for user quotas on device /dev/sdc1 | ||
| + | Block grace time: 7days; Inode grace time: 7days | ||
| + | Block limits | ||
| + | User used soft hard grace used soft hard grace | ||
| + | ---------------------------------------------------------------------- | ||
| + | root -- 20 | ||
| + | trainee | ||
| + | |||
| + | </ | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | **Important** - Notez que l' | ||
| + | </ | ||
| + | |||
| + | Les options de la commande **repquota** sont : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# repquota --help | ||
| + | repquota: Utility for reporting quotas. | ||
| + | Usage: | ||
| + | repquota [-vugsi] [-c|C] [-t|n] [-F quotaformat] [-O (default | xml | csv)] (-a | mntpoint) | ||
| + | |||
| + | -v, --verbose | ||
| + | -u, --user | ||
| + | -g, --group | ||
| + | -P, --project | ||
| + | -s, --human-readable | ||
| + | -t, --truncate-names | ||
| + | -p, --raw-grace | ||
| + | -n, --no-names | ||
| + | -i, --no-autofs | ||
| + | -c, --cache | ||
| + | -C, --no-cache | ||
| + | -F, --format=formatname | ||
| + | -O, --output=format | ||
| + | -a, --all | ||
| + | -h, --help | ||
| + | -V, --version | ||
| + | |||
| + | Bugs to jack@suse.cz | ||
| + | </ | ||
| + | |||
| + | ====3.5 - La Commande quota==== | ||
| + | |||
| + | Pour visualiser les quotas d'un utilisateur spécifique, | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# quota fenestros | ||
| + | Disk quotas for user fenestros (uid 1001): no limited resources used | ||
| + | [root@centos8 ~]# su - fenestros | ||
| + | [fenestros@centos8 ~]$ touch test | ||
| + | [fenestros@centos8 ~]$ exit | ||
| + | logout | ||
| + | [root@centos8 ~]# quota fenestros | ||
| + | Disk quotas for user fenestros (uid 1001): | ||
| + | | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | Les options de la commande **quota** sont : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# quota --help | ||
| + | quota: Usage: quota [-guPqvswim] [-l | [-Q | -A]] [-F quotaformat] | ||
| + | quota [-qvswim] [-l | [-Q | -A]] [-F quotaformat] -u username ... | ||
| + | quota [-qvswim] [-l | [-Q | -A]] [-F quotaformat] -g groupname ... | ||
| + | quota [-qvswugPQm] [-F quotaformat] -f filesystem ... | ||
| + | |||
| + | -u, --user | ||
| + | -g, --group | ||
| + | -P, --project | ||
| + | -q, --quiet | ||
| + | -v, --verbose | ||
| + | -s, --human-readable | ||
| + | --always-resolve | ||
| + | composed of only digits | ||
| + | -w, --no-wrap | ||
| + | -p, --raw-grace | ||
| + | -l, --local-only | ||
| + | -Q, --quiet-refuse | ||
| + | not respond | ||
| + | -i, --no-autofs | ||
| + | -F, --format=formatname | ||
| + | -f, --filesystem-list | ||
| + | -A, --all-nfs | ||
| + | -m, --no-mixed-pathnames | ||
| + | --show-mntpoint | ||
| + | --hide-device | ||
| + | -h, --help | ||
| + | -V, --version | ||
| + | |||
| + | Bugs to: jack@suse.cz | ||
| + | </ | ||
| + | |||
| + | ====3.6 - La Commande warnquota==== | ||
| + | |||
| + | La commande **warnquota** vérifie le ou les disques et envoie un message par mail à tout utilisateur qui a dépassé la limite soft. Elle est enrègle générale appelée par un job cron. Cependant elle peut aussi est appelée d'une manière intéractive. | ||
| + | |||
| + | Sous RHEL/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# which warnquota | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | Installez donc le paquet **quota-warnquota** : | ||
| + | |||
| + | < | ||
| + | [root@centos7 ~]# dnf install quota-warnquota | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | Les options de la commande **warnquota** sont : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# warnquota --help | ||
| + | warnquota: Usage: | ||
| + | warnquota [-ugsid] [-F quotaformat] [-c configfile] [-q quotatabfile] [-a adminsfile] [filesystem...] | ||
| + | |||
| + | -u, --user | ||
| + | -g, --group | ||
| + | -s, --human-readable | ||
| + | -i, --no-autofs | ||
| + | -d, --no-details | ||
| + | -F, --format=formatname | ||
| + | -c, --config=config-file | ||
| + | -q, --quota-tab=quotatab-file | ||
| + | -a, --admins-file=admins-file | ||
| + | -h, --help | ||
| + | -v, --version | ||
| + | |||
| + | warnquota: Bugs to jack@suse.cz | ||
| + | </ | ||
| + | |||
| + | ----- | ||
| + | Copyright © 2024 Hugh Norris. | ||