Version : 2022.01
Dernière mise-à-jour : 2023/02/15 15:57
Le noyau ou kernel est la partie du système d'exploitation qui gère les entrées/sorties avec des périphériques. Dans certains cas il est préférable de recompiler le noyau de Linux. La motivation de cette recompilation peut être :
Commencez par identifier le noyau utilisé par votre machine :
[root@centos7 ~]# uname -r 3.10.0-327.13.1.el7.x86_64
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 /lib/modules/<version-du-noyau> :
[root@centos7 ~]# ls /lib/modules/`uname -r`/ build modules.alias modules.builtin modules.dep.bin modules.modesetting modules.softdep source weak-updates extra modules.alias.bin modules.builtin.bin modules.devname modules.networking modules.symbols updates kernel modules.block modules.dep modules.drm modules.order modules.symbols.bin vdso
Les commandes pour manipuler les modules sont :
Par exemple :
[root@centos7 ~]# lsmod Module Size Used by ip6t_rpfilter 12546 1 ip6t_REJECT 12939 2 ipt_REJECT 12541 2 xt_conntrack 12760 9 ebtable_nat 12807 0 ebtable_broute 12731 0 bridge 119562 1 ebtable_broute stp 12976 1 bridge llc 14552 2 stp,bridge ebtable_filter 12827 0 ebtables 30913 3 ebtable_broute,ebtable_nat,ebtable_filter ip6table_nat 12864 1 nf_conntrack_ipv6 18738 6 nf_defrag_ipv6 34768 1 nf_conntrack_ipv6 nf_nat_ipv6 14131 1 ip6table_nat ip6table_mangle 12700 1 ip6table_security 12710 1 ip6table_raw 12683 1 ip6table_filter 12815 1 ip6_tables 27025 5 ip6table_filter,ip6table_mangle,ip6table_security,ip6table_nat,ip6table_raw iptable_nat 12875 1 nf_conntrack_ipv4 14862 5 nf_defrag_ipv4 12729 1 nf_conntrack_ipv4 nf_nat_ipv4 14115 1 iptable_nat nf_nat 26146 2 nf_nat_ipv4,nf_nat_ipv6 nf_conntrack 105745 6 nf_nat,nf_nat_ipv4,nf_nat_ipv6,xt_conntrack,nf_conntrack_ipv4,nf_conntrack_ipv6 iptable_mangle 12695 1 iptable_security 12705 1 iptable_raw 12678 1 iptable_filter 12810 1 dm_mirror 22135 0 dm_region_hash 20862 1 dm_mirror dm_log 18411 2 dm_region_hash,dm_mirror dm_mod 113292 2 dm_log,dm_mirror crc32_pclmul 13113 0 ghash_clmulni_intel 13259 0 aesni_intel 69884 0 lrw 13286 1 aesni_intel gf128mul 14951 1 lrw glue_helper 13990 1 aesni_intel snd_intel8x0 38274 1 ablk_helper 13597 1 aesni_intel cryptd 20359 3 ghash_clmulni_intel,aesni_intel,ablk_helper snd_ac97_codec 130605 1 snd_intel8x0 ac97_bus 12730 1 snd_ac97_codec ppdev 17671 0 snd_seq 66691 0 snd_seq_device 14356 1 snd_seq snd_pcm 105835 2 snd_ac97_codec,snd_intel8x0 pcspkr 12718 0 sg 40721 0 parport_pc 28165 0 parport 42348 2 ppdev,parport_pc snd_timer 29639 2 snd_pcm,snd_seq snd 83425 8 snd_ac97_codec,snd_intel8x0,snd_timer,snd_pcm,snd_seq,snd_seq_device soundcore 15047 1 snd i2c_piix4 22106 0 video 24400 0 i2c_core 40582 1 i2c_piix4 nfsd 302418 1 auth_rpcgss 59343 1 nfsd nfs_acl 12837 1 nfsd lockd 93600 1 nfsd grace 13295 2 nfsd,lockd sunrpc 300464 7 nfsd,auth_rpcgss,lockd,nfs_acl ip_tables 27240 5 iptable_security,iptable_filter,iptable_mangle,iptable_nat,iptable_raw xfs 939662 2 libcrc32c 12644 1 xfs sd_mod 45497 4 crc_t10dif 12714 1 sd_mod crct10dif_generic 12647 0 sr_mod 22416 0 cdrom 42556 1 sr_mod ata_generic 12910 0 pata_acpi 13038 0 ahci 29907 3 libahci 32031 1 ahci ata_piix 35038 0 crct10dif_pclmul 14289 1 crct10dif_common 12595 3 crct10dif_pclmul,crct10dif_generic,crc_t10dif crc32c_intel 22079 1 serio_raw 13462 0 libata 218730 5 ahci,pata_acpi,libahci,ata_generic,ata_piix e1000 149323 0
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@centos7 ~]# modprobe bonding [root@centos7 ~]# lsmod | more Module Size Used by bonding 136705 0 ip6t_rpfilter 12546 1 ip6t_REJECT 12939 2 ipt_REJECT 12541 2 xt_conntrack 12760 9 ebtable_nat 12807 0 ebtable_broute 12731 0 bridge 119562 1 ebtable_broute stp 12976 1 bridge llc 14552 2 stp,bridge ebtable_filter 12827 0 ebtables 30913 3 ebtable_broute,ebtable_nat,ebtable_filter ip6table_nat 12864 1 nf_conntrack_ipv6 18738 6 nf_defrag_ipv6 34768 1 nf_conntrack_ipv6 nf_nat_ipv6 14131 1 ip6table_nat ip6table_mangle 12700 1 ip6table_security 12710 1 ip6table_raw 12683 1 ip6table_filter 12815 1 ip6_tables 27025 5 ip6table_filter,ip6table_mangle,ip6table_securit y,ip6table_nat,ip6table_raw --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@centos7 ~]# modprobe -r bonding [root@centos7 ~]# lsmod | more Module Size Used by ip6t_rpfilter 12546 1 ip6t_REJECT 12939 2 ipt_REJECT 12541 2 xt_conntrack 12760 9 ebtable_nat 12807 0 ebtable_broute 12731 0 bridge 119562 1 ebtable_broute stp 12976 1 bridge llc 14552 2 stp,bridge ebtable_filter 12827 0 ebtables 30913 3 ebtable_broute,ebtable_nat,ebtable_filter ip6table_nat 12864 1 nf_conntrack_ipv6 18738 6 nf_defrag_ipv6 34768 1 nf_conntrack_ipv6 nf_nat_ipv6 14131 1 ip6table_nat ip6table_mangle 12700 1 ip6table_security 12710 1 ip6table_raw 12683 1 ip6table_filter 12815 1 ip6_tables 27025 5 ip6table_filter,ip6table_mangle,ip6table_securit y,ip6table_nat,ip6table_raw iptable_nat 12875 1 --More--
Les dépendances des modules sont résolues par la commande modprobe grâce aux fichier /lib/modules/<version-du-noyau>/modules.dep. Ce dernier peut être créé manuellement grâce à la commande depmod :
[root@centos7 ~]# more /lib/modules/`uname -r`/modules.dep kernel/arch/x86/kernel/cpu/mcheck/mce-inject.ko: kernel/arch/x86/kernel/test_nx.ko: kernel/arch/x86/crypto/ablk_helper.ko: kernel/crypto/cryptd.ko kernel/arch/x86/crypto/glue_helper.ko: kernel/arch/x86/crypto/camellia-x86_64.ko: kernel/crypto/xts.ko kernel/crypto/lrw.ko kernel/crypto/gf128mul.ko kernel/arch/x86/crypto/glue_helper.ko kernel/arch/x86/crypto/blowfish-x86_64.ko: kernel/crypto/blowfish_common.ko kernel/arch/x86/crypto/twofish-x86_64.ko: kernel/crypto/twofish_common.ko kernel/arch/x86/crypto/twofish-x86_64-3way.ko: kernel/arch/x86/crypto/twofish-x86_64.ko kernel/crypto/twofish_common.ko kernel/crypto/xts.ko kernel/cryp to/lrw.ko kernel/crypto/gf128mul.ko kernel/arch/x86/crypto/glue_helper.ko kernel/arch/x86/crypto/salsa20-x86_64.ko: kernel/arch/x86/crypto/serpent-sse2-x86_64.ko: kernel/crypto/xts.ko kernel/crypto/serpent_generic.ko kernel/crypto/lrw.ko kernel/crypto/gf128mul.ko kern el/arch/x86/crypto/glue_helper.ko kernel/arch/x86/crypto/ablk_helper.ko kernel/crypto/cryptd.ko kernel/arch/x86/crypto/aesni-intel.ko: kernel/crypto/lrw.ko kernel/crypto/gf128mul.ko kernel/arch/x86/crypto/glue_helper.ko kernel/arch/x86/crypto/ablk_ helper.ko kernel/crypto/cryptd.ko kernel/arch/x86/crypto/ghash-clmulni-intel.ko: kernel/crypto/cryptd.ko kernel/arch/x86/crypto/crc32c-intel.ko: kernel/arch/x86/crypto/sha-mb/sha1-mb.ko: kernel/crypto/mcryptd.ko kernel/arch/x86/crypto/crc32-pclmul.ko: kernel/arch/x86/crypto/sha512-ssse3.ko: kernel/crypto/sha512_generic.ko kernel/arch/x86/crypto/crct10dif-pclmul.ko: kernel/crypto/crct10dif_common.ko kernel/arch/x86/crypto/camellia-aesni-avx-x86_64.ko: kernel/arch/x86/crypto/camellia-x86_64.ko kernel/crypto/xts.ko kernel/crypto/lrw.ko kernel/crypto/g f128mul.ko kernel/arch/x86/crypto/glue_helper.ko kernel/arch/x86/crypto/ablk_helper.ko kernel/crypto/cryptd.ko kernel/arch/x86/crypto/cast5-avx-x86_64.ko: kernel/crypto/cast5_generic.ko kernel/crypto/cast_common.ko kernel/arch/x86/crypto/ablk_helper.ko kernel/cry --More--(0%)
Il est possible d'obtenir des informations sur un module grâce à la commande modinfo :
[root@centos7 ~]# modinfo bonding filename: /lib/modules/3.10.0-327.13.1.el7.x86_64/kernel/drivers/net/bonding/bonding.ko author: Thomas Davis, tadavis@lbl.gov and many others description: Ethernet Channel Bonding Driver, v3.7.1 version: 3.7.1 license: GPL alias: rtnl-link-bond rhelversion: 7.2 srcversion: 49765A3F5CDFF2C3DCFD8E6 depends: intree: Y vermagic: 3.10.0-327.13.1.el7.x86_64 SMP mod_unload modversions signer: CentOS Linux kernel signing key sig_key: 6F:33:78:18:7D:83:CD:18:A4:3B:2E:0A:C4:9A:ED:8A:EF:FC:3A:C7 sig_hashalgo: sha256 parm: max_bonds:Max number of bonded devices (int) parm: tx_queues:Max number of transmit queues (default = 16) (int) parm: num_grat_arp:Number of peer notifications to send on failover event (alias of num_unsol_na) (int) parm: num_unsol_na:Number of peer notifications to send on failover event (alias of num_grat_arp) (int) parm: miimon:Link check interval in milliseconds (int) parm: updelay:Delay before considering link up, in milliseconds (int) parm: downdelay:Delay before considering link down, in milliseconds (int) parm: use_carrier:Use netif_carrier_ok (vs MII ioctls) in miimon; 0 for off, 1 for on (default) (int) parm: mode:Mode of operation; 0 for balance-rr, 1 for active-backup, 2 for balance-xor, 3 for broadcast, 4 for 802.3ad, 5 for balance-tlb, 6 for balance-alb (charp) parm: primary:Primary network device to use (charp) parm: primary_reselect:Reselect primary slave once it comes up; 0 for always (default), 1 for only if speed of primary is better, 2 for only on active slave failure (charp) parm: lacp_rate:LACPDU tx rate to request from 802.3ad partner; 0 for slow, 1 for fast (charp) parm: ad_select:803.ad aggregation selection logic; 0 for stable (default), 1 for bandwidth, 2 for count (charp) parm: min_links:Minimum number of available links before turning on carrier (int) parm: xmit_hash_policy:balance-xor and 802.3ad hashing method; 0 for layer 2 (default), 1 for layer 3+4, 2 for layer 2+3, 3 for encap layer 2+3, 4 for encap layer 3+4 (charp) parm: arp_interval:arp interval in milliseconds (int) parm: arp_ip_target:arp targets in n.n.n.n form (array of charp) parm: arp_validate:validate src/dst of ARP probes; 0 for none (default), 1 for active, 2 for backup, 3 for all (charp) parm: arp_all_targets:fail on any/all arp targets timeout; 0 for any (default), 1 for all (charp) parm: fail_over_mac:For active-backup, do not set all slaves to the same MAC; 0 for none (default), 1 for active, 2 for follow (charp) parm: all_slaves_active:Keep all frames received on an interface by setting active flag for all slaves; 0 for never (default), 1 for always. (int) parm: resend_igmp:Number of IGMP membership reports to send on link failure (int) parm: packets_per_slave:Packets to send per slave in balance-rr mode; 0 for a random slave, 1 packet per slave (default), >1 packets per slave. (int) parm: lp_interval:The number of seconds between instances where the bonding driver sends learning packets to each slaves peer switch. The default is 1. (uint)
Dernièrement, les fichiers dans le repertoire /etc/modprobe.d sont utilisés pour spécifier les options éventuelles à passer aux modules lors de leur chargement ainsi que les alias utilisés pour leur faire référence :
[root@centos7 ~]# ls /etc/modprobe.d mlx4.conf [root@centos7 ~]# cat /etc/modprobe.d/mlx4.conf # This file is intended for users to select the various module options # they need for the mlx4 driver. On upgrade of the rdma package, # any user made changes to this file are preserved. Any changes made # to the libmlx4.conf file in this directory are overwritten on # pacakge upgrade. # # Some sample options and what they would do # Enable debugging output, device managed flow control, and disable SRIOV #options mlx4_core debug_level=1 log_num_mgm_entry_size=-1 probe_vf=0 num_vfs=0 # # Enable debugging output and create SRIOV devices, but don't attach any of # the child devices to the host, only the parent device #options mlx4_core debug_level=1 probe_vf=0 num_vfs=7 # # Enable debugging output, SRIOV, and attach one of the SRIOV child devices # in addition to the parent device to the host #options mlx4_core debug_level=1 probe_vf=1 num_vfs=7 # # Enable per priority flow control for send and receive, setting both priority # 1 and 2 as no drop priorities #options mlx4_en pfctx=3 pfcrx=3
Commencez par installer les paquets necessaires :
[root@centos7 ~]# yum install qt3-devel libXi-devel gcc-c++ rpmdevtools ncurses-devel Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: centos.mirrors.ovh.net * extras: centos.mirror.fr.planethoster.net * updates: mirror1.evolution-host.com Resolving Dependencies --> Running transaction check ---> Package gcc-c++.x86_64 0:4.8.5-4.el7 will be installed --> Processing Dependency: libstdc++-devel = 4.8.5-4.el7 for package: gcc-c++-4.8.5-4.el7.x86_64 ---> Package libXi-devel.x86_64 0:1.7.4-2.el7 will be installed --> Processing Dependency: xorg-x11-proto-devel for package: libXi-devel-1.7.4-2.el7.x86_64 --> Processing Dependency: pkgconfig(xfixes) for package: libXi-devel-1.7.4-2.el7.x86_64 --> Processing Dependency: pkgconfig(xext) for package: libXi-devel-1.7.4-2.el7.x86_64 --> Processing Dependency: pkgconfig(x11) for package: libXi-devel-1.7.4-2.el7.x86_64 --> Processing Dependency: pkgconfig(inputproto) for package: libXi-devel-1.7.4-2.el7.x86_64 ---> Package ncurses-devel.x86_64 0:5.9-13.20130511.el7 will be installed ---> Package qt3-devel.x86_64 0:3.3.8b-51.el7 will be installed --> Processing Dependency: qt3 = 3.3.8b-51.el7 for package: qt3-devel-3.3.8b-51.el7.x86_64 --> Processing Dependency: mesa-libGLU-devel for package: qt3-devel-3.3.8b-51.el7.x86_64 --> Processing Dependency: mesa-libGL-devel for package: qt3-devel-3.3.8b-51.el7.x86_64 --> Processing Dependency: libpng-devel for package: qt3-devel-3.3.8b-51.el7.x86_64 --> Processing Dependency: libmng-devel for package: qt3-devel-3.3.8b-51.el7.x86_64 --> Processing Dependency: libjpeg-devel for package: qt3-devel-3.3.8b-51.el7.x86_64 --> Processing Dependency: libXt-devel for package: qt3-devel-3.3.8b-51.el7.x86_64 --> Processing Dependency: libXrender-devel for package: qt3-devel-3.3.8b-51.el7.x86_64 --> Processing Dependency: libXrandr-devel for package: qt3-devel-3.3.8b-51.el7.x86_64 --> Processing Dependency: libXinerama-devel for package: qt3-devel-3.3.8b-51.el7.x86_64 --> Processing Dependency: libXft-devel for package: qt3-devel-3.3.8b-51.el7.x86_64 --> Processing Dependency: libXcursor-devel for package: qt3-devel-3.3.8b-51.el7.x86_64 --> Processing Dependency: libSM-devel for package: qt3-devel-3.3.8b-51.el7.x86_64 --> Processing Dependency: libICE-devel for package: qt3-devel-3.3.8b-51.el7.x86_64 --> Processing Dependency: freetype-devel for package: qt3-devel-3.3.8b-51.el7.x86_64 --> Processing Dependency: fontconfig-devel for package: qt3-devel-3.3.8b-51.el7.x86_64 --> Processing Dependency: libqui.so.1()(64bit) for package: qt3-devel-3.3.8b-51.el7.x86_64 --> Processing Dependency: libqt-mt.so.3()(64bit) for package: qt3-devel-3.3.8b-51.el7.x86_64 --> Processing Dependency: libmng.so.1()(64bit) for package: qt3-devel-3.3.8b-51.el7.x86_64 ---> Package rpmdevtools.noarch 0:8.3-5.el7 will be installed --> Processing Dependency: rpm-build >= 4.4.2.3 for package: rpmdevtools-8.3-5.el7.noarch --> Running transaction check ---> Package fontconfig-devel.x86_64 0:2.10.95-7.el7 will be installed --> Processing Dependency: pkgconfig(expat) for package: fontconfig-devel-2.10.95-7.el7.x86_64 ---> Package freetype-devel.x86_64 0:2.4.11-11.el7 will be installed --> Processing Dependency: zlib-devel for package: freetype-devel-2.4.11-11.el7.x86_64 ---> Package libICE-devel.x86_64 0:1.0.9-2.el7 will be installed ---> Package libSM-devel.x86_64 0:1.2.2-2.el7 will be installed ---> Package libX11-devel.x86_64 0:1.6.3-2.el7 will be installed --> Processing Dependency: pkgconfig(xcb) >= 1.1.92 for package: libX11-devel-1.6.3-2.el7.x86_64 --> Processing Dependency: pkgconfig(xcb) for package: libX11-devel-1.6.3-2.el7.x86_64 ---> Package libXcursor-devel.x86_64 0:1.1.14-2.1.el7 will be installed ---> Package libXext-devel.x86_64 0:1.3.3-3.el7 will be installed ---> Package libXfixes-devel.x86_64 0:5.0.1-2.1.el7 will be installed ---> Package libXft-devel.x86_64 0:2.3.2-2.el7 will be installed ---> Package libXinerama-devel.x86_64 0:1.1.3-2.1.el7 will be installed ---> Package libXrandr-devel.x86_64 0:1.4.2-2.el7 will be installed ---> Package libXrender-devel.x86_64 0:0.9.8-2.1.el7 will be installed ---> Package libXt-devel.x86_64 0:1.1.4-6.1.el7 will be installed ---> Package libjpeg-turbo-devel.x86_64 0:1.2.90-5.el7 will be installed ---> Package libmng.x86_64 0:1.0.10-14.el7 will be installed ---> Package libmng-devel.x86_64 0:1.0.10-14.el7 will be installed ---> Package libpng-devel.x86_64 2:1.5.13-7.el7_2 will be installed ---> Package libstdc++-devel.x86_64 0:4.8.5-4.el7 will be installed ---> Package mesa-libGL-devel.x86_64 0:10.6.5-3.20150824.el7 will be installed --> Processing Dependency: pkgconfig(xshmfence) >= 1.1 for package: mesa-libGL-devel-10.6.5-3.20150824.el7.x86_64 --> Processing Dependency: pkgconfig(libdrm) >= 2.4.38 for package: mesa-libGL-devel-10.6.5-3.20150824.el7.x86_64 --> Processing Dependency: pkgconfig(xxf86vm) for package: mesa-libGL-devel-10.6.5-3.20150824.el7.x86_64 --> Processing Dependency: pkgconfig(xdamage) for package: mesa-libGL-devel-10.6.5-3.20150824.el7.x86_64 --> Processing Dependency: gl-manpages for package: mesa-libGL-devel-10.6.5-3.20150824.el7.x86_64 ---> Package mesa-libGLU-devel.x86_64 0:9.0.0-4.el7 will be installed ---> Package qt3.x86_64 0:3.3.8b-51.el7 will be installed ---> Package rpm-build.x86_64 0:4.11.3-17.el7 will be installed --> Processing Dependency: system-rpm-config for package: rpm-build-4.11.3-17.el7.x86_64 --> Processing Dependency: perl(Thread::Queue) for package: rpm-build-4.11.3-17.el7.x86_64 ---> Package xorg-x11-proto-devel.noarch 0:7.7-12.el7 will be installed --> Running transaction check ---> Package expat-devel.x86_64 0:2.1.0-8.el7 will be installed ---> Package gl-manpages.noarch 0:1.1-7.20130122.el7 will be installed ---> Package libXdamage-devel.x86_64 0:1.1.4-4.1.el7 will be installed ---> Package libXxf86vm-devel.x86_64 0:1.1.3-2.1.el7 will be installed ---> Package libdrm-devel.x86_64 0:2.4.60-3.el7 will be installed ---> Package libxcb-devel.x86_64 0:1.11-4.el7 will be installed --> Processing Dependency: pkgconfig(xau) >= 0.99.2 for package: libxcb-devel-1.11-4.el7.x86_64 ---> Package libxshmfence-devel.x86_64 0:1.2-1.el7 will be installed ---> Package perl-Thread-Queue.noarch 0:3.02-2.el7 will be installed ---> Package redhat-rpm-config.noarch 0:9.1.0-68.el7.centos will be installed --> Processing Dependency: dwz >= 0.4 for package: redhat-rpm-config-9.1.0-68.el7.centos.noarch --> Processing Dependency: perl-srpm-macros for package: redhat-rpm-config-9.1.0-68.el7.centos.noarch ---> Package zlib-devel.x86_64 0:1.2.7-15.el7 will be installed --> Running transaction check ---> Package dwz.x86_64 0:0.11-3.el7 will be installed ---> Package libXau-devel.x86_64 0:1.0.8-2.1.el7 will be installed ---> Package perl-srpm-macros.noarch 0:1-8.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================================== Package Arch Version Repository Size ======================================================================================================================================================================== Installing: gcc-c++ x86_64 4.8.5-4.el7 base 7.2 M libXi-devel x86_64 1.7.4-2.el7 base 105 k ncurses-devel x86_64 5.9-13.20130511.el7 base 713 k qt3-devel x86_64 3.3.8b-51.el7 base 8.8 M rpmdevtools noarch 8.3-5.el7 base 97 k Installing for dependencies: dwz x86_64 0.11-3.el7 base 99 k expat-devel x86_64 2.1.0-8.el7 base 56 k fontconfig-devel x86_64 2.10.95-7.el7 base 128 k freetype-devel x86_64 2.4.11-11.el7 base 356 k gl-manpages noarch 1.1-7.20130122.el7 base 994 k libICE-devel x86_64 1.0.9-2.el7 base 49 k libSM-devel x86_64 1.2.2-2.el7 base 13 k libX11-devel x86_64 1.6.3-2.el7 base 980 k libXau-devel x86_64 1.0.8-2.1.el7 base 14 k libXcursor-devel x86_64 1.1.14-2.1.el7 base 23 k libXdamage-devel x86_64 1.1.4-4.1.el7 base 9.7 k libXext-devel x86_64 1.3.3-3.el7 base 75 k libXfixes-devel x86_64 5.0.1-2.1.el7 base 13 k libXft-devel x86_64 2.3.2-2.el7 base 19 k libXinerama-devel x86_64 1.1.3-2.1.el7 base 13 k libXrandr-devel x86_64 1.4.2-2.el7 base 21 k libXrender-devel x86_64 0.9.8-2.1.el7 base 16 k libXt-devel x86_64 1.1.4-6.1.el7 base 445 k libXxf86vm-devel x86_64 1.1.3-2.1.el7 base 18 k libdrm-devel x86_64 2.4.60-3.el7 base 92 k libjpeg-turbo-devel x86_64 1.2.90-5.el7 base 98 k libmng x86_64 1.0.10-14.el7 base 171 k libmng-devel x86_64 1.0.10-14.el7 base 85 k libpng-devel x86_64 2:1.5.13-7.el7_2 updates 122 k libstdc++-devel x86_64 4.8.5-4.el7 base 1.5 M libxcb-devel x86_64 1.11-4.el7 base 1.1 M libxshmfence-devel x86_64 1.2-1.el7 base 5.4 k mesa-libGL-devel x86_64 10.6.5-3.20150824.el7 base 147 k mesa-libGLU-devel x86_64 9.0.0-4.el7 base 9.0 k perl-Thread-Queue noarch 3.02-2.el7 base 17 k perl-srpm-macros noarch 1-8.el7 base 4.6 k qt3 x86_64 3.3.8b-51.el7 base 3.5 M redhat-rpm-config noarch 9.1.0-68.el7.centos base 77 k rpm-build x86_64 4.11.3-17.el7 base 143 k xorg-x11-proto-devel noarch 7.7-12.el7 base 281 k zlib-devel x86_64 1.2.7-15.el7 base 50 k Transaction Summary ======================================================================================================================================================================== Install 5 Packages (+36 Dependent packages) Total download size: 27 M Installed size: 90 M Is this ok [y/d/N]: y
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 plusieurs Go d'espace libre.
Arrêtez votre machine virtuelle. Ajoutez un deuxième disque de 20 Go au contrôleur SATA en utilisant la section Stockage des paramètres de la machine virtuelle. Le format du disque doit être vmdk. Nommez ce disque RedHatHome et re-démarrez la machine virtuelle en vous connectant directement en tant que root.
Créez une seule partition sur /dev/sdb :
[root@centos7 ~]# fdisk /dev/sdb Welcome to fdisk (util-linux 2.23.2). 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 Building a new DOS disklabel with disk identifier 0x88708329. Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): First sector (2048-41943039, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): Using default value 41943039 Partition 1 of type Linux and of size 20 GiB is set 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 /dev/sdb1 :
[root@centos7 ~]# mkfs.ext4 /dev/sdb1 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 1310720 inodes, 5242624 blocks 262131 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2153775104 160 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
Montez /dev/sdb1 sur /mnt :
[root@centos7 ~]# mount /dev/sdb1 /mnt
Copiez le contenu de /home vers /mnt :
[root@centos7 ~]# cp -a /home/* /mnt
Démontez /dev/sdb1 et déplacez /home vers /root :
[root@centos7 ~]# umount /mnt [root@centos7 ~]# mv /home /root
Identifiez l'UUID de /dev/sdb1 :
[root@centos7 ~]# ls -l /dev/disk/by-uuid/ | grep sdb1 lrwxrwxrwx. 1 root root 10 9 août 06:47 a5e2457f-7337-41f4-b958-e403eb419f94 -> ../../sdb1
Editez le fichier /etc/fstab :
# # /etc/fstab # Created by anaconda on Sat Apr 30 11:27:02 2016 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=e65fe7da-cda8-4f5a-a827-1b5cabe94bed / xfs defaults 0 0 UUID=2d947276-66e8-41f4-8475-b64b67d7a249 /boot xfs defaults 0 0 UUID=3181601a-7295-4ef0-a92c-f21f76b18e64 swap swap defaults 0 0 UUID=a5e2457f-7337-41f4-b958-e403eb419f94 /home ext4 defaults 1 2
Créez le point de montage /home :
[root@centos7 ~]# mkdir /home
Montez /dev/sdb1 :
[root@centos7 ~]# mount -a [root@centos7 ~]# mount sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel) proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=236036k,nr_inodes=59009,mode=755) securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime) tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel) devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000) tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755) tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,seclabel,mode=755) cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd) pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime) cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu) cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb) cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls) cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset) cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer) cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory) cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio) cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices) cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event) configfs on /sys/kernel/config type configfs (rw,relatime) /dev/sda2 on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota) selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime) systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=30,pgrp=1,timeout=300,minproto=5,maxproto=5,direct) debugfs on /sys/kernel/debug type debugfs (rw,relatime) hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel) mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel) tmpfs on /tmp type tmpfs (rw,seclabel) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime) nfsd on /proc/fs/nfsd type nfsd (rw,relatime) /dev/sda1 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,noquota) /dev/sdb1 on /home type ext4 (rw,relatime,seclabel,data=ordered) tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=50080k,mode=700,uid=1000,gid=1000)
Notez la taille de /home :
[trainee@centos7 ~]$ df -h Sys. de fichiers Taille Utilisé Dispo Uti% Monté sur /dev/sda2 9,8G 4,4G 5,5G 45% / devtmpfs 231M 0 231M 0% /dev tmpfs 245M 0 245M 0% /dev/shm tmpfs 245M 4,7M 240M 2% /run tmpfs 245M 0 245M 0% /sys/fs/cgroup tmpfs 245M 72K 245M 1% /tmp /dev/sda1 197M 197M 20K 100% /boot /dev/sdb1 20G 65M 19G 1% /home tmpfs 49M 0 49M 0% /run/user/1000
Fermez la session de root et connectez-vous en tant que trainee.
Pour créer l'arborescence de l'environnement de création de paquets dans /home/trainee, utilisez la commande rpmdev-setuptree :
[trainee@centos7 ~]$ rpmdev-setuptree [trainee@centos7 ~]$ ls -laR rpmbuild/ rpmbuild/: total 28 drwxrwxr-x. 7 trainee trainee 4096 9 août 06:56 . drwx------. 15 trainee trainee 4096 9 août 06:56 .. drwxrwxr-x. 2 trainee trainee 4096 9 août 06:56 BUILD drwxrwxr-x. 2 trainee trainee 4096 9 août 06:56 RPMS drwxrwxr-x. 2 trainee trainee 4096 9 août 06:56 SOURCES drwxrwxr-x. 2 trainee trainee 4096 9 août 06:56 SPECS drwxrwxr-x. 2 trainee trainee 4096 9 août 06:56 SRPMS rpmbuild/BUILD: total 8 drwxrwxr-x. 2 trainee trainee 4096 9 août 06:56 . drwxrwxr-x. 7 trainee trainee 4096 9 août 06:56 .. rpmbuild/RPMS: total 8 drwxrwxr-x. 2 trainee trainee 4096 9 août 06:56 . drwxrwxr-x. 7 trainee trainee 4096 9 août 06:56 .. rpmbuild/SOURCES: total 8 drwxrwxr-x. 2 trainee trainee 4096 9 août 06:56 . drwxrwxr-x. 7 trainee trainee 4096 9 août 06:56 .. rpmbuild/SPECS: total 8 drwxrwxr-x. 2 trainee trainee 4096 9 août 06:56 . drwxrwxr-x. 7 trainee trainee 4096 9 août 06:56 .. rpmbuild/SRPMS: total 8 drwxrwxr-x. 2 trainee trainee 4096 9 août 06:56 . drwxrwxr-x. 7 trainee trainee 4096 9 août 06:56 ..
Téléchargez le rpm source du noyau :
[trainee@centos7 ~]$ uname -a Linux centos7.fenestros.loc 3.10.0-327.13.1.el7.x86_64 #1 SMP Thu Mar 31 16:04:38 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux [trainee@centos7 ~]$ wget http://vault.centos.org/7.2.1511/updates/Source/SPackages/kernel-3.10.0-327.13.1.el7.src.rpm --2016-08-09 06:57:08-- http://vault.centos.org/7.2.1511/updates/Source/SPackages/kernel-3.10.0-327.13.1.el7.src.rpm Résolution de vault.centos.org (vault.centos.org)... 88.208.217.170, 2a00:f10:10b:13::10 Connexion vers vault.centos.org (vault.centos.org)|88.208.217.170|:80...connecté. requête HTTP transmise, en attente de la réponse...200 OK Longueur: 83047820 (79M) [application/x-rpm] Sauvegarde en : «kernel-3.10.0-327.13.1.el7.src.rpm» 100%[==============================================================================================================================>] 83 047 820 496KB/s ds 2m 52s 2016-08-09 07:00:00 (471 KB/s) - «kernel-3.10.0-327.13.1.el7.src.rpm» sauvegardé [83047820/83047820]
Installez maintenant les dépendances pour le rpm source en tant que root :
[trainee@centos7 ~]$ su - Mot de passe : fenestros [root@centos7 ~]# yum-builddep /home/trainee/kernel-3.10.0-327.13.1.el7.src.rpm Loaded plugins: fastestmirror, langpacks Enabling base-source repository Enabling extras-source repository Enabling updates-source repository base-source | 2.9 kB 00:00:00 extras-source | 2.9 kB 00:00:00 updates-source | 2.9 kB 00:00:00 (1/3): extras-source/7/primary_db | 43 kB 00:00:00 (2/3): base-source/7/primary_db | 949 kB 00:00:00 (3/3): updates-source/7/primary_db | 140 kB 00:00:00 Loading mirror speeds from cached hostfile * base: centos.mirrors.ovh.net * extras: centos.mirror.fr.planethoster.net * updates: mirror1.evolution-host.com Checking for new repos for mirrors Getting requirements for kernel-3.10.0-327.13.1.el7.src --> Already installed : kmod-20-5.el7.x86_64 --> Already installed : patch-2.7.1-8.el7.x86_64 --> Already installed : bash-4.2.46-19.el7.x86_64 --> Already installed : coreutils-8.22-15.el7_2.1.x86_64 --> Already installed : 2:tar-1.26-29.el7.x86_64 --> Already installed : xz-5.1.2-12alpha.el7.x86_64 --> Already installed : 1:findutils-4.5.11-5.el7.x86_64 --> Already installed : gzip-1.5-8.el7.x86_64 --> m4-1.4.16-10.el7.x86_64 --> Already installed : 4:perl-5.16.3-286.el7.x86_64 --> Already installed : 1:make-3.82-21.el7.x86_64 --> Already installed : diffutils-3.3-4.el7.x86_64 --> Already installed : gawk-4.0.2-4.el7.x86_64 --> Already installed : gcc-4.8.5-4.el7.x86_64 --> Already installed : binutils-2.23.52.0.1-55.el7.x86_64 --> Already installed : redhat-rpm-config-9.1.0-68.el7.centos.noarch --> Already installed : hostname-3.13-3.el7.x86_64 --> Already installed : net-tools-2.0-0.17.20131004git.el7.x86_64 --> Already installed : bc-1.06.95-13.el7.x86_64 --> xmlto-0.0.25-7.el7.x86_64 --> asciidoc-8.6.8-5.el7.noarch --> Already installed : 1:openssl-1.0.1e-51.el7_2.4.x86_64 --> hmaccalc-0.9.13-4.el7.x86_64 --> python-devel-2.7.5-34.el7.x86_64 --> newt-devel-0.52.15-4.el7.x86_64 --> perl-ExtUtils-Embed-1.30-286.el7.noarch --> Already installed : rpm-build-4.11.3-17.el7.x86_64 --> Already installed : elfutils-0.163-3.el7.x86_64 --> Running transaction check ---> Package asciidoc.noarch 0:8.6.8-5.el7 will be installed --> Processing Dependency: source-highlight for package: asciidoc-8.6.8-5.el7.noarch --> Processing Dependency: graphviz for package: asciidoc-8.6.8-5.el7.noarch --> Processing Dependency: docbook-style-xsl for package: asciidoc-8.6.8-5.el7.noarch ---> Package hmaccalc.x86_64 0:0.9.13-4.el7 will be installed ---> Package m4.x86_64 0:1.4.16-10.el7 will be installed ---> Package newt-devel.x86_64 0:0.52.15-4.el7 will be installed --> Processing Dependency: slang-devel for package: newt-devel-0.52.15-4.el7.x86_64 ---> Package perl-ExtUtils-Embed.noarch 0:1.30-286.el7 will be installed --> Processing Dependency: perl-devel for package: perl-ExtUtils-Embed-1.30-286.el7.noarch ---> Package python-devel.x86_64 0:2.7.5-34.el7 will be installed ---> Package xmlto.x86_64 0:0.0.25-7.el7 will be installed --> Processing Dependency: text-www-browser for package: xmlto-0.0.25-7.el7.x86_64 --> Processing Dependency: flex for package: xmlto-0.0.25-7.el7.x86_64 --> Processing Dependency: docbook-dtds for package: xmlto-0.0.25-7.el7.x86_64 --> Running transaction check ---> Package docbook-dtds.noarch 0:1.0-60.el7 will be installed --> Processing Dependency: sgml-common for package: docbook-dtds-1.0-60.el7.noarch ---> Package docbook-style-xsl.noarch 0:1.78.1-3.el7 will be installed ---> Package flex.x86_64 0:2.5.37-3.el7 will be installed ---> Package graphviz.x86_64 0:2.30.1-19.el7 will be installed --> Processing Dependency: libXaw.so.7()(64bit) for package: graphviz-2.30.1-19.el7.x86_64 ---> Package lynx.x86_64 0:2.8.8-0.3.dev15.el7 will be installed ---> Package perl-devel.x86_64 4:5.16.3-286.el7 will be installed --> Processing Dependency: systemtap-sdt-devel for package: 4:perl-devel-5.16.3-286.el7.x86_64 --> Processing Dependency: perl(ExtUtils::ParseXS) for package: 4:perl-devel-5.16.3-286.el7.x86_64 --> Processing Dependency: perl(ExtUtils::MakeMaker) for package: 4:perl-devel-5.16.3-286.el7.x86_64 --> Processing Dependency: perl(ExtUtils::Installed) for package: 4:perl-devel-5.16.3-286.el7.x86_64 --> Processing Dependency: libdb-devel for package: 4:perl-devel-5.16.3-286.el7.x86_64 --> Processing Dependency: gdbm-devel for package: 4:perl-devel-5.16.3-286.el7.x86_64 ---> Package slang-devel.x86_64 0:2.2.4-11.el7 will be installed ---> Package source-highlight.x86_64 0:3.1.6-6.el7 will be installed --> Processing Dependency: ctags for package: source-highlight-3.1.6-6.el7.x86_64 --> Processing Dependency: libboost_regex.so.1.53.0()(64bit) for package: source-highlight-3.1.6-6.el7.x86_64 --> Running transaction check ---> Package boost-regex.x86_64 0:1.53.0-25.el7 will be installed ---> Package ctags.x86_64 0:5.8-13.el7 will be installed ---> Package gdbm-devel.x86_64 0:1.10-8.el7 will be installed ---> Package libXaw.x86_64 0:1.0.12-5.el7 will be installed ---> Package libdb-devel.x86_64 0:5.3.21-19.el7 will be installed ---> Package perl-ExtUtils-Install.noarch 0:1.58-286.el7 will be installed ---> Package perl-ExtUtils-MakeMaker.noarch 0:6.68-3.el7 will be installed --> Processing Dependency: perl(Test::Harness) for package: perl-ExtUtils-MakeMaker-6.68-3.el7.noarch --> Processing Dependency: perl(ExtUtils::Manifest) for package: perl-ExtUtils-MakeMaker-6.68-3.el7.noarch ---> Package perl-ExtUtils-ParseXS.noarch 1:3.18-2.el7 will be installed ---> Package sgml-common.noarch 0:0.6.3-39.el7 will be installed ---> Package systemtap-sdt-devel.x86_64 0:2.8-10.el7 will be installed --> Running transaction check ---> Package perl-ExtUtils-Manifest.noarch 0:1.61-244.el7 will be installed ---> Package perl-Test-Harness.noarch 0:3.28-3.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================================== Package Arch Version Repository Size ======================================================================================================================================================================== Installing: asciidoc noarch 8.6.8-5.el7 base 251 k hmaccalc x86_64 0.9.13-4.el7 base 26 k m4 x86_64 1.4.16-10.el7 base 256 k newt-devel x86_64 0.52.15-4.el7 base 51 k perl-ExtUtils-Embed noarch 1.30-286.el7 base 49 k python-devel x86_64 2.7.5-34.el7 base 391 k xmlto x86_64 0.0.25-7.el7 base 50 k Installing for dependencies: boost-regex x86_64 1.53.0-25.el7 base 294 k ctags x86_64 5.8-13.el7 base 155 k docbook-dtds noarch 1.0-60.el7 base 226 k docbook-style-xsl noarch 1.78.1-3.el7 base 2.0 M flex x86_64 2.5.37-3.el7 base 292 k gdbm-devel x86_64 1.10-8.el7 base 47 k graphviz x86_64 2.30.1-19.el7 base 1.3 M libXaw x86_64 1.0.12-5.el7 base 190 k libdb-devel x86_64 5.3.21-19.el7 base 38 k lynx x86_64 2.8.8-0.3.dev15.el7 base 1.4 M perl-ExtUtils-Install noarch 1.58-286.el7 base 73 k perl-ExtUtils-MakeMaker noarch 6.68-3.el7 base 275 k perl-ExtUtils-Manifest noarch 1.61-244.el7 base 31 k perl-ExtUtils-ParseXS noarch 1:3.18-2.el7 base 77 k perl-Test-Harness noarch 3.28-3.el7 base 302 k perl-devel x86_64 4:5.16.3-286.el7 base 452 k sgml-common noarch 0.6.3-39.el7 base 55 k slang-devel x86_64 2.2.4-11.el7 base 91 k source-highlight x86_64 3.1.6-6.el7 base 611 k systemtap-sdt-devel x86_64 2.8-10.el7 base 65 k Transaction Summary ======================================================================================================================================================================== Install 7 Packages (+20 Dependent packages) Total download size: 9.0 M Installed size: 43 M Is this ok [y/d/N]: y
Installez maintenant le paquet kernel-3.10.0-327.13.1.el7.src.rpm :
[root@centos7 ~]# exit logout [trainee@centos7 ~]$ rpm -Uvh kernel-3.10.0-327.13.1.el7.src.rpm Mise à jour / installation... 1:kernel-3.10.0-327.13.1.el7 ################################# [100%] attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root attention : utilisateur builder inexistant - utilisation de root attention : groupe builder inexistant - utilisation de root
Les erreurs sont sans importance.
Naviguez vers le repertoire ~/rpmbuild/SPECS et utilisez la commande rpmbuild pour préparer l'arborescence source du noyau :
[trainee@centos7 ~]$ cd ~/rpmbuild/SPECS [trainee@centos7 SPECS]$ rpmbuild -bp --target=$(uname -m) kernel.spec Construction pour plate-formes cibles: x86_64 Construction pour cible x86_64 erreur : Dépendances de construction manquantes: pesign >= 0.109-4 est nécessaire pour kernel-3.10.0-327.13.1.el7.x86_64 elfutils-devel est nécessaire pour kernel-3.10.0-327.13.1.el7.x86_64 binutils-devel est nécessaire pour kernel-3.10.0-327.13.1.el7.x86_64 bison est nécessaire pour kernel-3.10.0-327.13.1.el7.x86_64 audit-libs-devel est nécessaire pour kernel-3.10.0-327.13.1.el7.x86_64 numactl-devel est nécessaire pour kernel-3.10.0-327.13.1.el7.x86_64 pciutils-devel est nécessaire pour kernel-3.10.0-327.13.1.el7.x86_64
Notez qu'il existe toujours des dépendances manquantes !
Redevenez root et installez les dépendances :
[trainee@centos7 SPECS]$ cd - /home/trainee [trainee@centos7 ~]$ su - Mot de passe : Dernière connexion : lundi 8 août 2016 à 16:39:54 CEST sur pts/0 [root@centos7 ~]# yum install elfutils-devel binutils-devel bison audit-libs-devel numactl-devel pciutils-devel pesign ...
Vous pouvez maintenant utilisez la commande rpmbuild pour préparer l'arborescence source du noyau :
[root@centos7 ~]# exit logout [trainee@centos7 ~]$ cd ~/rpmbuild/SPECS [trainee@centos7 SPECS]$ rpmbuild -bp --target=$(uname -m) kernel.spec Construction pour plate-formes cibles: x86_64 Construction pour cible x86_64 Exécution_de(%prep) : /bin/sh -e /var/tmp/rpm-tmp.xP6OkC + umask 022 + cd /home/trainee/rpmbuild/BUILD + patch_command='patch -p1 -F1 -s' + cd /home/trainee/rpmbuild/BUILD + rm -rf kernel-3.10.0-327.13.1.el7 + /usr/bin/mkdir -p kernel-3.10.0-327.13.1.el7 + cd kernel-3.10.0-327.13.1.el7 + /usr/bin/xz -dc /home/trainee/rpmbuild/SOURCES/linux-3.10.0-327.13.1.el7.tar.xz + /usr/bin/tar -xf - ...
A l'issu du processus, examinez l'arborescence :
[trainee@centos7 SPECS]$ ls -la ~/rpmbuild/BUILD/kernel-3.10.0-327.13.1.el7/linux-3.10.0-327.13.1.el7.x86_64/ total 824 drwxr-xr-x. 24 trainee trainee 4096 8 août 16:52 . drwxr-xr-x. 3 trainee trainee 4096 8 août 16:52 .. drwxr-xr-x. 32 trainee trainee 4096 8 août 16:52 arch drwxr-xr-x. 3 trainee trainee 4096 29 févr. 18:35 block -rw-r--r--. 1 trainee trainee 126411 8 août 16:52 .config -rw-r--r--. 1 trainee trainee 126420 8 août 16:52 .config.old drwxr-xr-x. 2 trainee trainee 4096 8 août 16:52 configs -rw-r--r--. 1 trainee trainee 18693 29 févr. 18:35 COPYING -rw-r--r--. 1 trainee trainee 95317 29 févr. 18:35 CREDITS drwxr-xr-x. 4 trainee trainee 4096 29 févr. 18:35 crypto drwxr-xr-x. 101 trainee trainee 12288 8 août 16:52 Documentation drwxr-xr-x. 114 trainee trainee 4096 29 févr. 18:35 drivers drwxr-xr-x. 36 trainee trainee 4096 8 août 16:52 firmware drwxr-xr-x. 74 trainee trainee 4096 29 févr. 18:35 fs -rw-r--r--. 1 trainee trainee 46 29 févr. 18:35 .gitattributes drwxr-xr-x. 27 trainee trainee 4096 8 août 16:52 include drwxr-xr-x. 2 trainee trainee 4096 29 févr. 18:35 init drwxr-xr-x. 2 trainee trainee 4096 29 févr. 18:35 ipc -rw-r--r--. 1 trainee trainee 2536 29 févr. 18:35 Kbuild -rw-r--r--. 1 trainee trainee 505 29 févr. 18:35 Kconfig drwxr-xr-x. 11 trainee trainee 4096 8 août 16:52 kernel drwxr-xr-x. 10 trainee trainee 4096 8 août 16:52 lib -rw-r--r--. 1 trainee trainee 4465 29 févr. 18:35 .mailmap -rw-r--r--. 1 trainee trainee 260223 29 févr. 18:35 MAINTAINERS -rw-r--r--. 1 trainee trainee 49887 29 févr. 18:35 Makefile drwxr-xr-x. 2 trainee trainee 4096 29 févr. 18:35 mm drwxr-xr-x. 56 trainee trainee 4096 29 févr. 18:35 net -rw-r--r--. 1 trainee trainee 18736 29 févr. 18:35 README -rw-r--r--. 1 trainee trainee 7485 29 févr. 18:35 REPORTING-BUGS drwxr-xr-x. 12 trainee trainee 4096 29 févr. 18:35 samples -rw-r--r--. 1 trainee trainee 0 8 août 16:52 .scmversion drwxr-xr-x. 13 trainee trainee 4096 8 août 16:52 scripts drwxr-xr-x. 9 trainee trainee 4096 29 févr. 18:35 security drwxr-xr-x. 23 trainee trainee 4096 29 févr. 18:35 sound drwxr-xr-x. 19 trainee trainee 4096 29 févr. 18:35 tools drwxr-xr-x. 2 trainee trainee 4096 8 août 16:52 usr drwxr-xr-x. 3 trainee trainee 4096 29 févr. 18:35 virt
A l'intérieur de ce répertoire se trouve le fichier .config utilisé pour compiler le noyau :
[trainee@centos7 SPECS]$ more ~/rpmbuild/BUILD/kernel-3.10.0-327.13.1.el7/linux-3.10.0-327.13.1.el7.x86_64/.config # # Automatically generated file; DO NOT EDIT. # Linux/x86_64 3.10.0 Kernel Configuration # CONFIG_64BIT=y CONFIG_X86_64=y CONFIG_X86=y CONFIG_INSTRUCTION_DECODER=y CONFIG_OUTPUT_FORMAT="elf64-x86-64" CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig" CONFIG_LOCKDEP_SUPPORT=y CONFIG_STACKTRACE_SUPPORT=y CONFIG_HAVE_LATENCYTOP_SUPPORT=y CONFIG_MMU=y CONFIG_NEED_DMA_MAP_STATE=y CONFIG_NEED_SG_DMA_LENGTH=y 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_RWSEM_XCHGADD_ALGORITHM=y CONFIG_GENERIC_CALIBRATE_DELAY=y CONFIG_ARCH_HAS_CPU_RELAX=y CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y CONFIG_ARCH_HAS_CPU_AUTOPROBE=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_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 CONFIG_X86_HT=y CONFIG_ARCH_HWEIGHT_CFLAGS="-fcall-saved-rdi -fcall-saved-rsi -fcall-saved-rdx -fcall-saved-rcx -fcall-saved-r8 -fcall-saved-r9 -fcall-saved-r10 -fcall-saved-r11" CONFIG_ARCH_SUPPORTS_UPROBES=y CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" CONFIG_IRQ_WORK=y CONFIG_BUILDTIME_EXTABLE_SORT=y # --Plus--(1%)
Ce fichier est généré par une des trois commandes suivantes et ne doit pas être édité manuellement :
Dans ce fichier, vous pouvez constater la présence de lignes correspondantes à des fonctionalités suivies par une lettre ou une valeur. Dans le cas d'une lettre, la signification est la suivante :
Le fichier Makefile contient le nom du noyau et spécifie les informations suivantes :
Les trois premières informations sont gérées par kernel.org et Linus Torvalds en personne tandis que l'EXTRAVERSION est gérée par Red Hat :
[trainee@centos7 SPECS]$ more ~/rpmbuild/BUILD/kernel-3.10.0-327.13.1.el7/linux-3.10.0-327.13.1.el7.x86_64/Makefile VERSION = 3 PATCHLEVEL = 10 SUBLEVEL = 0 EXTRAVERSION = NAME = Unicycling Gorilla RHEL_MAJOR = 7 RHEL_MINOR = 2 RHEL_RELEASE = 327.13.1 RHEL_DRM_VERSION = 4 RHEL_DRM_PATCHLEVEL = 1 RHEL_DRM_SUBLEVEL = 0 # *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. # Do not: # o use make's built-in rules and variables # (this increases performance and avoids hard-to-debug behaviour); # o print "Entering directory ..."; MAKEFLAGS += -rR --no-print-directory # Avoid funny character set dependencies unexport LC_ALL LC_COLLATE=C LC_NUMERIC=C export LC_COLLATE LC_NUMERIC # We are using a recursive build, so we need to do a little thinking # to get the ordering right. # # Most importantly: sub-Makefiles should only ever modify files in # their own directory. If in some directory we have a dependency on # a file in another dir (which doesn't happen often, but it's often # unavoidable when linking the built-in.o targets which finally # turn into vmlinux), we will call a sub make in that other dir, and # after that we are sure that everything which is in that other dir # is now up to date. # # The only cases where we need to modify files which have global # effects are thus separated out and done before the recursive # descending is started. They are now explicitly listed as the # prepare rule. --Plus--(2%)
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'EXTRAVERSION. Le passage à la version 3.0 fut décidé par Linus Torvalds à l'occasion des 20 ans du noyau Linux.
Utilisez maintenant la commande make oldconfig :
[trainee@centos7 SPECS]$ cd ~/rpmbuild/BUILD/kernel-3.10.0-327.13.1.el7/linux-3.10.0-327.13.1.el7.x86_64 [trainee@centos7 linux-3.10.0-327.13.1.el7.x86_64]$ make oldconfig scripts/kconfig/conf --oldconfig Kconfig # # configuration written to .config #
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.
Après avoir modifié la configuration du noyau selon vos besoins en utilisant soit la commande menuconfig soit la commande xconfig (pas necéssaire pour cet exemple), insérez la sortie de la commande uname -i sur la première ligne du fichier .config :
[trainee@centos7 linux-3.10.0-327.13.1.el7.x86_64]$ uname -i x86_64 [trainee@centos7 linux-3.10.0-327.13.1.el7.x86_64]$ vi .config [trainee@centos7 linux-3.10.0-327.13.1.el7.x86_64]$ head .config # x86_64 # # Automatically generated file; DO NOT EDIT. # Linux/x86 3.10.0 Kernel Configuration # CONFIG_64BIT=y CONFIG_X86_64=y CONFIG_X86=y CONFIG_INSTRUCTION_DECODER=y CONFIG_OUTPUT_FORMAT="elf64-x86-64"
Renommez le fichier .config en le plaçant dans le répertoire ~/rpmbuild/SOURCES/ :
[trainee@centos7 linux-3.10.0-327.13.1.el7.x86_64]$ cp .config ~/rpmbuild/SOURCES/config-`uname -m`-generic [trainee@centos7 linux-3.10.0-327.13.1.el7.x86_64]$ ls ~/rpmbuild/SOURCES centos.cer cpupower.service kernel-3.10.0-ppc64-debug.config kernel-3.10.0-x86_64.config Module.kabi_ppc64 x509.genkey centos-kpatch.x509 debrand-rh-i686-cpu.patch kernel-3.10.0-ppc64le.config kernel-3.10.0-x86_64-debug.config Module.kabi_ppc64le centos-ldup.x509 debrand-rh_taint.patch kernel-3.10.0-ppc64le-debug.config kernel-abi-whitelists-327.tar.bz2 Module.kabi_s390x check-kabi debrand-single-cpu.patch kernel-3.10.0-s390x.config linux-3.10.0-327.13.1.el7.tar.xz Module.kabi_x86_64 config-x86_64-generic extra_certificates kernel-3.10.0-s390x-debug.config linux-kernel-test.patch secureboot.cer cpupower.config kernel-3.10.0-ppc64.config kernel-3.10.0-s390x-kdump.config Makefile.common sign-modules
Pour un noyau 32 bits, remplacez x86_64 par i386 et config-`uname -m`-generic par config-x86-32-generic.
Editez la directive buildid dans le fichier ~/rpmbuild/SPECS/kernel.spec :
[trainee@centos7 linux-3.10.0-327.13.1.el7.x86_64]$ cd ~/rpmbuild/SPECS [trainee@centos7 SPECS]$ vi kernel.spec [trainee@centos7 SPECS]$ head kernel.spec # We have to override the new %%install behavior because, well... the kernel is special. %global __spec_install_pre %{___build_pre} Summary: The Linux kernel %define buildid .i2tch # For a kernel released for public testing, released_kernel should be 1. # For internal testing builds during development, it should be 0. %global released_kernel 1
La compilation du noyau peut prendre beaucoup de temps. La commande utilisée est la suivante :
[trainee@centos7 SPECS]$ rpmbuild -bb --target=`uname -m` kernel.spec
A l'issu du processus, les rpm se trouvent dans le répertoire /home/trainee/rpmbuild/RPMS/x86_64/ :
... Vérification des fichiers non empaquetés : /usr/lib/rpm/check-files /home/trainee/rpmbuild/BUILDROOT/kernel-3.10.0-327.13.1.el7.i2tch.x86_64 Écrit : /home/trainee/rpmbuild/RPMS/x86_64/kernel-3.10.0-327.13.1.el7.i2tch.x86_64.rpm Écrit : /home/trainee/rpmbuild/RPMS/x86_64/kernel-headers-3.10.0-327.13.1.el7.i2tch.x86_64.rpm Écrit : /home/trainee/rpmbuild/RPMS/x86_64/kernel-debuginfo-common-x86_64-3.10.0-327.13.1.el7.i2tch.x86_64.rpm Écrit : /home/trainee/rpmbuild/RPMS/x86_64/perf-3.10.0-327.13.1.el7.i2tch.x86_64.rpm Écrit : /home/trainee/rpmbuild/RPMS/x86_64/perf-debuginfo-3.10.0-327.13.1.el7.i2tch.x86_64.rpm Écrit : /home/trainee/rpmbuild/RPMS/x86_64/python-perf-3.10.0-327.13.1.el7.i2tch.x86_64.rpm Écrit : /home/trainee/rpmbuild/RPMS/x86_64/python-perf-debuginfo-3.10.0-327.13.1.el7.i2tch.x86_64.rpm Écrit : /home/trainee/rpmbuild/RPMS/x86_64/kernel-tools-3.10.0-327.13.1.el7.i2tch.x86_64.rpm Écrit : /home/trainee/rpmbuild/RPMS/x86_64/kernel-tools-libs-3.10.0-327.13.1.el7.i2tch.x86_64.rpm Écrit : /home/trainee/rpmbuild/RPMS/x86_64/kernel-tools-libs-devel-3.10.0-327.13.1.el7.i2tch.x86_64.rpm Écrit : /home/trainee/rpmbuild/RPMS/x86_64/kernel-tools-debuginfo-3.10.0-327.13.1.el7.i2tch.x86_64.rpm Écrit : /home/trainee/rpmbuild/RPMS/x86_64/kernel-devel-3.10.0-327.13.1.el7.i2tch.x86_64.rpm Écrit : /home/trainee/rpmbuild/RPMS/x86_64/kernel-debuginfo-3.10.0-327.13.1.el7.i2tch.x86_64.rpm Écrit : /home/trainee/rpmbuild/RPMS/x86_64/kernel-debug-3.10.0-327.13.1.el7.i2tch.x86_64.rpm Écrit : /home/trainee/rpmbuild/RPMS/x86_64/kernel-debug-devel-3.10.0-327.13.1.el7.i2tch.x86_64.rpm Écrit : /home/trainee/rpmbuild/RPMS/x86_64/kernel-debug-debuginfo-3.10.0-327.13.1.el7.i2tch.x86_64.rpm Exécution_de(%clean) : /bin/sh -e /var/tmp/rpm-tmp.HNhcuC + umask 022 + cd /home/trainee/rpmbuild/BUILD + cd kernel-3.10.0-327.13.1.el7 + rm -rf /home/trainee/rpmbuild/BUILDROOT/kernel-3.10.0-327.13.1.el7.i2tch.x86_64 + exit 0
Notez que la génération du nouveau noyau a consommé plus de 9 Go d'espace disque :
[trainee@centos7 SPECS]$ df -h Sys. de fichiers Taille Utilisé Dispo Uti% Monté sur /dev/sda2 9,8G 4,3G 5,5G 44% / devtmpfs 231M 0 231M 0% /dev tmpfs 245M 0 245M 0% /dev/shm tmpfs 245M 4,7M 240M 2% /run tmpfs 245M 0 245M 0% /sys/fs/cgroup tmpfs 245M 40K 245M 1% /tmp /dev/sdb1 20G 9,5G 9,2G 51% /home /dev/sda1 197M 197M 20K 100% /boot tmpfs 49M 0 49M 0% /run/user/1000
Installez maintenant les deux paquets kernel-devel et kernel-headers :
[root@centos7 ~]# rpm -ivh /home/trainee/rpmbuild/RPMS/x86_64/kernel-devel-3.10.0-327.13.1.el7.i2tch.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:kernel-devel-3.10.0-327.13.1.el7.################################# [100%] [root@centos7 ~]# rpm -ivh /home/trainee/rpmbuild/RPMS/x86_64/kernel-headers-3.10.0-327.13.1.el7.i2tch.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:kernel-headers-3.10.0-327.13.1.el################################# [100%]
Installez en dernier le nouveau noyau avec la commande rpm :
[root@centos7 ~]# rpm -ivh --force --nodeps /home/trainee/rpmbuild/RPMS/x86_64/kernel-3.10.0-327.13.1.el7.i2tch.x86_64.rpm Preparing... ################################# [100%] installing package kernel-3.10.0-327.13.1.el7.i2tch.x86_64 needs 30MB on the /boot filesystem
Important : Notez le message d'erreur concernant le manque d'espace disponible sur /boot.
Lister maintenant les noyaux installés :
[root@centos7 ~]# rpm -qa | grep kernel-3 kernel-3.10.0-327.el7.x86_64 kernel-3.10.0-327.13.1.el7.x86_64
Un noyau se désinstalle comme tout autre paquet :
[root@centos7 ~]# yum remove kernel-3.10.0-327.el7.x86_64 Loaded plugins: fastestmirror, langpacks Resolving Dependencies --> Running transaction check ---> Package kernel.x86_64 0:3.10.0-327.el7 will be erased --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================================== Package Arch Version Repository Size ======================================================================================================================================================================== Removing: kernel x86_64 3.10.0-327.el7 @base/$releasever 136 M Transaction Summary ======================================================================================================================================================================== Remove 1 Package Installed size: 136 M Is this ok [y/N]: y
Installez le nouveau noyau avec la commande rpm :
[root@centos7 ~]# rpm -ivh --force --nodeps /home/trainee/rpmbuild/RPMS/x86_64/kernel-3.10.0-327.13.1.el7.i2tch.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:kernel-3.10.0-327.13.1.el7.i2tch ################################# [100%]
Lister maintenant les noyaux installés :
[root@centos7 ~]# rpm -qa | grep kernel-3 kernel-3.10.0-327.13.1.el7.i2tch.x86_64 kernel-3.10.0-327.13.1.el7.x86_64
Constatez la création d'un nouveau grub.cfg :
[root@centos7 ~]# grep i2tch /boot/grub2/grub.cfg menuentry 'CentOS Linux (3.10.0-327.13.1.el7.i2tch.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-327.el7.x86_64-advanced-e65fe7da-cda8-4f5a-a827-1b5cabe94bed' { linux16 /vmlinuz-3.10.0-327.13.1.el7.i2tch.x86_64 root=UUID=e65fe7da-cda8-4f5a-a827-1b5cabe94bed ro rhgb quiet LANG=en_GB.UTF-8 initrd16 /initramfs-3.10.0-327.13.1.el7.i2tch.x86_64.img
Important : Re-démarrez votre VM en utilisant le nouveau noyau.
Vérifiez ensuite l'utilisation du nouveau noyau :
[root@centos7 ~]# uname -r 3.10.0-327.13.1.el7.i2tch.x86_64
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, uniquement des quotas par partition. L'administrateur met souvent des quotas en place sur l'arborescence de /home pour limiter l'espace de stockage occupé par les utilisateurs.
Déconnectez-vous et reconnectez-vous en tant que root.
Avant de mettre en place des quotas, configurer SELINUX en mode permissive afin de ne pas avoir d'erreurs de ce dernier :
[root@centos7 ~]# getenforce Enforcing [root@centos7 ~]# setenforce permissive [root@centos7 ~]# getenforce Permissive
Editez ensuite le fichier /etc/sysconfig/selinux ainsi :
[root@centos7 ~]# vi /etc/sysconfig/selinux [root@centos7 ~]# cat /etc/sysconfig/selinux # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=permissive # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
Commencez par vérifiez que le paquet quota est bien installé :
[root@centos7 ~]# rpm -qa | grep quota quota-4.01-11.el7_2.1.x86_64 quota-nls-4.01-11.el7_2.1.noarch
Editez le fichier /etc/fstab en ajoutant les options usrquota et grpquota à la ligne /home :
[root@centos7 ~]# vi /etc/fstab [root@centos7 ~]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Sat Apr 30 11:27:02 2016 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=e65fe7da-cda8-4f5a-a827-1b5cabe94bed / xfs defaults 0 0 UUID=2d947276-66e8-41f4-8475-b64b67d7a249 /boot xfs defaults 0 0 UUID=3181601a-7295-4ef0-a92c-f21f76b18e64 swap swap defaults 0 0 UUID=a080ac6a-d15c-48e2-8461-a7b1aa3ebf1a /home ext4 defaults,usrquota,grpquota 1 2
Démontez puis remontez /home :
[root@centos7 ~]# umount /home [root@centos7 ~]# mount -a
Déconnectez-vous et reconnectez-vous en tant que trainee. Vérifiez ensuite que les options soient prises en compte :
[root@centos7 ~]# cat /etc/mtab rootfs / rootfs rw 0 0 sysfs /sys sysfs rw,seclabel,nosuid,nodev,noexec,relatime 0 0 proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0 devtmpfs /dev devtmpfs rw,seclabel,nosuid,size=236036k,nr_inodes=59009,mode=755 0 0 securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0 tmpfs /dev/shm tmpfs rw,seclabel,nosuid,nodev 0 0 devpts /dev/pts devpts rw,seclabel,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0 tmpfs /run tmpfs rw,seclabel,nosuid,nodev,mode=755 0 0 tmpfs /sys/fs/cgroup tmpfs ro,seclabel,nosuid,nodev,noexec,mode=755 0 0 cgroup /sys/fs/cgroup/systemd cgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd 0 0 pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0 cgroup /sys/fs/cgroup/net_cls cgroup rw,nosuid,nodev,noexec,relatime,net_cls 0 0 cgroup /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0 cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0 cgroup /sys/fs/cgroup/hugetlb cgroup rw,nosuid,nodev,noexec,relatime,hugetlb 0 0 cgroup /sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0 cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0 cgroup /sys/fs/cgroup/cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpuacct,cpu 0 0 cgroup /sys/fs/cgroup/perf_event cgroup rw,nosuid,nodev,noexec,relatime,perf_event 0 0 cgroup /sys/fs/cgroup/cpuset cgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0 configfs /sys/kernel/config configfs rw,relatime 0 0 /dev/sda2 / xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0 selinuxfs /sys/fs/selinux selinuxfs rw,relatime 0 0 systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct 0 0 debugfs /sys/kernel/debug debugfs rw,relatime 0 0 hugetlbfs /dev/hugepages hugetlbfs rw,seclabel,relatime 0 0 tmpfs /tmp tmpfs rw,seclabel 0 0 mqueue /dev/mqueue mqueue rw,seclabel,relatime 0 0 sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw,relatime 0 0 nfsd /proc/fs/nfsd nfsd rw,relatime 0 0 /dev/sda1 /boot xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0 tmpfs /run/user/0 tmpfs rw,seclabel,nosuid,nodev,relatime,size=50080k,mode=700 0 0 /dev/sdb1 /home ext4 rw,seclabel,relatime,quota,usrquota,grpquota,data=ordered 0 0
Pour activer les quotas sur /home, il convient d'utiliser la commande quotacheck :
[root@centos7 ~]# quotacheck -cugvm -f /dev/sdb1 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: Parcours de /dev/sdb1 [/home] terminé quotacheck: Cannot stat old user quota file /home/aquota.user: Aucun fichier ou dossier de ce type. Usage will not be subtracted. quotacheck: Cannot stat old group quota file /home/aquota.group: Aucun fichier ou dossier de ce type. Usage will not be subtracted. quotacheck: Cannot stat old user quota file /home/aquota.user: Aucun fichier ou dossier de ce type. Usage will not be subtracted. quotacheck: Cannot stat old group quota file /home/aquota.group: Aucun fichier ou dossier de ce type. Usage will not be subtracted. quotacheck: Vérifié 100 répertoires et 230 fichiers quotacheck: Ancien fichier non trouvé. quotacheck: Ancien fichier non trouvé.
Les options de la commande quotacheck sont :
[root@centos7 ~]# quotacheck --help Utility for checking and repairing quota files. quotacheck [-gucbfinvdmMR] [-F <quota-format>] filesystem|-a -u, --user check user files -g, --group check group files -c, --create-files create new quota files -b, --backup create backups of old quota files -f, --force force check even if quotas are enabled -i, --interactive interactive mode -n, --use-first-dquot use the first copy of duplicated structure -v, --verbose print more information -d, --debug print even more messages -m, --no-remount do not remount filesystem read-only -M, --try-remount try remounting filesystem read-only, continue even if it fails -R, --exclude-root exclude root when checking all filesystems -F, --format=formatname check quota files of specific format -a, --all check all filesystems -h, --help display this message and exit -V, --version display version information and exit Rapports de bugs à 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@centos7 ~]# ls -la /home total 44 drwxr-xr-x. 4 root root 4096 11 août 13:39 . dr-xr-xr-x. 18 root root 4096 11 août 13:27 .. -rw-------. 1 root root 7168 11 août 13:39 aquota.group -rw-------. 1 root root 7168 11 août 13:39 aquota.user drwx------. 2 root root 16384 11 août 13:26 lost+found drwx------. 14 trainee trainee 4096 30 avril 15:29 trainee
Créez maintenant un utilisateur fenestros avec le mot de passe fenestros :
[root@centos7 ~]# groupadd fenestros && useradd fenestros -c FenestrOs -d /home/fenestros -g fenestros -s /bin/bash [root@centos7 ~]# passwd fenestros Changement de mot de passe pour l'utilisateur fenestros. Nouveau mot de passe : fenestros MOT DE PASSE INCORRECT : Le mot de passe contient le nom d'utilisateur sous une forme Retapez le nouveau mot de passe : fenestros passwd : mise à jour réussie de tous les jetons d'authentification. [root@centos7 ~]#
Mettez en place maintenant un quota de 10Mo pour l'utilisateur fenestros :
[root@centos ~]# edquota -u fenestros -f /home
L'éditeur vi se lance et vous obtiendrez un résultat similaire à celui-ci :
Quotas disque pour user fenestros (uid 1001) : Système de fichiers blocs souple stricte inodes souple stricte /dev/sdb1 0 0 0 0 0 0
Modifiez ce fichier ainsi :
Quotas disque pour user fenestros (uid 1001) : Système de fichiers blocs souple stricte inodes souple stricte /dev/sdb1 0 8000 10000 0 0 0
Les options de la commande edquota sont :
[root@centos7 ~]# 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 [-u|g] [-F formatname] [-f filesystem] -t edquota [-u|g] [-F formatname] [-f filesystem] -T username|groupname ... -u, --user edit user data -g, --group edit group data -r, --remote edit remote quota (via RPC) -m, --no-mixed-pathnames trim leading slashes from NFSv4 mountpoints -F, --format=formatname edit quotas of a specific format -p, --prototype=name copy data from a prototype user/group --always-resolve always try to resolve name, even if it is composed only of digits -f, --filesystem=filesystem edit data only on a specific filesystem -t, --edit-period edit grace period -T, --edit-times edit grace time of a user/group -h, --help display this help text and exit -V, --version display version information and exit Rapports de bugs à : jack@suse.cz
Pour mettre en place un quota par group, la procédure est similaire. Il suffit d'utiliser l'option -g de la commande edquota.
Appliquez maintenant les quotas :
[root@centos7 ~]# quotaon -a
Les options de la commande quotaon sont :
[root@centos7 ~]# quotaon --help quotaon: Usage: quotaon [-guvp] [-F quotaformat] [-x state] -a quotaon [-guvp] [-F quotaformat] [-x state] filesys ... -a, --all turn quotas on for all filesystems -f, --off turn quotas off -u, --user operate on user quotas -g, --group operate on group quotas -p, --print-state print whether quotas are on or off -x, --xfs-command=cmd perform XFS quota command -F, --format=formatname operate on specific quota format -v, --verbose print more messages -h, --help display this help text and exit -V, --version display version information and exit
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'utilisateur fenestros aura dépassé le quota souple, il recevra un message d'avertissement. Quand il dépasse le quota stricte, il ne pourra plus enregistrer dans /home, sauf dans le cas où il supprime des fichiers pour retomber en dessous de la limite stricte.
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'inodes utilisés par l'utilisateur.
La commande pour désactivez les quotas est quotaoff.
Pour visualiser les quotas utilisez la commande repquota :
[root@centos7 ~]# repquota /home *** Rapport pour les quotas user sur le périphérique /dev/sdb1 Période de sursis bloc : 7days ; période de sursis inode : 7days Block limits File limits Utilisateur utilisé souple stricte sursis utilisé souple stricte sursis ---------------------------------------------------------------------- root -- 20 0 0 2 0 0 trainee -- 20484 0 0 328 0 0
Notez que l'utilisateur fenestros ne figure pas dans la liste. Sous CentOS, le quota n'est pas visible tant que l'utilisateur ne s'est pas connecté pour la première fois. Notez aussi les période de grâce de 7 jours.
Les options de la commande repquota sont :
[root@centos7 ~]# repquota --help repquota: Utility for reporting quotas. Usage: repquota [-vugsi] [-c|C] [-t|n] [-F quotaformat] (-a | mntpoint) -v, --verbose display also users/groups without any usage -u, --user display information about users -g, --group display information about groups -s, --human-readable show numbers in human friendly units (MB, GB, ...) -t, --truncate-names truncate names to 9 characters -p, --raw-grace print grace time in seconds since epoch -n, --no-names do not translate uid/gid to name -i, --no-autofs avoid autofs mountpoints -c, --cache translate big number of ids at once -C, --no-cache translate ids one by one -F, --format=formatname report information for specific format -a, --all report information for all mount points with quotas -h, --help display this help message and exit -V, --version display version information and exit Rapports de bugs à jack@suse.cz
Pour visualiser les quotas d'un utilisateur spécifique, il convient d'utiliser la commande quota :
[root@centos7 ~]# quota fenestros Disk quotas for user fenestros (uid 1001): aucun [root@centos7 ~]# su - fenestros [fenestros@centos7 ~]$ touch test [fenestros@centos7 ~]$ exit logout [root@centos7 ~]# quota fenestros Disk quotas for user fenestros (uid 1001): Système fichiers blocs quota limite sursisfichiers quota limite sursis /dev/sdb1 24 8000 10000 7 0 0
Les options de la commande quota sont :
[root@centos7 ~]# quota --help quota: Usage: quota [-guqvswim] [-l | [-Q | -A]] [-F quotaformat] quota [-qvswim] [-l | [-Q | -A]] [-F quotaformat] -u username ... quota [-qvswim] [-l | [-Q | -A]] [-F quotaformat] -g groupname ... quota [-qvswugQm] [-F quotaformat] -f filesystem ... -u, --user display quota for user -g, --group display quota for group -q, --quiet print more terse message -v, --verbose print more verbose message -s, --human-readable display numbers in human friendly units (MB, GB...) --always-resolve always try to translate name to id, even if it is composed of only digits -w, --no-wrap do not wrap long lines -p, --raw-grace print grace time in seconds since epoch -l, --local-only do not query NFS filesystems -Q, --quiet-refuse do not print error message when NFS server does not respond -i, --no-autofs do not query autofs mountpoints -F, --format=formatname display quota of a specific format -f, --filesystem-list display quota information only for given filesystems -A, --all-nfs display quota for all NFS mountpoints -m, --no-mixed-pathnames trim leading slashes from NFSv4 mountpoints --show-mntpoint show mount point of the file system in output --hide-device do not show file system device in output -h, --help display this help message and exit -V, --version display version information and exit Rapports de bugs à : jack@suse.cz
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/CentOS 7, warnquota n'est pas installé par défaut :
[root@centos7 ~]# yum install quota-warnquota Modules complémentaires chargés : fastestmirror, langpacks base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 Loading mirror speeds from cached hostfile * base: centos.quelquesmots.fr * extras: miroir.univ-paris13.fr * updates: miroir.univ-paris13.fr Résolution des dépendances --> Lancement de la transaction de test ---> Le paquet quota-warnquota.x86_64 1:4.01-11.el7_2.1 sera installé --> Résolution des dépendances terminée Dépendances résolues ======================================================================================================================================================================== Package Architecture Version Dépôt Taille ======================================================================================================================================================================== Installation : quota-warnquota x86_64 1:4.01-11.el7_2.1 updates 76 k Résumé de la transaction ======================================================================================================================================================================== Installation 1 Paquet Taille totale des téléchargements : 76 k Taille d'installation : 137 k Is this ok [y/d/N]: y
Les options de la commande warnquota sont :
[root@centos7 ~]# warnquota --help warnquota: Usage: warnquota [-ugsid] [-F quotaformat] [-c configfile] [-q quotatabfile] [-a adminsfile] [filesystem...] -u, --user warn users -g, --group warn groups -s, --human-readable send information in more human friendly units -i, --no-autofs avoid autofs mountpoints -d, --no-details do not send quota information itself -F, --format=formatname use quotafiles of specific format -c, --config=config-file non-default config file -q, --quota-tab=quotatab-file non-default quotatab -a, --admins-file=admins-file non-default admins file -h, --help display this help message and exit -v, --version display version information and exit Rapports de bugs à jack@suse.cz
Copyright © 2023 Hugh Norris.