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:admin:l117 [2022/06/05 17:53] – removed admin | elearning:workbooks:centos:8:admin:l117 [2022/06/05 17:55] (Version actuelle) – admin | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | ~~PDF: | ||
| + | Version : **2022.01** | ||
| + | |||
| + | Updated: ~~LASTMOD~~ | ||
| + | |||
| + | ======LCE511 - Managing Integrated Peripherals====== | ||
| + | |||
| + | =====Contents===== | ||
| + | |||
| + | * **LCE511 - Managing Integrated Peripherals** | ||
| + | * Contents | ||
| + | * Special Files | ||
| + | * LAB #1 - Commands | ||
| + | * 1.1 - The lspci Command | ||
| + | * 1.2 - The lsusb Command | ||
| + | * 1.3 - The dmidecode Command | ||
| + | * LAB #2 - The sysctl Command | ||
| + | * 2.1 - The /proc Directory | ||
| + | * Files | ||
| + | * / | ||
| + | * / | ||
| + | * /proc/dma | ||
| + | * / | ||
| + | * / | ||
| + | * / | ||
| + | * / | ||
| + | * / | ||
| + | * /proc/swaps | ||
| + | * / | ||
| + | * / | ||
| + | * / | ||
| + | * Directories | ||
| + | * ide/scsi | ||
| + | * acpi | ||
| + | * bus | ||
| + | * net | ||
| + | * sys | ||
| + | * 2.2 - Using the sysctl Command | ||
| + | * LAB #3 - Interpreting Information in /proc | ||
| + | * 3.1 - free | ||
| + | * 3.2 - uptime ou w | ||
| + | * 3.3 - iostat | ||
| + | * 3.4 - hdparm | ||
| + | * 3.5 - vmstat | ||
| + | * 3.6 - mpstat | ||
| + | * 3.7 - sar | ||
| + | * USB Modules | ||
| + | * udev | ||
| + | * The udevadm Command | ||
| + | * The /sys Filesystem | ||
| + | * LAB #4 - Limiting Ressources | ||
| + | * 4.1 - ulimit | ||
| + | * 4.2 - CGroups | ||
| + | * Limiting Memeory Usage | ||
| + | * The cgcreate Command | ||
| + | * The cgdelete Command | ||
| + | * The / | ||
| + | * The cgconfigparser Command | ||
| + | |||
| + | =====Special Files===== | ||
| + | |||
| + | In a PC, peripherals are connected to a **controler** which communicates with the processor via a **bus**. The controller and associated peripherals require specific drivers. Under Linux, these drivers are normally supplied as kernel **modules**. Each peripheral is represented by a special file in the **/dev** directory. Each special file contains the information required by the system in order for it to use the driver. | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | Peripherals that require the system to be halted prior to plugging or unplugging them are refered to as **Cold Plug Devices**. Peripherals that can be plugged/ | ||
| + | </ | ||
| + | |||
| + | The following output shows the typical content of the /dev directory: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# ls -l /dev | more | ||
| + | total 0 | ||
| + | crw-r--r--. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | lrwxrwxrwx. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | crw-------. | ||
| + | lrwxrwxrwx. | ||
| + | drwxr-xr-x. 10 root root 200 Jun 28 02:04 cpu | ||
| + | crw-------. | ||
| + | drwxr-xr-x. | ||
| + | brw-rw----. | ||
| + | brw-rw----. | ||
| + | drwxr-xr-x. | ||
| + | crw-rw----. | ||
| + | lrwxrwxrwx. | ||
| + | crw-rw-rw-. | ||
| + | crw-rw-rw-. | ||
| + | crw-------. | ||
| + | crw-------. | ||
| + | drwxr-xr-x. | ||
| + | crw-------. | ||
| + | lrwxrwxrwx. | ||
| + | drwxr-xr-x. | ||
| + | crw-r--r--. | ||
| + | lrwxrwxrwx. | ||
| + | crw-rw----. | ||
| + | crw-rw----. | ||
| + | crw-rw----. | ||
| + | crw-rw----. | ||
| + | crw-rw----. | ||
| + | drwxr-xr-x. | ||
| + | crw-------. | ||
| + | crw-r-----. | ||
| + | drwxrwxrwt. | ||
| + | drwxr-xr-x. | ||
| + | crw-rw-rw-. | ||
| + | --More-- | ||
| + | </ | ||
| + | |||
| + | As you can see, certain files refer to **block** devices whilst others refer to **character** devices: | ||
| + | |||
| + | < | ||
| + | ... | ||
| + | brw-rw----. | ||
| + | ... | ||
| + | crw-rw-rw-. | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | The major difference between these two types lies in the way that the communication between the system and the peripheral takes place. In the case of a block file, that communication uses a buffer whilst in the case of a character file the communication takes place directly byte by byte. | ||
| + | |||
| + | The figures that can be seen immediately before the date of the special file are called respectively the **major** and the **minor** : | ||
| + | |||
| + | * the **major** identifies the peripheral' | ||
| + | * the **minor** identifies the peripheral. For instance 8,1 indicates the first partition of the **sda** disk. | ||
| + | |||
| + | =====LAB #1 - Commands===== | ||
| + | |||
| + | ====1.1 - The lspci Command==== | ||
| + | |||
| + | This command show a list of the peripherals connected to the PCI, AGP and PCI express buses: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# lspci | ||
| + | 00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02) | ||
| + | 00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/ | ||
| + | 00:01.1 IDE interface: Intel Corporation 82371SB PIIX3 IDE [Natoma/ | ||
| + | 00:01.2 USB controller: Intel Corporation 82371SB PIIX3 USB [Natoma/ | ||
| + | 00:01.3 Bridge: Intel Corporation 82371AB/ | ||
| + | 00:02.0 VGA compatible controller: Device 1234:1111 (rev 02) | ||
| + | 00:03.0 Unclassified device [00ff]: Red Hat, Inc. Virtio memory balloon | ||
| + | 00:07.0 SATA controller: Intel Corporation 82801IR/ | ||
| + | 00:12.0 Ethernet controller: Red Hat, Inc. Virtio network device | ||
| + | 00:1e.0 PCI bridge: Red Hat, Inc. QEMU PCI-PCI bridge | ||
| + | 00:1f.0 PCI bridge: Red Hat, Inc. QEMU PCI-PCI bridge | ||
| + | </ | ||
| + | |||
| + | To obtain peripheral specific information, | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# lspci -v -s 00:03.0 | ||
| + | 00:03.0 Unclassified device [00ff]: Red Hat, Inc. Virtio memory balloon | ||
| + | Subsystem: Red Hat, Inc. Device 0005 | ||
| + | Physical Slot: 3 | ||
| + | Flags: bus master, fast devsel, latency 0, IRQ 10 | ||
| + | I/O ports at e000 [size=64] | ||
| + | Memory at fe400000 (64-bit, prefetchable) [size=16K] | ||
| + | Capabilities: | ||
| + | Capabilities: | ||
| + | Capabilities: | ||
| + | Capabilities: | ||
| + | Capabilities: | ||
| + | Kernel driver in use: virtio-pci | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# lspci -vv -s 00:03.0 | ||
| + | 00:03.0 Unclassified device [00ff]: Red Hat, Inc. Virtio memory balloon | ||
| + | Subsystem: Red Hat, Inc. Device 0005 | ||
| + | Physical Slot: 3 | ||
| + | Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx- | ||
| + | Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx- | ||
| + | Latency: 0 | ||
| + | Interrupt: pin A routed to IRQ 10 | ||
| + | Region 0: I/O ports at e000 [size=64] | ||
| + | Region 4: Memory at fe400000 (64-bit, prefetchable) [size=16K] | ||
| + | Capabilities: | ||
| + | BAR=0 offset=00000000 size=00000000 | ||
| + | Capabilities: | ||
| + | BAR=4 offset=00003000 size=00001000 multiplier=00000004 | ||
| + | Capabilities: | ||
| + | BAR=4 offset=00002000 size=00001000 | ||
| + | Capabilities: | ||
| + | BAR=4 offset=00001000 size=00001000 | ||
| + | Capabilities: | ||
| + | BAR=4 offset=00000000 size=00001000 | ||
| + | Kernel driver in use: virtio-pci | ||
| + | </ | ||
| + | |||
| + | ===Command Line Switches=== | ||
| + | |||
| + | The command line switches of this command are: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# lspci --help | ||
| + | lspci: invalid option -- ' | ||
| + | Usage: lspci [< | ||
| + | |||
| + | Basic display modes: | ||
| + | -mm | ||
| + | -t Show bus tree | ||
| + | |||
| + | Display options: | ||
| + | -v Be verbose (-vv or -vvv for higher verbosity) | ||
| + | -k Show kernel drivers handling each device | ||
| + | -x Show hex-dump of the standard part of the config space | ||
| + | -xxx Show hex-dump of the whole config space (dangerous; root only) | ||
| + | -xxxx Show hex-dump of the 4096-byte extended config space (root only) | ||
| + | -b Bus-centric view (addresses and IRQ's as seen by the bus) | ||
| + | -D Always show domain numbers | ||
| + | -P Display bridge path in addition to bus and device number | ||
| + | -PP | ||
| + | |||
| + | Resolving of device ID's to names: | ||
| + | -n Show numeric ID's | ||
| + | -nn Show both textual and numeric ID's (names & numbers) | ||
| + | -q Query the PCI ID database for unknown ID's via DNS | ||
| + | -qq As above, but re-query locally cached entries | ||
| + | -Q Query the PCI ID database for all ID's via DNS | ||
| + | |||
| + | Selection of devices: | ||
| + | -s [[[[< | ||
| + | -d [< | ||
| + | |||
| + | Other options: | ||
| + | -i < | ||
| + | -p < | ||
| + | -M Enable `bus | ||
| + | </ | ||
| + | |||
| + | ====1.2 - The lsusb Command==== | ||
| + | |||
| + | This command show a list of the peripherals connected to the USB bus: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# lsusb | ||
| + | Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd | ||
| + | Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub | ||
| + | |||
| + | [root@centos8 ~]# lsusb -vt | ||
| + | /: Bus 01.Port 1: Dev 1, Class=root_hub, | ||
| + | |__ Port 1: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, | ||
| + | </ | ||
| + | |||
| + | ===Command Line Switches=== | ||
| + | |||
| + | The command line switches of this command are: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# lsusb --help | ||
| + | Usage: lsusb [options]... | ||
| + | List USB devices | ||
| + | -v, --verbose | ||
| + | Increase verbosity (show descriptors) | ||
| + | -s [[bus]: | ||
| + | Show only devices with specified device and/or | ||
| + | bus numbers (in decimal) | ||
| + | -d vendor: | ||
| + | Show only devices with the specified vendor and | ||
| + | product ID numbers (in hexadecimal) | ||
| + | .LAB#1 | ||
| + | -D device | ||
| + | Selects which device lsusb will examine | ||
| + | -t, --tree | ||
| + | Dump the physical USB device hierarchy as a tree | ||
| + | -V, --version | ||
| + | Show version of program | ||
| + | -h, --help | ||
| + | Show usage and help | ||
| + | </ | ||
| + | |||
| + | ====1.3 - The dmidecode Command==== | ||
| + | |||
| + | The **dmidecode** Command reads the **DMI** (//Desktop Management Interface// | ||
| + | |||
| + | * the current status of each peripheral, | ||
| + | * possible extensions. | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# dmidecode | ||
| + | # dmidecode 3.2 | ||
| + | Getting SMBIOS data from sysfs. | ||
| + | SMBIOS 2.8 present. | ||
| + | 11 structures occupying 511 bytes. | ||
| + | Table at 0x000F5870. | ||
| + | |||
| + | Handle 0x0000, DMI type 0, 24 bytes | ||
| + | BIOS Information | ||
| + | Vendor: SeaBIOS | ||
| + | Version: rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org | ||
| + | Release Date: 04/01/2014 | ||
| + | Address: 0xE8000 | ||
| + | Runtime Size: 96 kB | ||
| + | ROM Size: 64 kB | ||
| + | Characteristics: | ||
| + | BIOS characteristics not supported | ||
| + | Targeted content distribution is supported | ||
| + | BIOS Revision: 0.0 | ||
| + | |||
| + | Handle 0x0100, DMI type 1, 27 bytes | ||
| + | System Information | ||
| + | Manufacturer: | ||
| + | Product Name: Standard PC (i440FX + PIIX, 1996) | ||
| + | Version: pc-i440fx-5.2 | ||
| + | Serial Number: Not Specified | ||
| + | UUID: 95bd69e3-4a74-44a7-b58c-b74fbfb86df2 | ||
| + | Wake-up Type: Power Switch | ||
| + | SKU Number: Not Specified | ||
| + | Family: Not Specified | ||
| + | |||
| + | Handle 0x0300, DMI type 3, 22 bytes | ||
| + | Chassis Information | ||
| + | Manufacturer: | ||
| + | Type: Other | ||
| + | Lock: Not Present | ||
| + | Version: pc-i440fx-5.2 | ||
| + | Serial Number: Not Specified | ||
| + | Asset Tag: Not Specified | ||
| + | Boot-up State: Safe | ||
| + | Power Supply State: Safe | ||
| + | Thermal State: Safe | ||
| + | Security Status: Unknown | ||
| + | OEM Information: | ||
| + | Height: Unspecified | ||
| + | Number Of Power Cords: Unspecified | ||
| + | Contained Elements: 0 | ||
| + | SKU Number: Not Specified | ||
| + | |||
| + | Handle 0x0400, DMI type 4, 42 bytes | ||
| + | Processor Information | ||
| + | Socket Designation: | ||
| + | Type: Central Processor | ||
| + | Family: Other | ||
| + | Manufacturer: | ||
| + | ID: 61 0F 00 00 FF FB 8B 07 | ||
| + | Version: pc-i440fx-5.2 | ||
| + | Voltage: Unknown | ||
| + | External Clock: Unknown | ||
| + | Max Speed: 2000 MHz | ||
| + | Current Speed: 2000 MHz | ||
| + | Status: Populated, Enabled | ||
| + | Upgrade: Other | ||
| + | L1 Cache Handle: Not Provided | ||
| + | L2 Cache Handle: Not Provided | ||
| + | L3 Cache Handle: Not Provided | ||
| + | Serial Number: Not Specified | ||
| + | Asset Tag: Not Specified | ||
| + | Part Number: Not Specified | ||
| + | Core Count: 4 | ||
| + | Core Enabled: 4 | ||
| + | Thread Count: 1 | ||
| + | Characteristics: | ||
| + | |||
| + | Handle 0x0401, DMI type 4, 42 bytes | ||
| + | Processor Information | ||
| + | Socket Designation: | ||
| + | Type: Central Processor | ||
| + | Family: Other | ||
| + | Manufacturer: | ||
| + | ID: 61 0F 00 00 FF FB 8B 07 | ||
| + | Version: pc-i440fx-5.2 | ||
| + | Voltage: Unknown | ||
| + | External Clock: Unknown | ||
| + | Max Speed: 2000 MHz | ||
| + | Current Speed: 2000 MHz | ||
| + | Status: Populated, Enabled | ||
| + | Upgrade: Other | ||
| + | L1 Cache Handle: Not Provided | ||
| + | L2 Cache Handle: Not Provided | ||
| + | L3 Cache Handle: Not Provided | ||
| + | Serial Number: Not Specified | ||
| + | Asset Tag: Not Specified | ||
| + | Part Number: Not Specified | ||
| + | Core Count: 4 | ||
| + | Core Enabled: 4 | ||
| + | Thread Count: 1 | ||
| + | Characteristics: | ||
| + | |||
| + | Handle 0x1000, DMI type 16, 23 bytes | ||
| + | Physical Memory Array | ||
| + | Location: Other | ||
| + | Use: System Memory | ||
| + | Error Correction Type: Multi-bit ECC | ||
| + | Maximum Capacity: 4 GB | ||
| + | Error Information Handle: Not Provided | ||
| + | Number Of Devices: 1 | ||
| + | |||
| + | Handle 0x1100, DMI type 17, 40 bytes | ||
| + | Memory Device | ||
| + | Array Handle: 0x1000 | ||
| + | Error Information Handle: Not Provided | ||
| + | Total Width: Unknown | ||
| + | Data Width: Unknown | ||
| + | Size: 4 GB | ||
| + | Form Factor: DIMM | ||
| + | Set: None | ||
| + | Locator: DIMM 0 | ||
| + | Bank Locator: Not Specified | ||
| + | Type: RAM | ||
| + | Type Detail: Other | ||
| + | Speed: Unknown | ||
| + | Manufacturer: | ||
| + | Serial Number: Not Specified | ||
| + | Asset Tag: Not Specified | ||
| + | Part Number: Not Specified | ||
| + | Rank: Unknown | ||
| + | Configured Memory Speed: Unknown | ||
| + | Minimum Voltage: Unknown | ||
| + | Maximum Voltage: Unknown | ||
| + | Configured Voltage: Unknown | ||
| + | |||
| + | Handle 0x1300, DMI type 19, 31 bytes | ||
| + | Memory Array Mapped Address | ||
| + | Starting Address: 0x00000000000 | ||
| + | Ending Address: 0x000BFFFFFFF | ||
| + | Range Size: 3 GB | ||
| + | Physical Array Handle: 0x1000 | ||
| + | Partition Width: 1 | ||
| + | |||
| + | Handle 0x1301, DMI type 19, 31 bytes | ||
| + | Memory Array Mapped Address | ||
| + | Starting Address: 0x00100000000 | ||
| + | Ending Address: 0x0013FFFFFFF | ||
| + | Range Size: 1 GB | ||
| + | Physical Array Handle: 0x1000 | ||
| + | Partition Width: 1 | ||
| + | |||
| + | Handle 0x2000, DMI type 32, 11 bytes | ||
| + | System Boot Information | ||
| + | Status: No errors detected | ||
| + | |||
| + | Handle 0x7F00, DMI type 127, 4 bytes | ||
| + | End Of Table | ||
| + | </ | ||
| + | |||
| + | ===Command Line Switches=== | ||
| + | |||
| + | The command line switches of this command are: | ||
| + | |||
| + | < | ||
| + | [root@centos7 ~]# dmidecode --help | ||
| + | Usage: dmidecode [OPTIONS] | ||
| + | Options are: | ||
| + | -d, --dev-mem FILE Read memory from device FILE (default: /dev/mem) | ||
| + | -h, --help | ||
| + | -q, --quiet | ||
| + | -s, --string KEYWORD | ||
| + | -t, --type TYPE Only display the entries of given type | ||
| + | -u, --dump | ||
| + | | ||
| + | | ||
| + | -V, --version | ||
| + | </ | ||
| + | |||
| + | =====LAB #2 - The sysctl Command===== | ||
| + | |||
| + | ====2.1 - The /proc Directory==== | ||
| + | |||
| + | The /proc directory contains virtual files and directories wich are created dynamically when consulted. Only root can consult all of the information in /proc. | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# ls /proc | ||
| + | 1 16391 19 2212 2427 2622 431 | ||
| + | 10 | ||
| + | 1007 | ||
| + | 11 | ||
| + | 11805 16593 2 | ||
| + | 12 | ||
| + | 1219 | ||
| + | 1228 | ||
| + | 1232 | ||
| + | 1234 | ||
| + | 1235 | ||
| + | 1247 | ||
| + | 13 | ||
| + | 1307 | ||
| + | 1339 | ||
| + | 1356 | ||
| + | 14 | ||
| + | 1441 | ||
| + | 1443 | ||
| + | 1444 | ||
| + | 1446 | ||
| + | 14977 1828 | ||
| + | 15 | ||
| + | 15067 183 2167 2330 2571 422 | ||
| + | 1536 | ||
| + | 1553 | ||
| + | 15594 186 2187 2358 259 | ||
| + | 15735 187 2190 2373 2593 427 | ||
| + | 16 | ||
| + | 16165 1883 | ||
| + | 16167 1888 | ||
| + | </ | ||
| + | |||
| + | ===Files=== | ||
| + | |||
| + | ==/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cat / | ||
| + | processor | ||
| + | vendor_id | ||
| + | cpu family | ||
| + | model : 6 | ||
| + | model name : Common KVM processor | ||
| + | stepping | ||
| + | microcode | ||
| + | cpu MHz : 1999.987 | ||
| + | cache size : 16384 KB | ||
| + | physical id : 0 | ||
| + | siblings | ||
| + | core id : 0 | ||
| + | cpu cores : 4 | ||
| + | apicid | ||
| + | initial apicid | ||
| + | fpu : yes | ||
| + | fpu_exception | ||
| + | cpuid level : 13 | ||
| + | wp : yes | ||
| + | flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc nopl xtopology cpuid tsc_known_freq pni cx16 x2apic hypervisor lahf_lm cpuid_fault pti | ||
| + | bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit | ||
| + | bogomips | ||
| + | clflush size : 64 | ||
| + | cache_alignment : 128 | ||
| + | address sizes : 40 bits physical, 48 bits virtual | ||
| + | power management: | ||
| + | |||
| + | processor | ||
| + | vendor_id | ||
| + | cpu family | ||
| + | model : 6 | ||
| + | model name : Common KVM processor | ||
| + | stepping | ||
| + | microcode | ||
| + | cpu MHz : 1999.987 | ||
| + | cache size : 16384 KB | ||
| + | physical id : 0 | ||
| + | siblings | ||
| + | core id : 1 | ||
| + | cpu cores : 4 | ||
| + | apicid | ||
| + | initial apicid | ||
| + | fpu : yes | ||
| + | fpu_exception | ||
| + | cpuid level : 13 | ||
| + | wp : yes | ||
| + | flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc nopl xtopology cpuid tsc_known_freq pni cx16 x2apic hypervisor lahf_lm cpuid_fault pti | ||
| + | bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit | ||
| + | bogomips | ||
| + | clflush size : 64 | ||
| + | cache_alignment : 128 | ||
| + | address sizes : 40 bits physical, 48 bits virtual | ||
| + | power management: | ||
| + | |||
| + | processor | ||
| + | vendor_id | ||
| + | cpu family | ||
| + | model : 6 | ||
| + | model name : Common KVM processor | ||
| + | stepping | ||
| + | microcode | ||
| + | cpu MHz : 1999.987 | ||
| + | cache size : 16384 KB | ||
| + | physical id : 0 | ||
| + | siblings | ||
| + | core id : 2 | ||
| + | cpu cores : 4 | ||
| + | apicid | ||
| + | initial apicid | ||
| + | fpu : yes | ||
| + | fpu_exception | ||
| + | cpuid level : 13 | ||
| + | wp : yes | ||
| + | flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc nopl xtopology cpuid tsc_known_freq pni cx16 x2apic hypervisor lahf_lm cpuid_fault pti | ||
| + | bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit | ||
| + | bogomips | ||
| + | clflush size : 64 | ||
| + | cache_alignment : 128 | ||
| + | address sizes : 40 bits physical, 48 bits virtual | ||
| + | power management: | ||
| + | |||
| + | processor | ||
| + | vendor_id | ||
| + | cpu family | ||
| + | model : 6 | ||
| + | model name : Common KVM processor | ||
| + | stepping | ||
| + | microcode | ||
| + | cpu MHz : 1999.987 | ||
| + | cache size : 16384 KB | ||
| + | physical id : 0 | ||
| + | siblings | ||
| + | core id : 3 | ||
| + | cpu cores : 4 | ||
| + | apicid | ||
| + | initial apicid | ||
| + | fpu : yes | ||
| + | fpu_exception | ||
| + | cpuid level : 13 | ||
| + | wp : yes | ||
| + | flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc nopl xtopology cpuid tsc_known_freq pni cx16 x2apic hypervisor lahf_lm cpuid_fault pti | ||
| + | bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit | ||
| + | bogomips | ||
| + | clflush size : 64 | ||
| + | cache_alignment : 128 | ||
| + | address sizes : 40 bits physical, 48 bits virtual | ||
| + | power management: | ||
| + | |||
| + | processor | ||
| + | vendor_id | ||
| + | cpu family | ||
| + | model : 6 | ||
| + | model name : Common KVM processor | ||
| + | stepping | ||
| + | microcode | ||
| + | cpu MHz : 1999.987 | ||
| + | cache size : 16384 KB | ||
| + | physical id : 1 | ||
| + | siblings | ||
| + | core id : 0 | ||
| + | cpu cores : 4 | ||
| + | apicid | ||
| + | initial apicid | ||
| + | fpu : yes | ||
| + | fpu_exception | ||
| + | cpuid level : 13 | ||
| + | wp : yes | ||
| + | flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc nopl xtopology cpuid tsc_known_freq pni cx16 x2apic hypervisor lahf_lm cpuid_fault pti | ||
| + | bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit | ||
| + | bogomips | ||
| + | clflush size : 64 | ||
| + | cache_alignment : 128 | ||
| + | address sizes : 40 bits physical, 48 bits virtual | ||
| + | power management: | ||
| + | |||
| + | processor | ||
| + | vendor_id | ||
| + | cpu family | ||
| + | model : 6 | ||
| + | model name : Common KVM processor | ||
| + | stepping | ||
| + | microcode | ||
| + | cpu MHz : 1999.987 | ||
| + | cache size : 16384 KB | ||
| + | physical id : 1 | ||
| + | siblings | ||
| + | core id : 1 | ||
| + | cpu cores : 4 | ||
| + | apicid | ||
| + | initial apicid | ||
| + | fpu : yes | ||
| + | fpu_exception | ||
| + | cpuid level : 13 | ||
| + | wp : yes | ||
| + | flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc nopl xtopology cpuid tsc_known_freq pni cx16 x2apic hypervisor lahf_lm cpuid_fault pti | ||
| + | bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit | ||
| + | bogomips | ||
| + | clflush size : 64 | ||
| + | cache_alignment : 128 | ||
| + | address sizes : 40 bits physical, 48 bits virtual | ||
| + | power management: | ||
| + | |||
| + | processor | ||
| + | vendor_id | ||
| + | cpu family | ||
| + | model : 6 | ||
| + | model name : Common KVM processor | ||
| + | stepping | ||
| + | microcode | ||
| + | cpu MHz : 1999.987 | ||
| + | cache size : 16384 KB | ||
| + | physical id : 1 | ||
| + | siblings | ||
| + | core id : 2 | ||
| + | cpu cores : 4 | ||
| + | apicid | ||
| + | initial apicid | ||
| + | fpu : yes | ||
| + | fpu_exception | ||
| + | cpuid level : 13 | ||
| + | wp : yes | ||
| + | flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc nopl xtopology cpuid tsc_known_freq pni cx16 x2apic hypervisor lahf_lm cpuid_fault pti | ||
| + | bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit | ||
| + | bogomips | ||
| + | clflush size : 64 | ||
| + | cache_alignment : 128 | ||
| + | address sizes : 40 bits physical, 48 bits virtual | ||
| + | power management: | ||
| + | |||
| + | processor | ||
| + | vendor_id | ||
| + | cpu family | ||
| + | model : 6 | ||
| + | model name : Common KVM processor | ||
| + | stepping | ||
| + | microcode | ||
| + | cpu MHz : 1999.987 | ||
| + | cache size : 16384 KB | ||
| + | physical id : 1 | ||
| + | siblings | ||
| + | core id : 3 | ||
| + | cpu cores : 4 | ||
| + | apicid | ||
| + | initial apicid | ||
| + | fpu : yes | ||
| + | fpu_exception | ||
| + | cpuid level : 13 | ||
| + | wp : yes | ||
| + | flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc nopl xtopology cpuid tsc_known_freq pni cx16 x2apic hypervisor lahf_lm cpuid_fault pti | ||
| + | bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit | ||
| + | bogomips | ||
| + | clflush size : 64 | ||
| + | cache_alignment : 128 | ||
| + | address sizes : 40 bits physical, 48 bits virtual | ||
| + | power management: | ||
| + | </ | ||
| + | |||
| + | ==/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cat / | ||
| + | | ||
| + | 0: 109 0 0 0 0 0 0 0 | ||
| + | 1: 0 0 0 0 9 0 0 0 | ||
| + | 8: 0 0 0 0 0 1 0 0 | ||
| + | 9: 0 0 0 0 0 0 0 0 | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | NMI: 0 0 0 0 0 0 0 0 | ||
| + | LOC: | ||
| + | SPU: 0 0 0 0 0 0 0 0 | ||
| + | PMI: 0 0 0 0 0 0 0 0 | ||
| + | IWI: 0 0 0 0 2 0 0 0 IRQ work interrupts | ||
| + | RTR: 0 0 0 0 0 0 0 0 APIC ICR read retries | ||
| + | RES: | ||
| + | CAL: 11095 11007 10841 10343 14679 | ||
| + | TLB: | ||
| + | TRM: 0 0 0 0 0 0 0 0 | ||
| + | THR: 0 0 0 0 0 0 0 0 | ||
| + | DFR: 0 0 0 0 0 0 0 0 | ||
| + | MCE: 0 0 0 0 0 0 0 0 | ||
| + | MCP: 288 288 288 288 288 288 288 288 | ||
| + | HYP: 0 0 0 0 0 0 0 0 | ||
| + | HRE: 0 0 0 0 0 0 0 0 | ||
| + | HVS: 0 0 0 0 0 0 0 0 | ||
| + | ERR: 0 | ||
| + | MIS: 0 | ||
| + | PIN: 0 0 0 0 0 0 0 0 | ||
| + | NPI: 0 0 0 0 0 0 0 0 | ||
| + | PIW: 0 0 0 0 0 0 0 0 | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | **Important** : The use of an IRQ by a peripheral is exclusive. | ||
| + | </ | ||
| + | |||
| + | ==/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cat /proc/dma | ||
| + | 4: cascade | ||
| + | </ | ||
| + | |||
| + | ==/ | ||
| + | |||
| + | < | ||
| + | root@centos8 ~]# cat / | ||
| + | 0000-0cf7 : PCI Bus 0000:00 | ||
| + | 0000-001f : dma1 | ||
| + | 0020-0021 : pic1 | ||
| + | 0040-0043 : timer0 | ||
| + | 0050-0053 : timer1 | ||
| + | 0060-0060 : keyboard | ||
| + | 0064-0064 : keyboard | ||
| + | 0070-0077 : rtc0 | ||
| + | 0080-008f : dma page reg | ||
| + | 00a0-00a1 : pic2 | ||
| + | 00c0-00df : dma2 | ||
| + | 00f0-00ff : fpu | ||
| + | 0170-0177 : 0000: | ||
| + | 0170-0177 : ata_piix | ||
| + | 01f0-01f7 : 0000: | ||
| + | 01f0-01f7 : ata_piix | ||
| + | 0376-0376 : 0000: | ||
| + | 0376-0376 : ata_piix | ||
| + | 03c0-03df : vga+ | ||
| + | 03f6-03f6 : 0000: | ||
| + | 03f6-03f6 : ata_piix | ||
| + | --More-- | ||
| + | </ | ||
| + | |||
| + | <WRAP center round alert 60%> | ||
| + | **Important** - If two peripherals use the same IO Port, both become unusable. | ||
| + | </ | ||
| + | |||
| + | ==/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cat / | ||
| + | Character devices: | ||
| + | 1 mem | ||
| + | 4 /dev/vc/0 | ||
| + | 4 tty | ||
| + | 4 ttyS | ||
| + | 5 /dev/tty | ||
| + | 5 / | ||
| + | 5 /dev/ptmx | ||
| + | 7 vcs | ||
| + | 10 misc | ||
| + | 13 input | ||
| + | 21 sg | ||
| + | 29 fb | ||
| + | 128 ptm | ||
| + | 136 pts | ||
| + | 162 raw | ||
| + | 180 usb | ||
| + | 188 ttyUSB | ||
| + | 189 usb_device | ||
| + | 202 cpu/msr | ||
| + | 203 cpu/cpuid | ||
| + | 226 drm | ||
| + | 244 aux | ||
| + | 245 hidraw | ||
| + | 246 usbmon | ||
| + | 247 bsg | ||
| + | 248 watchdog | ||
| + | 249 ptp | ||
| + | 250 pps | ||
| + | 251 rtc | ||
| + | 252 dax | ||
| + | 253 tpm | ||
| + | 254 gpiochip | ||
| + | |||
| + | Block devices: | ||
| + | 8 sd | ||
| + | 9 md | ||
| + | 11 sr | ||
| + | 65 sd | ||
| + | 66 sd | ||
| + | 67 sd | ||
| + | 68 sd | ||
| + | 69 sd | ||
| + | 70 sd | ||
| + | 71 sd | ||
| + | 128 sd | ||
| + | 129 sd | ||
| + | 130 sd | ||
| + | 131 sd | ||
| + | 132 sd | ||
| + | 133 sd | ||
| + | 134 sd | ||
| + | 135 sd | ||
| + | 253 device-mapper | ||
| + | 254 mdp | ||
| + | 259 blkext | ||
| + | </ | ||
| + | |||
| + | ==/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cat / | ||
| + | xt_CHECKSUM 16384 1 - Live 0xffffffffc09a8000 | ||
| + | ipt_MASQUERADE 16384 3 - Live 0xffffffffc09a3000 | ||
| + | xt_conntrack 16384 1 - Live 0xffffffffc099e000 | ||
| + | ipt_REJECT 16384 2 - Live 0xffffffffc0999000 | ||
| + | nft_compat 20480 16 - Live 0xffffffffc0993000 | ||
| + | nf_nat_tftp 16384 0 - Live 0xffffffffc098b000 | ||
| + | nft_objref 16384 1 - Live 0xffffffffc0986000 | ||
| + | nf_conntrack_tftp 16384 3 nf_nat_tftp, | ||
| + | nft_counter 16384 33 - Live 0xffffffffc097c000 | ||
| + | tun 53248 1 - Live 0xffffffffc096e000 | ||
| + | bridge 192512 0 - Live 0xffffffffc093e000 | ||
| + | stp 16384 1 bridge, Live 0xffffffffc0939000 | ||
| + | llc 16384 2 bridge,stp, Live 0xffffffffc0930000 | ||
| + | nft_fib_inet 16384 1 - Live 0xffffffffc08f5000 | ||
| + | nft_fib_ipv4 16384 1 nft_fib_inet, | ||
| + | nft_fib_ipv6 16384 1 nft_fib_inet, | ||
| + | nft_fib 16384 3 nft_fib_inet, | ||
| + | nft_reject_inet 16384 5 - Live 0xffffffffc08de000 | ||
| + | nf_reject_ipv4 16384 2 ipt_REJECT, | ||
| + | nf_reject_ipv6 16384 1 nft_reject_inet, | ||
| + | nft_reject 16384 1 nft_reject_inet, | ||
| + | --More-- | ||
| + | </ | ||
| + | |||
| + | ==/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cat / | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | 11 0 sr0 10 0 4 2 0 0 0 0 0 9 2 0 0 0 0 | ||
| + | | ||
| + | | ||
| + | </ | ||
| + | |||
| + | ==/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cat / | ||
| + | major minor # | ||
| + | |||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | 11 0 1048575 sr0 | ||
| + | | ||
| + | | ||
| + | </ | ||
| + | |||
| + | ==/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cat /proc/swaps | ||
| + | Filename | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | ==/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cat / | ||
| + | 0.00 0.00 0.00 1/697 16936 | ||
| + | </ | ||
| + | |||
| + | ==/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cat / | ||
| + | MemTotal: | ||
| + | MemFree: | ||
| + | MemAvailable: | ||
| + | Buffers: | ||
| + | Cached: | ||
| + | SwapCached: | ||
| + | Active: | ||
| + | Inactive: | ||
| + | Active(anon): | ||
| + | Inactive(anon): | ||
| + | Active(file): | ||
| + | Inactive(file): | ||
| + | Unevictable: | ||
| + | Mlocked: | ||
| + | SwapTotal: | ||
| + | SwapFree: | ||
| + | Dirty: | ||
| + | Writeback: | ||
| + | AnonPages: | ||
| + | Mapped: | ||
| + | Shmem: | ||
| + | KReclaimable: | ||
| + | Slab: | ||
| + | SReclaimable: | ||
| + | SUnreclaim: | ||
| + | KernelStack: | ||
| + | PageTables: | ||
| + | NFS_Unstable: | ||
| + | Bounce: | ||
| + | WritebackTmp: | ||
| + | CommitLimit: | ||
| + | Committed_AS: | ||
| + | VmallocTotal: | ||
| + | VmallocUsed: | ||
| + | VmallocChunk: | ||
| + | Percpu: | ||
| + | HardwareCorrupted: | ||
| + | AnonHugePages: | ||
| + | ShmemHugePages: | ||
| + | ShmemPmdMapped: | ||
| + | FileHugePages: | ||
| + | FilePmdMapped: | ||
| + | HugePages_Total: | ||
| + | HugePages_Free: | ||
| + | HugePages_Rsvd: | ||
| + | HugePages_Surp: | ||
| + | Hugepagesize: | ||
| + | Hugetlb: | ||
| + | DirectMap4k: | ||
| + | DirectMap2M: | ||
| + | </ | ||
| + | |||
| + | ==/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cat / | ||
| + | Linux version 4.18.0-305.3.1.el8.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 8.4.1 20200928 (Red Hat 8.4.1-1) (GCC)) #1 SMP Tue Jun 1 16:14:33 UTC 2021 | ||
| + | </ | ||
| + | |||
| + | ===Répertoires=== | ||
| + | |||
| + | ==ide/ | ||
| + | |||
| + | This sub-directory contains disk capacity, disk type and disk geometry information. | ||
| + | |||
| + | ==acpi== | ||
| + | |||
| + | This sub-directory contains information on energy management, temperatures, | ||
| + | |||
| + | ==bus== | ||
| + | |||
| + | This sub-directory contains a sub-directory for each bus. | ||
| + | |||
| + | ==net== | ||
| + | |||
| + | This sub-directory contains information concerning the network. | ||
| + | |||
| + | ==sys== | ||
| + | |||
| + | This sub-directory contains files used by root to configure the kernel. For instance, the following command configiresthe kernel to ignore incoming pings: | ||
| + | |||
| + | # echo 1 > / | ||
| + | |||
| + | ====2.2 - Using the sysctl Command==== | ||
| + | |||
| + | Files in the **/ | ||
| + | |||
| + | The **sysctl** command applies rules at system boot that are defined in the **/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cat / | ||
| + | # sysctl settings are defined through files in | ||
| + | # / | ||
| + | # | ||
| + | # Vendors settings live in / | ||
| + | # To override a whole file, create a new file with the same in | ||
| + | # / | ||
| + | # only specific settings, add a file with a lexically later | ||
| + | # name in / | ||
| + | # | ||
| + | # For more information, | ||
| + | |||
| + | [root@centos8 ~]# ls -l / | ||
| + | total 0 | ||
| + | lrwxrwxrwx. 1 root root 14 Mar 16 15:42 99-sysctl.conf -> ../ | ||
| + | [root@centos8 ~]# ls -l / | ||
| + | total 24 | ||
| + | -rw-r--r--. 1 root root 1810 Dec 22 2020 10-default-yama-scope.conf | ||
| + | -rw-r--r--. 1 root root 524 Mar 16 15:42 50-coredump.conf | ||
| + | -rw-r--r--. 1 root root 1270 Mar 16 15:42 50-default.conf | ||
| + | -rw-r--r--. 1 root root 246 Jun 15 2020 50-libkcapi-optmem_max.conf | ||
| + | -rw-r--r--. 1 root root 636 Mar 16 15:42 50-pid-max.conf | ||
| + | -rw-r--r--. 1 root root 499 Nov 26 2019 60-libvirtd.conf | ||
| + | |||
| + | [root@centos8 ~]# cat / | ||
| + | # This file is part of systemd. | ||
| + | # | ||
| + | # systemd is free software; you can redistribute it and/or modify it | ||
| + | # under the terms of the GNU Lesser General Public License as published by | ||
| + | # the Free Software Foundation; either version 2.1 of the License, or | ||
| + | # (at your option) any later version. | ||
| + | |||
| + | # See sysctl.d(5) and core(5) for documentation. | ||
| + | |||
| + | # To override settings in this file, create a local file in /etc | ||
| + | # (e.g. / | ||
| + | # there. | ||
| + | |||
| + | # System Request functionality of the kernel (SYNC) | ||
| + | # | ||
| + | # Use kernel.sysrq = 1 to allow all keys. | ||
| + | # See https:// | ||
| + | # of values and keys. | ||
| + | kernel.sysrq = 16 | ||
| + | |||
| + | # Append the PID to the core filename | ||
| + | kernel.core_uses_pid = 1 | ||
| + | |||
| + | # https:// | ||
| + | kernel.kptr_restrict = 1 | ||
| + | |||
| + | # Source route verification | ||
| + | net.ipv4.conf.all.rp_filter = 1 | ||
| + | |||
| + | # Do not accept source routing | ||
| + | net.ipv4.conf.all.accept_source_route = 0 | ||
| + | |||
| + | # Promote secondary addresses when the primary address is removed | ||
| + | net.ipv4.conf.all.promote_secondaries = 1 | ||
| + | |||
| + | # Fair Queue CoDel packet scheduler to fight bufferbloat | ||
| + | net.core.default_qdisc = fq_codel | ||
| + | |||
| + | # Enable hard and soft link protection | ||
| + | fs.protected_hardlinks = 1 | ||
| + | fs.protected_symlinks = 1 | ||
| + | </ | ||
| + | |||
| + | The command line switches of this command are: | ||
| + | |||
| + | < | ||
| + | Usage: | ||
| + | | ||
| + | |||
| + | Options: | ||
| + | -a, --all display all variables | ||
| + | -A alias of -a | ||
| + | -X alias of -a | ||
| + | --deprecated | ||
| + | -b, --binary | ||
| + | -e, --ignore | ||
| + | -N, --names | ||
| + | -n, --values | ||
| + | -p, --load[=< | ||
| + | -f alias of -p | ||
| + | --system | ||
| + | -r, --pattern < | ||
| + | | ||
| + | -q, --quiet | ||
| + | -w, --write | ||
| + | -o does nothing | ||
| + | -x does nothing | ||
| + | -d alias of -h | ||
| + | |||
| + | -h, --help | ||
| + | -V, --version | ||
| + | |||
| + | For more details see sysctl(8). | ||
| + | </ | ||
| + | |||
| + | =====LAB#3 - Interpreting Information in /proc===== | ||
| + | |||
| + | The information found in files in the /proc filesystem can be interpreted using the following commands: | ||
| + | |||
| + | * free, | ||
| + | * uptime et w, | ||
| + | * iostat, | ||
| + | * hdparm | ||
| + | * vmstat, | ||
| + | * mpstat, | ||
| + | * sar. | ||
| + | |||
| + | ====3.1 - The free Command==== | ||
| + | |||
| + | The **free** command shows total, used, free, shared, buffered, cached and swapped memory: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# free -m | ||
| + | total used free shared | ||
| + | Mem: | ||
| + | Swap: 3279 | ||
| + | </ | ||
| + | |||
| + | In the above example, you can see: | ||
| + | |||
| + | * 3735 MB of total physical memory, | ||
| + | * 1135 MB of used physical memory and 1818 MB of free physical memory, | ||
| + | * 3279 MB of swap space with 0MB being used. | ||
| + | |||
| + | The command line switches of this command are: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# free --help | ||
| + | |||
| + | Usage: | ||
| + | free [options] | ||
| + | |||
| + | Options: | ||
| + | -b, --bytes | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | -k, --kibi | ||
| + | -m, --mebi | ||
| + | -g, --gibi | ||
| + | | ||
| + | | ||
| + | -h, --human | ||
| + | | ||
| + | -l, --lohi | ||
| + | -t, --total | ||
| + | -s N, --seconds N | ||
| + | -c N, --count N | ||
| + | -w, --wide | ||
| + | |||
| + | | ||
| + | -V, --version | ||
| + | |||
| + | For more details see free(1). | ||
| + | </ | ||
| + | |||
| + | ====3.2 - The uptime and w Commands==== | ||
| + | |||
| + | Each of these commands show the load average over the past 1, 5 and 15 minutes: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# uptime | ||
| + | | ||
| + | |||
| + | [root@centos8 ~]# w | ||
| + | | ||
| + | USER | ||
| + | trainee | ||
| + | </ | ||
| + | |||
| + | The **load average** indicates the number of processes being executed and waiting to be executed for the period concerned. | ||
| + | |||
| + | If the load average of a single-core system was **3.48 | ||
| + | |||
| + | * 2.48 processes would have been waiting to be executed over the last minute, | ||
| + | * 3.00 processes would have been waiting to be executed over the last 5 minutes, | ||
| + | * 2.85 processes would have been waiting to be executed over the last 15 minutes, | ||
| + | |||
| + | The command line switches of these commands are: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# uptime --help | ||
| + | |||
| + | Usage: | ||
| + | | ||
| + | |||
| + | Options: | ||
| + | -p, --pretty | ||
| + | -h, --help | ||
| + | -s, --since | ||
| + | -V, --version | ||
| + | |||
| + | For more details see uptime(1). | ||
| + | |||
| + | [root@centos8 ~]# w --help | ||
| + | |||
| + | Usage: | ||
| + | w [options] | ||
| + | |||
| + | Options: | ||
| + | -h, --no-header | ||
| + | -u, --no-current | ||
| + | -s, --short | ||
| + | -f, --from | ||
| + | -o, --old-style | ||
| + | -i, --ip-addr | ||
| + | |||
| + | | ||
| + | -V, --version | ||
| + | |||
| + | For more details see w(1). | ||
| + | </ | ||
| + | |||
| + | ====3.3 - The iostat Command==== | ||
| + | |||
| + | The **iostat** command show disk, terminal and streamer statistics: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# iostat | ||
| + | bash: iostat: command not found... | ||
| + | Install package ' | ||
| + | |||
| + | |||
| + | * Waiting in queue... | ||
| + | The following packages have to be installed: | ||
| + | | ||
| + | | ||
| + | Proceed with changes? [N/y] y | ||
| + | |||
| + | |||
| + | * Waiting in queue... | ||
| + | * Waiting for authentication... | ||
| + | * Waiting in queue... | ||
| + | * Downloading packages... | ||
| + | * Requesting data... | ||
| + | * Testing changes... | ||
| + | * Installing packages... | ||
| + | Linux 4.18.0-305.3.1.el8.x86_64 (centos8.ittraining.loc) | ||
| + | |||
| + | avg-cpu: | ||
| + | | ||
| + | |||
| + | Device | ||
| + | sda | ||
| + | sdb | ||
| + | scd0 0.00 | ||
| + | dm-0 0.26 | ||
| + | dm-1 0.00 | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# iostat -d -x | ||
| + | Linux 4.18.0-305.3.1.el8.x86_64 (centos8.ittraining.loc) | ||
| + | |||
| + | Device | ||
| + | sda 0.20 0.16 | ||
| + | sdb 0.00 0.00 0.02 0.00 | ||
| + | scd0 | ||
| + | dm-0 | ||
| + | dm-1 | ||
| + | </ | ||
| + | |||
| + | The command line switches of this command are: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# iostat --help | ||
| + | Usage: iostat [ options ] [ < | ||
| + | Options are: | ||
| + | [ -c ] [ -d ] [ -h ] [ -k | -m ] [ -N ] [ -s ] [ -t ] [ -V ] [ -x ] [ -y ] [ -z ] | ||
| + | [ -j { ID | LABEL | PATH | UUID | ... } ] [ --human ] [ -o JSON ] | ||
| + | [ [ -H ] -g < | ||
| + | [ < | ||
| + | </ | ||
| + | |||
| + | ====3.4 - The hdparm Command==== | ||
| + | |||
| + | The hdparm command measures disk reads: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# hdparm -t /dev/sda | ||
| + | |||
| + | /dev/sda: | ||
| + | | ||
| + | </ | ||
| + | |||
| + | ====3.5 - La Commande vmstat==== | ||
| + | |||
| + | The **vmstat** commands shows memory, pagination and processor statistics: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# vmstat 1 10 | ||
| + | procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | </ | ||
| + | |||
| + | The command line switches of this command are: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# vmstat --help | ||
| + | |||
| + | Usage: | ||
| + | | ||
| + | |||
| + | Options: | ||
| + | -a, --active | ||
| + | -f, --forks | ||
| + | -m, --slabs | ||
| + | -n, --one-header | ||
| + | -s, --stats | ||
| + | -d, --disk | ||
| + | -D, --disk-sum | ||
| + | -p, --partition < | ||
| + | -S, --unit < | ||
| + | -w, --wide | ||
| + | -t, --timestamp | ||
| + | |||
| + | -h, --help | ||
| + | -V, --version | ||
| + | |||
| + | For more details see vmstat(8). | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | **Important** : By default vmstat shows statistics from boot until current time. | ||
| + | </ | ||
| + | |||
| + | ====3.6 - The mpstat Command==== | ||
| + | |||
| + | La commande **mpstat** affiche des statistiques détaillées sur le CPU : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# mpstat | ||
| + | Linux 4.18.0-305.3.1.el8.x86_64 (centos8.ittraining.loc) | ||
| + | |||
| + | 04: | ||
| + | 04: | ||
| + | </ | ||
| + | |||
| + | If there are several CPU's in the system, statistics can be viewed by core and as an average: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# mpstat -P ALL | ||
| + | Linux 4.18.0-305.3.1.el8.x86_64 (centos8.ittraining.loc) | ||
| + | |||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | </ | ||
| + | |||
| + | Finally, mpstat is capable of showing statistics over time. In the following example you can see 5 data sets, one taken every 2 seconds: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# mpstat -P ALL 2 5 | ||
| + | Linux 4.18.0-305.3.1.el8.x86_64 (centos8.ittraining.loc) | ||
| + | |||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | |||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | |||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | |||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | |||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | 04: | ||
| + | |||
| + | Average: | ||
| + | Average: | ||
| + | Average: | ||
| + | Average: | ||
| + | Average: | ||
| + | Average: | ||
| + | Average: | ||
| + | Average: | ||
| + | Average: | ||
| + | Average: | ||
| + | </ | ||
| + | |||
| + | The command line switches of this command are: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# mpstat --help | ||
| + | Usage: mpstat [ options ] [ < | ||
| + | Options are: | ||
| + | [ -A ] [ -n ] [ -u ] [ -V ] [ -I { SUM | CPU | SCPU | ALL } ] | ||
| + | [ -N { < | ||
| + | </ | ||
| + | |||
| + | ====3.7 - The sar Command==== | ||
| + | |||
| + | The **sar** command can survey all system resources dependant upon the switch that is used. Several important switches are: | ||
| + | |||
| + | ^ Switch ^ Description ^ | ||
| + | | -u | CPU usage in % | | ||
| + | | -q | Number of processes in the process queue | | ||
| + | | -r | Memory usage | | ||
| + | | -w | Swap usage | | ||
| + | | -p | Pagination usage | | ||
| + | | -b | Buffer usage | | ||
| + | | -d | Disk usage | | ||
| + | |||
| + | The **/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# ls / | ||
| + | sa1 sa2 sadc | ||
| + | </ | ||
| + | |||
| + | The **/ | ||
| + | |||
| + | ^ Switch ^ Description ^ | ||
| + | | -t | Interval | | ||
| + | | -n | Count | | ||
| + | |||
| + | The **/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# ls / | ||
| + | sa29 s | ||
| + | |||
| + | |||
| + | ar29 | ||
| + | </ | ||
| + | |||
| + | Using CentOS / RHEL 8, the interval between collects is configured using systemd **timers** de systemd and not cron as was previously the case: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cat / | ||
| + | # / | ||
| + | # (C) 2014 Tomasz Torcz < | ||
| + | # | ||
| + | # sysstat-11.7.3 systemd unit file: | ||
| + | # Activates activity collector every 10 minutes | ||
| + | |||
| + | [Unit] | ||
| + | Description=Run system activity accounting tool every 10 minutes | ||
| + | |||
| + | [Timer] | ||
| + | OnCalendar=*: | ||
| + | |||
| + | [Install] | ||
| + | WantedBy=sysstat.service | ||
| + | </ | ||
| + | |||
| + | The **OnCalendar** value indicates a collect every 10 minutes. | ||
| + | |||
| + | To change this value, you need to create an **override** file in **/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# systemctl edit sysstat-collect.timer | ||
| + | [root@centos8 ~]# cat / | ||
| + | [Unit] | ||
| + | Description=Run system activity accounting tool every 2 minutes | ||
| + | |||
| + | [Timer] | ||
| + | OnCalendar= | ||
| + | OnCalendar=*: | ||
| + | AccuracySec=0 | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | **Important** : Note the line **OnCalendar=** which is required to override the default value. | ||
| + | </ | ||
| + | |||
| + | Now check if the configuration has been applied: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# systemctl status sysstat-collect.timer | ||
| + | ● sysstat-collect.timer - Run system activity accounting tool every 2 minutes | ||
| + | | ||
| + | Drop-In: / | ||
| + | | ||
| + | | ||
| + | Trigger: Tue 2021-06-29 09:20:00 EDT; 1min 19s left | ||
| + | |||
| + | Jun 29 06:16:04 centos8.ittraining.loc systemd[1]: Started Run system activity accounting tool every 10 minutes. | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# journalctl -g sysstat-collect.service | ||
| + | -- Logs begin at Mon 2021-06-28 02:04:10 EDT, end at Tue 2021-06-29 09:18:00 EDT. -- | ||
| + | Jun 29 06:20:33 centos8.ittraining.loc systemd[1]: sysstat-collect.service: | ||
| + | Jun 29 06:26:29 centos8.ittraining.loc systemd[1]: sysstat-collect.service: | ||
| + | Jun 29 06:30:33 centos8.ittraining.loc systemd[1]: sysstat-collect.service: | ||
| + | Jun 29 06:40:33 centos8.ittraining.loc systemd[1]: sysstat-collect.service: | ||
| + | Jun 29 06:50:33 centos8.ittraining.loc systemd[1]: sysstat-collect.service: | ||
| + | Jun 29 07:00:33 centos8.ittraining.loc systemd[1]: sysstat-collect.service: | ||
| + | Jun 29 07:10:33 centos8.ittraining.loc systemd[1]: sysstat-collect.service: | ||
| + | Jun 29 07:20:33 centos8.ittraining.loc systemd[1]: sysstat-collect.service: | ||
| + | Jun 29 07:30:33 centos8.ittraining.loc systemd[1]: sysstat-collect.service: | ||
| + | Jun 29 07:40:33 centos8.ittraining.loc systemd[1]: sysstat-collect.service: | ||
| + | Jun 29 07:50:33 centos8.ittraining.loc systemd[1]: sysstat-collect.service: | ||
| + | Jun 29 07:53:56 centos8.ittraining.loc systemd[1]: sysstat-collect.service: | ||
| + | Jun 29 07:54:00 centos8.ittraining.loc systemd[1]: sysstat-collect.service: | ||
| + | Jun 29 07:56:00 centos8.ittraining.loc systemd[1]: sysstat-collect.service: | ||
| + | Jun 29 07:58:00 centos8.ittraining.loc systemd[1]: sysstat-collect.service: | ||
| + | Jun 29 08:00:00 centos8.ittraining.loc systemd[1]: sysstat-collect.service: | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | Execute the sar command: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# sar | ||
| + | Linux 4.18.0-305.3.1.el8.x86_64 (centos8.ittraining.loc) | ||
| + | |||
| + | 06: | ||
| + | |||
| + | 06: | ||
| + | 06: | ||
| + | 06: | ||
| + | 06: | ||
| + | 06: | ||
| + | 07: | ||
| + | 07: | ||
| + | 07: | ||
| + | 07: | ||
| + | 07: | ||
| + | 07: | ||
| + | 07: | ||
| + | 07: | ||
| + | Average: | ||
| + | |||
| + | 07: | ||
| + | |||
| + | 07: | ||
| + | 07: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 08: | ||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | |||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | Average: | ||
| + | </ | ||
| + | |||
| + | ===CPU Stats=== | ||
| + | |||
| + | Use the -u switch: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# sar -u 5 3 | ||
| + | Linux 4.18.0-305.3.1.el8.x86_64 (centos8.ittraining.loc) | ||
| + | |||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | Average: | ||
| + | </ | ||
| + | |||
| + | More information can be shown by using the **ALL** argument: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# sar -u ALL 5 3 | ||
| + | Linux 4.18.0-305.3.1.el8.x86_64 (centos8.ittraining.loc) | ||
| + | |||
| + | 01: | ||
| + | 01: | ||
| + | 01: | ||
| + | 01: | ||
| + | Average: | ||
| + | </ | ||
| + | |||
| + | To see the statistics from a specific core, use the **-P** switch: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# sar -u -P 1 5 3 | ||
| + | Linux 4.18.0-305.3.1.el8.x86_64 (centos8.ittraining.loc) | ||
| + | |||
| + | 01: | ||
| + | 01: | ||
| + | 01: | ||
| + | 01: | ||
| + | Average: | ||
| + | [root@centos8 ~]# sar -u -P 5 5 3 | ||
| + | Linux 4.18.0-305.3.1.el8.x86_64 (centos8.ittraining.loc) | ||
| + | |||
| + | 01: | ||
| + | 01: | ||
| + | 01: | ||
| + | 01: | ||
| + | Average: | ||
| + | </ | ||
| + | |||
| + | ===Memory and Swap Statistics=== | ||
| + | |||
| + | Use the **-r** switch to see memory statistics: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# sar -r 5 3 | ||
| + | Linux 4.18.0-305.3.1.el8.x86_64 (centos8.ittraining.loc) | ||
| + | |||
| + | 07: | ||
| + | 07: | ||
| + | 07: | ||
| + | 07: | ||
| + | Average: | ||
| + | </ | ||
| + | |||
| + | Use the **-S** switch to see swap statistics: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# sar -S 5 3 | ||
| + | Linux 4.18.0-305.3.1.el8.x86_64 (centos8.ittraining.loc) | ||
| + | |||
| + | 07: | ||
| + | 07: | ||
| + | 07: | ||
| + | 07: | ||
| + | Average: | ||
| + | </ | ||
| + | |||
| + | ===I/O Statistics=== | ||
| + | |||
| + | Use the **-b** switch: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# sar -b 5 3 | ||
| + | Linux 4.18.0-305.3.1.el8.x86_64 (centos8.ittraining.loc) | ||
| + | |||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | Average: | ||
| + | </ | ||
| + | |||
| + | ===Disk I/O Statistics=== | ||
| + | |||
| + | Use the **-d** switch: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# sar -d 5 3 | ||
| + | Linux 4.18.0-305.3.1.el8.x86_64 (centos8.ittraining.loc) | ||
| + | |||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | |||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | |||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | 09: | ||
| + | |||
| + | Average: | ||
| + | Average: | ||
| + | Average: | ||
| + | Average: | ||
| + | Average: | ||
| + | Average: | ||
| + | </ | ||
| + | |||
| + | The **DEV** column identifies the disks by their major/minor numbers. To see the names of the disks add the, **-p** switch: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# sar -p -d 5 3 | ||
| + | Linux 4.18.0-305.3.1.el8.x86_64 (centos8.ittraining.loc) | ||
| + | |||
| + | 07: | ||
| + | 07: | ||
| + | 07: | ||
| + | 07: | ||
| + | 07: | ||
| + | 07: | ||
| + | |||
| + | 07: | ||
| + | 07: | ||
| + | 07: | ||
| + | 07: | ||
| + | 07: | ||
| + | 07: | ||
| + | |||
| + | 07: | ||
| + | 07: | ||
| + | 07: | ||
| + | 07: | ||
| + | 07: | ||
| + | 07: | ||
| + | |||
| + | Average: | ||
| + | Average: | ||
| + | Average: | ||
| + | Average: | ||
| + | Average: | ||
| + | Average: | ||
| + | </ | ||
| + | |||
| + | The command line switches of this command are: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# sar --help | ||
| + | Usage: sar [ options ] [ < | ||
| + | Main options and reports (report name between square brackets): | ||
| + | -B Paging statistics [A_PAGE] | ||
| + | -b I/O and transfer rate statistics [A_IO] | ||
| + | -d Block devices statistics [A_DISK] | ||
| + | -F [ MOUNT ] | ||
| + | Filesystems statistics [A_FS] | ||
| + | -H Hugepages utilization statistics [A_HUGE] | ||
| + | -I { < | ||
| + | Interrupts statistics [A_IRQ] | ||
| + | -m { < | ||
| + | Power management statistics [A_PWR_...] | ||
| + | Keywords are: | ||
| + | CPU CPU instantaneous clock frequency | ||
| + | FAN Fans speed | ||
| + | FREQ CPU average clock frequency | ||
| + | IN Voltage inputs | ||
| + | TEMP Devices temperature | ||
| + | USB USB devices plugged into the system | ||
| + | -n { < | ||
| + | Network statistics [A_NET_...] | ||
| + | Keywords are: | ||
| + | DEV | ||
| + | EDEV Network interfaces (errors) | ||
| + | NFS NFS client | ||
| + | NFSD NFS server | ||
| + | SOCK Sockets (v4) | ||
| + | IP IP traffic | ||
| + | EIP IP traffic | ||
| + | ICMP ICMP traffic | ||
| + | EICMP ICMP traffic | ||
| + | TCP TCP traffic | ||
| + | ETCP TCP traffic | ||
| + | UDP UDP traffic | ||
| + | SOCK6 | ||
| + | IP6 IP traffic | ||
| + | EIP6 IP traffic | ||
| + | ICMP6 ICMP traffic | ||
| + | EICMP6 | ||
| + | UDP6 UDP traffic | ||
| + | FC Fibre channel HBAs | ||
| + | SOFT Software-based network processing | ||
| + | -q Queue length and load average statistics [A_QUEUE] | ||
| + | -r [ ALL ] | ||
| + | Memory utilization statistics [A_MEMORY] | ||
| + | -S Swap space utilization statistics [A_MEMORY] | ||
| + | -u [ ALL ] | ||
| + | CPU utilization statistics [A_CPU] | ||
| + | -v Kernel tables statistics [A_KTABLES] | ||
| + | -W Swapping statistics [A_SWAP] | ||
| + | -w Task creation and system switching statistics [A_PCSW] | ||
| + | -y TTY devices statistics [A_SERIAL] | ||
| + | </ | ||
| + | |||
| + | =====USB Modules===== | ||
| + | |||
| + | The Universal Serial Bus can offer data transfer speeds of upto 480Mb/s for version 2.0 and upto 4.8 Gb/s for version 3.0. Under Linux the USB modules are: | ||
| + | |||
| + | ^ USB Version ^ Module ^ Name ^ | ||
| + | | 1.0\1.1 | ||
| + | | ::: | **OHCI** | //Open Controller Host Interface// | | ||
| + | | 2.0 | **EHCI** | //Enhanced Host Controller Interface// | | ||
| + | | 3.0 | **XHCI** | // | ||
| + | |||
| + | The following table shows a list of commonly used USB modules: | ||
| + | |||
| + | ^ Module ^ Peripheral ^ | ||
| + | | **usb_storage** | ||
| + | | **usbhid** | ||
| + | | **snd-usb-audio** | ||
| + | | **usbvidéo** | ||
| + | | **irda-usb** | ||
| + | | **usbnet** | ||
| + | |||
| + | These modules can be loaded by any one of the following: | ||
| + | |||
| + | * Initramfs, | ||
| + | * The init process, | ||
| + | * kmod by using the **/ | ||
| + | * udev, | ||
| + | * manually. | ||
| + | |||
| + | =====udev===== | ||
| + | |||
| + | Since the 2.6 Kernel series, Linux capable of **hotplugging**. Linux uses three componants to manage hotplugging: | ||
| + | |||
| + | * Udev, | ||
| + | * HAL, | ||
| + | * Dbus. | ||
| + | |||
| + | The roles of each componant are as follows: | ||
| + | |||
| + | * Udev dynamically creates/ | ||
| + | * HAL obtains information from udev, creates a files in XML format representing the peripheral and then informs Nautilus by using Dbus, | ||
| + | * Dbus acts as a system bus and is used for inter-process communication. | ||
| + | |||
| + | When Linux is booted, udev plays an important role: | ||
| + | |||
| + | * at boot **tmpfs** is mounted on /dev, | ||
| + | * udev copies any statically configured nodes from **/ | ||
| + | * the **udevd** daemon collects **uevents** from the kernel and looks for anappropriate rule in the **/ | ||
| + | * udev creates the nodes and any required symbolic links specified in the rule previously identified, | ||
| + | * udev stores in RAM the rules from **/ | ||
| + | * when a change occurs udev updates the the rules in the RAM. | ||
| + | |||
| + | udev uses the **sysfs** filesystem mounted on /sys which renders the peripherals visible to udev in user space. For example when a USB stick is inserted, udev creates **/ | ||
| + | |||
| + | The main configuration file for udev is **/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cat / | ||
| + | # see udev.conf(5) for details | ||
| + | # | ||
| + | # udevd is also started in the initrd. | ||
| + | # also want to rebuild the initrd, so that it will include the modified configuration. | ||
| + | |||
| + | # | ||
| + | </ | ||
| + | |||
| + | Rules files can be foud in **/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# ls / | ||
| + | 01-md-raid-creating.rules | ||
| + | 10-dm.rules | ||
| + | 11-dm-lvm.rules | ||
| + | 11-dm-mpath.rules | ||
| + | 11-dm-parts.rules | ||
| + | 13-dm-disk.rules | ||
| + | 39-usbmuxd.rules | ||
| + | 40-elevator.rules | ||
| + | 40-libgphoto2.rules | ||
| + | 40-redhat.rules | ||
| + | 40-usb-blacklist.rules | ||
| + | 40-usb_modeswitch.rules | ||
| + | 50-udev-default.rules | ||
| + | 60-alias-kmsg.rules | ||
| + | 60-block.rules | ||
| + | 60-cdrom_id.rules | ||
| + | 60-drm.rules | ||
| + | 60-evdev.rules | ||
| + | 60-fido-id.rules | ||
| + | 60-input-id.rules | ||
| + | 60-libfprint-2-autosuspend.rules | ||
| + | 60-net.rules | ||
| + | 60-persistent-alsa.rules | ||
| + | 60-persistent-input.rules | ||
| + | 60-persistent-storage.rules | ||
| + | 60-persistent-storage-tape.rules | ||
| + | 60-persistent-v4l.rules | ||
| + | 60-raw.rules | ||
| + | 60-rdma-ndd.rules | ||
| + | 60-rdma-persistent-naming.rules | ||
| + | 60-sensor.rules | ||
| + | 60-serial.rules | ||
| + | 60-tpm-udev.rules | ||
| + | 61-gdm.rules | ||
| + | 61-gnome-bluetooth-rfkill.rules | ||
| + | 61-gnome-settings-daemon-rfkill.rules | ||
| + | 61-scsi-sg3_id.rules | ||
| + | 62-multipath.rules | ||
| + | 63-fc-wwpn-id.rules | ||
| + | 63-md-raid-arrays.rules | ||
| + | 63-scsi-sg3_symlink.rules | ||
| + | 64-btrfs.rules | ||
| + | 64-md-raid-assembly.rules | ||
| + | 65-libwacom.rules | ||
| + | 65-md-incremental.rules | ||
| + | 65-sane-backends.rules | ||
| + | 66-kpartx.rules | ||
| + | 68-del-part-nodes.rules | ||
| + | 69-btattach-bcm.rules | ||
| + | 69-cd-sensors.rules | ||
| + | 69-dm-lvm-metad.rules | ||
| + | 69-libmtp.rules | ||
| + | 69-md-clustered-confirm-device.rules | ||
| + | 70-hypervfcopy.rules | ||
| + | 70-hypervkvp.rules | ||
| + | 70-hypervvss.rules | ||
| + | 70-joystick.rules | ||
| + | 70-mouse.rules | ||
| + | 70-nvmf-autoconnect.rules | ||
| + | 70-power-switch.rules | ||
| + | 70-printers.rules | ||
| + | 70-spice-vdagentd.rules | ||
| + | 70-touchpad.rules | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | **Important** : You can create your own rules by putting them in the **99-local.rules** file. | ||
| + | </ | ||
| + | |||
| + | The default udev rule file is **50-udev-default.rules**: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cat / | ||
| + | # do not edit this file, it will be overwritten on update | ||
| + | |||
| + | # run a command on remove events | ||
| + | ACTION==" | ||
| + | ACTION==" | ||
| + | |||
| + | SUBSYSTEM==" | ||
| + | |||
| + | # select " | ||
| + | SUBSYSTEM==" | ||
| + | SUBSYSTEM==" | ||
| + | |||
| + | SUBSYSTEM==" | ||
| + | ENV{MODALIAS}!="", | ||
| + | |||
| + | ACTION!=" | ||
| + | |||
| + | SUBSYSTEM==" | ||
| + | SUBSYSTEM==" | ||
| + | SUBSYSTEM==" | ||
| + | SUBSYSTEM==" | ||
| + | SUBSYSTEM==" | ||
| + | SUBSYSTEM==" | ||
| + | SUBSYSTEM==" | ||
| + | KERNEL==" | ||
| + | |||
| + | SUBSYSTEM==" | ||
| + | |||
| + | SUBSYSTEM==" | ||
| + | SUBSYSTEM==" | ||
| + | |||
| + | SUBSYSTEM==" | ||
| + | SUBSYSTEM==" | ||
| + | SUBSYSTEM==" | ||
| + | SUBSYSTEM==" | ||
| + | SUBSYSTEM==" | ||
| + | SUBSYSTEM==" | ||
| + | |||
| + | SUBSYSTEM==" | ||
| + | SUBSYSTEM==" | ||
| + | |||
| + | SUBSYSTEM==" | ||
| + | OPTIONS+=" | ||
| + | --More-- | ||
| + | </ | ||
| + | |||
| + | Each rule has the following format: | ||
| + | |||
| + | KEY, [KEY, ...] NAME [, SYMLINK] | ||
| + | |||
| + | The Key is a **type=value** pair which uniquely identifies a peripheral. The **type** can be one of the following: | ||
| + | |||
| + | ^ Type ^ Description ^ Examples ^ | ||
| + | | BUS | Bus type | usb, scsi, ide | | ||
| + | | KERNEL | The default name given to the peripheral by the kernel | hda, ttyUSB0, lp0 | | ||
| + | | SUBSYSTEM | The default sub-system name given by the Kernel, generally identical to the BUS value | usb, scsi | | ||
| + | | DRIVER | The name of the module used by the peripheral | usb-storage | | ||
| + | | ID | The position of the peripheral on its bus | PCI bus id, USB id | | ||
| + | | PLACE | The topological position of a USB oeripheral on its bus. | S/O | | ||
| + | | SYSFS{filename} | The name of the peripheral file in /sys. This file contains the manufacturer' | ||
| + | | PROGRAM | An eventual external program to be called in order to identify the peripheral | S/O | | ||
| + | | RESULT | Value expected from PROGRAM | S/O | | ||
| + | |||
| + | NAME and SYMLINK are used to tell udev what to do with the peripheral: | ||
| + | |||
| + | ^ Type ^ Description ^ | ||
| + | | NAME | The name of the peripheral in /dev | | ||
| + | | SYMLINK | The eventual symbolic links that point to NAME | | ||
| + | |||
| + | ====The udevadm Command==== | ||
| + | |||
| + | To obtain information from udev on a particular peripheral, you can use the **udevadm** command which has replaced the **udevinfo** command available in Red Hat/CentOS 5: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# udevadm info --query=all -n /dev/sda | ||
| + | P: / | ||
| + | N: sda | ||
| + | S: disk/ | ||
| + | S: disk/ | ||
| + | S: disk/ | ||
| + | S: disk/ | ||
| + | S: disk/ | ||
| + | E: DEVLINKS=/ | ||
| + | E: DEVNAME=/ | ||
| + | E: DEVPATH=/ | ||
| + | E: DEVTYPE=disk | ||
| + | E: ID_ATA=1 | ||
| + | E: ID_ATA_FEATURE_SET_SMART=1 | ||
| + | E: ID_ATA_FEATURE_SET_SMART_ENABLED=1 | ||
| + | E: ID_ATA_SATA=1 | ||
| + | E: ID_ATA_WRITE_CACHE=1 | ||
| + | E: ID_ATA_WRITE_CACHE_ENABLED=1 | ||
| + | E: ID_BUS=ata | ||
| + | E: ID_MODEL=QEMU_HARDDISK | ||
| + | E: ID_MODEL_ENC=QEMU\x20HARDDISK\x20\x20\x20 | ||
| + | E: ID_PART_TABLE_TYPE=dos | ||
| + | E: ID_PART_TABLE_UUID=b39ec5c8 | ||
| + | E: ID_PATH=pci-0000: | ||
| + | E: ID_PATH_TAG=pci-0000_00_07_0-ata-1 | ||
| + | E: ID_REVISION=2.5+ | ||
| + | E: ID_SCSI=1 | ||
| + | E: ID_SCSI_INQUIRY=1 | ||
| + | E: ID_SERIAL=QEMU_HARDDISK_QM00005 | ||
| + | E: ID_SERIAL_SHORT=QM00005 | ||
| + | E: ID_TYPE=disk | ||
| + | E: ID_VENDOR=ATA | ||
| + | E: ID_VENDOR_ENC=ATA\x20\x20\x20\x20\x20 | ||
| + | E: MAJOR=8 | ||
| + | E: MINOR=0 | ||
| + | E: SCSI_IDENT_LUN_ATA=QEMU_HARDDISK_QM00005 | ||
| + | E: SCSI_IDENT_LUN_T10=ATA_QEMU_HARDDISK_QM00005 | ||
| + | E: SCSI_IDENT_LUN_VENDOR=QM00005 | ||
| + | E: SCSI_IDENT_SERIAL=QM00005 | ||
| + | E: SCSI_MODEL=QEMU_HARDDISK | ||
| + | E: SCSI_MODEL_ENC=QEMU\x20HARDDISK\x20\x20\x20 | ||
| + | E: SCSI_REVISION=2.5+ | ||
| + | E: SCSI_TPGS=0 | ||
| + | E: SCSI_TYPE=disk | ||
| + | E: SCSI_VENDOR=ATA | ||
| + | E: SCSI_VENDOR_ENC=ATA\x20\x20\x20\x20\x20 | ||
| + | E: SUBSYSTEM=block | ||
| + | E: TAGS=: | ||
| + | E: USEC_INITIALIZED=8735808 | ||
| + | </ | ||
| + | |||
| + | The command line switches of this command are: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# udevadm --help | ||
| + | udevadm [--help] [--version] [--debug] COMMAND [COMMAND OPTIONS] | ||
| + | |||
| + | Send control commands or test the device manager. | ||
| + | |||
| + | Commands: | ||
| + | info Query sysfs or the udev database | ||
| + | trigger | ||
| + | settle | ||
| + | control | ||
| + | monitor | ||
| + | test Test an event run | ||
| + | test-builtin | ||
| + | |||
| + | [root@centos8 ~]# udevadm info --help | ||
| + | udevadm info [OPTIONS] [DEVPATH|FILE] | ||
| + | |||
| + | Query sysfs or the udev database. | ||
| + | |||
| + | -h --help | ||
| + | -V --version | ||
| + | -q --query=TYPE | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | -p --path=SYSPATH | ||
| + | -n --name=NAME | ||
| + | -r --root | ||
| + | -a --attribute-walk | ||
| + | of parent devices | ||
| + | -d --device-id-of-file=FILE Print major:minor of device containing this file | ||
| + | -x --export | ||
| + | -P --export-prefix | ||
| + | -e --export-db | ||
| + | -c --cleanup-db | ||
| + | </ | ||
| + | |||
| + | =====The /sys Filesystem===== | ||
| + | |||
| + | The virtual filesystem **/sys** was introduced with the 2.6 Kernel. Its role is to identify and describe peripherals for udev: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# ls -l /sys | ||
| + | total 0 | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. | ||
| + | drwxr-xr-x. 153 root root 0 Jul 12 08:15 module | ||
| + | drwxr-xr-x. | ||
| + | </ | ||
| + | |||
| + | Each directory contains specific information: | ||
| + | |||
| + | * **block** | ||
| + | * information concerning block devices | ||
| + | * **bus** | ||
| + | * information concerning buses | ||
| + | * **class** | ||
| + | * information concerning classes | ||
| + | * **devices** | ||
| + | * information concerning the posiion of devices on their bus | ||
| + | * **firmware** | ||
| + | * information concerning APCI | ||
| + | * **module** | ||
| + | * information concerning kernel modules | ||
| + | * **power** | ||
| + | * information concerning power management | ||
| + | * **fs** | ||
| + | * information concerning file systems | ||
| + | |||
| + | For example: | ||
| + | |||
| + | < | ||
| + | [root@centos ~]# cat / | ||
| + | 2097152 | ||
| + | </ | ||
| + | |||
| + | The figure returned is in sectors. | ||
| + | |||
| + | =====LAB #4 - Limiting Ressources===== | ||
| + | |||
| + | ====4.1 - ulimit==== | ||
| + | |||
| + | Resources available to users can be limited by using the **ulimit** command. | ||
| + | |||
| + | The **ulimit** command manages two limits: | ||
| + | |||
| + | * a //hard// hard limit by specifying the **-H** switch, | ||
| + | * a //soft// soft limit by specifying the **-S** switch. | ||
| + | |||
| + | The soft limit is the limit imposed on the user whilst the hard limit is the limit that a user can obtain once he has gone over the soft limit. | ||
| + | |||
| + | Only root can position a hard limit and only if the limit does not exceed real resource levels. | ||
| + | |||
| + | Root can define limits by editing the **/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cat / | ||
| + | # / | ||
| + | # | ||
| + | #This file sets the resource limits for the users logged in via PAM. | ||
| + | #It does not affect resource limits of the system services. | ||
| + | # | ||
| + | #Also note that configuration files in / | ||
| + | #which are read in alphabetical order, override the settings in this | ||
| + | #file in case the domain is the same or more specific. | ||
| + | #That means for example that setting a limit for wildcard domain here | ||
| + | #can be overriden with a wildcard setting in a config file in the | ||
| + | # | ||
| + | #with a user specific setting in the subdirectory. | ||
| + | # | ||
| + | #Each line describes a limit for a user in the form: | ||
| + | # | ||
| + | #< | ||
| + | # | ||
| + | #Where: | ||
| + | #< | ||
| + | # - a user name | ||
| + | # - a group name, with @group syntax | ||
| + | # - the wildcard *, for default entry | ||
| + | # - the wildcard %, can be also used with %group syntax, | ||
| + | # for maxlogin limit | ||
| + | # | ||
| + | #< | ||
| + | # - " | ||
| + | # - " | ||
| + | # | ||
| + | #< | ||
| + | # - core - limits the core file size (KB) | ||
| + | # - data - max data size (KB) | ||
| + | # - fsize - maximum filesize (KB) | ||
| + | # - memlock - max locked-in-memory address space (KB) | ||
| + | # - nofile - max number of open file descriptors | ||
| + | # - rss - max resident set size (KB) | ||
| + | # - stack - max stack size (KB) | ||
| + | # - cpu - max CPU time (MIN) | ||
| + | # - nproc - max number of processes | ||
| + | # - as - address space limit (KB) | ||
| + | # - maxlogins - max number of logins for this user | ||
| + | # - maxsyslogins - max number of logins on the system | ||
| + | # - priority - the priority to run user process with | ||
| + | # - locks - max number of file locks the user can hold | ||
| + | # - sigpending - max number of pending signals | ||
| + | # - msgqueue - max memory used by POSIX message queues (bytes) | ||
| + | # - nice - max nice priority allowed to raise to values: [-20, 19] | ||
| + | # - rtprio - max realtime priority | ||
| + | # | ||
| + | #< | ||
| + | # | ||
| + | |||
| + | #* | ||
| + | #* | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | #ftp | ||
| + | # | ||
| + | |||
| + | # End of file | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | **Important** : The limit can be a number or the word **unlimited**. | ||
| + | </ | ||
| + | |||
| + | For example if root adds the two following lines to / | ||
| + | |||
| + | < | ||
| + | ... | ||
| + | trainee | ||
| + | trainee | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | the number of open files for trainee is limited to 1024. However trainee can increase this limit to 4 096 by using the following command: | ||
| + | |||
| + | < | ||
| + | $ ulimit -n 4096 | ||
| + | </ | ||
| + | |||
| + | To see the list of the current limits use the **-a** switch: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# ulimit -a | ||
| + | core file size (blocks, -c) unlimited | ||
| + | data seg size | ||
| + | scheduling priority | ||
| + | file size | ||
| + | pending signals | ||
| + | max locked memory | ||
| + | max memory size | ||
| + | open files (-n) 1024 | ||
| + | pipe size (512 bytes, -p) 8 | ||
| + | POSIX message queues | ||
| + | real-time priority | ||
| + | stack size (kbytes, -s) 8192 | ||
| + | cpu time | ||
| + | max user processes | ||
| + | virtual memory | ||
| + | file locks (-x) unlimited | ||
| + | </ | ||
| + | |||
| + | The command line switches of this command are: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# help ulimit | ||
| + | ulimit: ulimit [-SHabcdefiklmnpqrstuvxPT] [limit] | ||
| + | Modify shell resource limits. | ||
| + | | ||
| + | Provides control over the resources available to the shell and processes | ||
| + | it creates, on systems that allow such control. | ||
| + | | ||
| + | Options: | ||
| + | -S use the `soft' resource limit | ||
| + | -H use the `hard' resource limit | ||
| + | -a all current limits are reported | ||
| + | -b the socket buffer size | ||
| + | -c the maximum size of core files created | ||
| + | -d the maximum size of a process' | ||
| + | -e the maximum scheduling priority (`nice' | ||
| + | -f the maximum size of files written by the shell and its children | ||
| + | -i the maximum number of pending signals | ||
| + | -k the maximum number of kqueues allocated for this process | ||
| + | -l the maximum size a process may lock into memory | ||
| + | -m the maximum resident set size | ||
| + | -n the maximum number of open file descriptors | ||
| + | -p the pipe buffer size | ||
| + | -q the maximum number of bytes in POSIX message queues | ||
| + | -r the maximum real-time scheduling priority | ||
| + | -s the maximum stack size | ||
| + | -t the maximum amount of cpu time in seconds | ||
| + | -u the maximum number of user processes | ||
| + | -v the size of virtual memory | ||
| + | -x the maximum number of file locks | ||
| + | -P the maximum number of pseudoterminals | ||
| + | -T the maximum number of threads | ||
| + | | ||
| + | Not all options are available on all platforms. | ||
| + | | ||
| + | If LIMIT is given, it is the new value of the specified resource; the | ||
| + | special LIMIT values `soft', | ||
| + | current soft limit, the current hard limit, and no limit, respectively. | ||
| + | Otherwise, the current value of the specified resource is printed. | ||
| + | no option is given, then -f is assumed. | ||
| + | | ||
| + | Values are in 1024-byte increments, except for -t, which is in seconds, | ||
| + | -p, which is in increments of 512 bytes, and -u, which is an unscaled | ||
| + | number of processes. | ||
| + | | ||
| + | Exit Status: | ||
| + | Returns success unless an invalid option is supplied or an error occurs. | ||
| + | </ | ||
| + | |||
| + | ====4.2 - CGroups==== | ||
| + | |||
| + | Control Groups, also called **CGroups** are another, more modern way, of limiting resources. | ||
| + | |||
| + | CGroups are organised hierarchially just like processes. However as opposed to processes, CGroups are organised into **multiples** hierarchies called **Resource Controllers** or simply **Controllers**. | ||
| + | |||
| + | To consult the cgroup hierarchies, | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# lssubsys -am | ||
| + | bash: lssubsys: command not found... | ||
| + | Install package ' | ||
| + | |||
| + | |||
| + | * Waiting in queue... | ||
| + | The following packages have to be installed: | ||
| + | | ||
| + | | ||
| + | Proceed with changes? [N/y] y | ||
| + | |||
| + | |||
| + | * Waiting in queue... | ||
| + | * Waiting for authentication... | ||
| + | * Waiting in queue... | ||
| + | * Downloading packages... | ||
| + | * Requesting data... | ||
| + | * Testing changes... | ||
| + | * Installing packages... | ||
| + | cpuset / | ||
| + | cpu,cpuacct / | ||
| + | blkio / | ||
| + | memory / | ||
| + | devices / | ||
| + | freezer / | ||
| + | net_cls, | ||
| + | perf_event / | ||
| + | hugetlb / | ||
| + | pids / | ||
| + | rdma / | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# lssubsys -am | ||
| + | cpuset / | ||
| + | cpu,cpuacct / | ||
| + | blkio / | ||
| + | memory / | ||
| + | devices / | ||
| + | freezer / | ||
| + | net_cls, | ||
| + | perf_event / | ||
| + | hugetlb / | ||
| + | pids / | ||
| + | rdma / | ||
| + | </ | ||
| + | |||
| + | **Systemd** organises the processes in each cgroup. As a result, the CGroup resource management is closely aligned to Systemd' | ||
| + | |||
| + | At the top of the hierarchy we can see the root slice -**-.slice**, | ||
| + | |||
| + | * **system.slice** - system services, | ||
| + | * **user.slice** - user sessions, | ||
| + | * **machine.slice** - virtiual machines and containers. | ||
| + | |||
| + | Under these slices can be found: | ||
| + | |||
| + | * **scopes** -processes created by a **Fork**, | ||
| + | * **services** - processes created by a **Unit**. | ||
| + | |||
| + | Slices can be consulted with the following command: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# systemctl list-units --type=slice | ||
| + | UNIT LOAD | ||
| + | -.slice | ||
| + | machine.slice | ||
| + | system-getty.slice | ||
| + | system-lvm2\x2dpvscan.slice | ||
| + | system-sshd\x2dkeygen.slice | ||
| + | system-systemd\x2dfsck.slice | ||
| + | system-systemd\x2dhibernate\x2dresume.slice loaded active active system-systemd\x2dhibernate\x2dresume.slice | ||
| + | system-user\x2druntime\x2ddir.slice | ||
| + | system-vncserver.slice | ||
| + | system.slice | ||
| + | user-1000.slice | ||
| + | user-42.slice | ||
| + | user.slice | ||
| + | |||
| + | LOAD = Reflects whether the unit definition was properly loaded. | ||
| + | ACTIVE = The high-level unit activation state, i.e. generalization of SUB. | ||
| + | SUB = The low-level unit activation state, values depend on unit type. | ||
| + | |||
| + | 13 loaded units listed. Pass --all to see loaded but inactive units, too. | ||
| + | To show all installed unit files use ' | ||
| + | </ | ||
| + | |||
| + | CGroup hierarchies can be seen by using the **systemd-cgls** command: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# systemd-cgls | ||
| + | Control group /: | ||
| + | -.slice | ||
| + | ├─user.slice | ||
| + | │ ├─user-42.slice | ||
| + | │ │ ├─session-c1.scope | ||
| + | │ │ │ ├─1317 gdm-session-worker [pam/ | ||
| + | │ │ │ ├─1459 / | ||
| + | │ │ │ ├─1856 / | ||
| + | │ │ │ ├─1882 / | ||
| + | │ │ │ ├─2059 / | ||
| + | │ │ │ ├─2132 ibus-daemon --xim --panel disable | ||
| + | │ │ │ ├─2135 / | ||
| + | │ │ │ ├─2138 / | ||
| + | │ │ │ ├─2251 / | ||
| + | │ │ │ ├─2261 / | ||
| + | │ │ │ ├─2268 / | ||
| + | │ │ │ ├─2271 / | ||
| + | │ │ │ ├─2272 / | ||
| + | │ │ │ ├─2273 / | ||
| + | │ │ │ ├─2274 / | ||
| + | │ │ │ ├─2275 / | ||
| + | │ │ │ ├─2280 / | ||
| + | │ │ │ ├─2281 / | ||
| + | │ │ │ ├─2283 / | ||
| + | │ │ │ ├─2284 / | ||
| + | │ │ │ ├─2285 / | ||
| + | │ │ │ ├─2290 / | ||
| + | │ │ │ ├─2321 / | ||
| + | │ │ │ ├─2328 / | ||
| + | │ │ │ ├─2333 / | ||
| + | │ │ │ └─2432 / | ||
| + | │ │ └─user@42.service | ||
| + | │ │ | ||
| + | │ │ │ └─2170 / | ||
| + | │ │ | ||
| + | │ │ │ └─1455 / | ||
| + | │ │ | ||
| + | │ │ │ ├─1357 / | ||
| + | │ │ │ └─1377 (sd-pam) | ||
| + | │ │ | ||
| + | │ │ │ ├─2090 / | ||
| + | │ │ │ ├─2095 / | ||
| + | │ │ │ └─2098 / | ||
| + | │ │ | ||
| + | │ │ | ||
| + | │ │ | ||
| + | │ └─user-1000.slice | ||
| + | │ | ||
| + | │ │ ├─gvfs-goa-volume-monitor.service | ||
| + | │ │ │ └─2369 / | ||
| + | │ │ ├─xdg-permission-store.service | ||
| + | │ │ │ └─2191 / | ||
| + | │ │ ├─tracker-store.service | ||
| + | │ │ │ └─2653 / | ||
| + | │ │ ├─evolution-calendar-factory.service | ||
| + | │ │ │ ├─2605 / | ||
| + | │ │ │ └─2706 / | ||
| + | │ │ ├─pulseaudio.service | ||
| + | │ │ │ └─1456 / | ||
| + | │ │ ├─gvfs-daemon.service | ||
| + | │ │ │ ├─1896 / | ||
| + | │ │ │ └─1901 / | ||
| + | │ │ ├─evolution-source-registry.service | ||
| + | │ │ │ └─2206 / | ||
| + | │ │ ├─gvfs-udisks2-volume-monitor.service | ||
| + | │ │ │ └─2243 / | ||
| + | │ │ ├─init.scope | ||
| + | │ │ │ ├─1239 / | ||
| + | │ │ │ └─1318 (sd-pam) | ||
| + | │ │ ├─gvfs-gphoto2-volume-monitor.service | ||
| + | │ │ │ └─2269 / | ||
| + | │ │ ├─at-spi-dbus-bus.service | ||
| + | │ │ │ ├─1964 / | ||
| + | │ │ │ ├─1969 / | ||
| + | │ │ │ └─1972 / | ||
| + | │ │ ├─dbus.service | ||
| + | │ │ │ ├─1786 / | ||
| + | │ │ │ ├─2183 / | ||
| + | │ │ │ ├─2201 / | ||
| + | │ │ │ ├─2225 / | ||
| + | │ │ │ ├─2397 / | ||
| + | │ │ │ └─2721 / | ||
| + | │ │ ├─evolution-addressbook-factory.service | ||
| + | │ │ │ ├─2727 / | ||
| + | │ │ │ └─2771 / | ||
| + | │ │ ├─gvfs-mtp-volume-monitor.service | ||
| + | lines 44-86 | ||
| + | </ | ||
| + | |||
| + | Using Systemd, several resources can be limited: | ||
| + | |||
| + | * **CPUShares** - default value = 1024, | ||
| + | * **MemoryLimit** - expressed in MB or GB, there is no default value, | ||
| + | * **BlockIOWeight** - expressed as a value between 10 and 1000, there is no default value, | ||
| + | * **StartupCPUShares** - the same as CPUShares but only used during startup, | ||
| + | * **StartupBlockIOWeight** - the same as BlockIOWeight but only used during startup, | ||
| + | * **CPUQuota** - used to limit CPU usage even when the system is doing nothing. | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | **Important** : You can check the systemd.resource-control(5) manual to see which CGroup parameters can be passed to systemctl. | ||
| + | </ | ||
| + | |||
| + | ===Limiting Memory Usage=== | ||
| + | |||
| + | Start by creating the **hello-world.sh** script that will be used to work with CGroups : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# vi hello-world.sh | ||
| + | [root@centos8 ~]# cat hello-world.sh | ||
| + | #!/bin/bash | ||
| + | while [ 1 ]; do | ||
| + | echo "hello world" | ||
| + | sleep 360 | ||
| + | done | ||
| + | </ | ||
| + | |||
| + | Make the script runnable and test it: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# chmod u+x hello-world.sh | ||
| + | [root@centos8 ~]# ./ | ||
| + | hello world | ||
| + | ^C | ||
| + | </ | ||
| + | |||
| + | Now create a CGroup in the **memory** sub-system called **helloworld** : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# mkdir / | ||
| + | </ | ||
| + | |||
| + | By default, this CGroup inherits the use of the **all** of the available memory. To avoid that, create a **40, | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# echo 40000000 > / | ||
| + | [root@centos8 ~]# cat / | ||
| + | 39997440 | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | **Important** - Note that the 40,000,000 requested have become 39,997,440 which corresponds to a round number of Kernel Memory Pages, each of 4KB size ( 39,997,440 / 4,096 = 9,765 ). | ||
| + | </ | ||
| + | |||
| + | Now run the **helloworld.sh** script: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# ./ | ||
| + | [1] 35148 | ||
| + | |||
| + | [root@centos8 ~]# hello world | ||
| + | [Enter] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
| + | |||
| + | [root@centos8 ~]# ps aux | grep hello-world | ||
| + | root | ||
| + | root | ||
| + | </ | ||
| + | |||
| + | Note that there is **no** memory limit: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# ps -ww -o cgroup 35148 | ||
| + | CGROUP | ||
| + | 12: | ||
| + | </ | ||
| + | |||
| + | NOw insert the PID of the script into the **helloworld** CGroup: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# echo 35148 > / | ||
| + | </ | ||
| + | |||
| + | NOw you can see a memory limit - **12: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# ps -ww -o cgroup 35148 | ||
| + | CGROUP | ||
| + | 12: | ||
| + | </ | ||
| + | |||
| + | Now check the actual memory consumption: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cat / | ||
| + | 274432 | ||
| + | </ | ||
| + | |||
| + | Kill the **hello-world.sh** script: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# kill 35148 | ||
| + | [root@centos8 ~]# ps aux | grep hello-world | ||
| + | root | ||
| + | [1]+ Terminated | ||
| + | </ | ||
| + | |||
| + | Create a more restrictive CGroup called **helloworld1** : | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# mkdir / | ||
| + | [root@centos8 ~]# echo 6000 > / | ||
| + | [root@centos8 ~]# cat / | ||
| + | 4096 | ||
| + | </ | ||
| + | |||
| + | Re-run the script and put the PID in the new CGroup: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# ./ | ||
| + | [1] 35389 | ||
| + | |||
| + | [root@centos8 ~]# hello world | ||
| + | [Enter] | ||
| + | |||
| + | [root@centos8 ~]# echo 35389 > / | ||
| + | </ | ||
| + | |||
| + | Wait for **hello world** to appear. You will notice that the script has stopped: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# hello world | ||
| + | [Enter] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
| + | [1]+ Killed | ||
| + | </ | ||
| + | |||
| + | ===The cgcreate Command=== | ||
| + | |||
| + | This command creates a CGroup: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cgcreate -g memory: | ||
| + | [root@centos8 ~]# ls -l / | ||
| + | total 0 | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:39 cgroup.clone_children | ||
| + | --w--w----. 1 root root 0 Jul 13 10:39 cgroup.event_control | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:39 cgroup.procs | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:39 memory.failcnt | ||
| + | --w--w----. 1 root root 0 Jul 13 10:39 memory.force_empty | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:39 memory.kmem.failcnt | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:39 memory.kmem.limit_in_bytes | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:39 memory.kmem.max_usage_in_bytes | ||
| + | -r--r--r--. 1 root root 0 Jul 13 10:39 memory.kmem.slabinfo | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:39 memory.kmem.tcp.failcnt | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:39 memory.kmem.tcp.limit_in_bytes | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:39 memory.kmem.tcp.max_usage_in_bytes | ||
| + | -r--r--r--. 1 root root 0 Jul 13 10:39 memory.kmem.tcp.usage_in_bytes | ||
| + | -r--r--r--. 1 root root 0 Jul 13 10:39 memory.kmem.usage_in_bytes | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:39 memory.limit_in_bytes | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:39 memory.max_usage_in_bytes | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:39 memory.memsw.failcnt | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:39 memory.memsw.limit_in_bytes | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:39 memory.memsw.max_usage_in_bytes | ||
| + | -r--r--r--. 1 root root 0 Jul 13 10:39 memory.memsw.usage_in_bytes | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:39 memory.move_charge_at_immigrate | ||
| + | -r--r--r--. 1 root root 0 Jul 13 10:39 memory.numa_stat | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:39 memory.oom_control | ||
| + | ----------. 1 root root 0 Jul 13 10:39 memory.pressure_level | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:39 memory.soft_limit_in_bytes | ||
| + | -r--r--r--. 1 root root 0 Jul 13 10:39 memory.stat | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:39 memory.swappiness | ||
| + | -r--r--r--. 1 root root 0 Jul 13 10:39 memory.usage_in_bytes | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:39 memory.use_hierarchy | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:39 notify_on_release | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:39 tasks | ||
| + | </ | ||
| + | |||
| + | Set a memory limit for **helloworld2**: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# echo 40000000 > / | ||
| + | </ | ||
| + | |||
| + | ==The cgexec Command== | ||
| + | |||
| + | This command inserts the limit into the CGroup **and** launches the script: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cgexec -g memory: | ||
| + | [1] 37670 | ||
| + | |||
| + | [root@centos8 ~]# hello world | ||
| + | [Enter] | ||
| + | |||
| + | [root@centos8 ~]# | ||
| + | </ | ||
| + | |||
| + | ==THe cgdelete Command== | ||
| + | |||
| + | Once the sxcript has terminated, this command deletes the CGroup: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# ps aux | grep *.sh | ||
| + | root | ||
| + | root | ||
| + | |||
| + | [root@centos8 ~]# kill 37670 | ||
| + | |||
| + | root@centos8 ~]# ps aux | grep *.sh | ||
| + | root | ||
| + | [1]+ Terminated | ||
| + | |||
| + | [root@centos8 ~]# cgdelete memory: | ||
| + | |||
| + | [root@centos8 ~]# ls -l / | ||
| + | ls: cannot access '/ | ||
| + | </ | ||
| + | |||
| + | ==The / | ||
| + | |||
| + | In order for limites to be persistent, it is necessary to edit the **/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# vi / | ||
| + | [root@centos8 ~]# cat / | ||
| + | # | ||
| + | # Copyright IBM Corporation. 2007 | ||
| + | # | ||
| + | # Authors: | ||
| + | # This program is free software; you can redistribute it and/or modify it | ||
| + | # under the terms of version 2.1 of the GNU Lesser General Public License | ||
| + | # as published by the Free Software Foundation. | ||
| + | # | ||
| + | # This program is distributed in the hope that it would be useful, but | ||
| + | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| + | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| + | # | ||
| + | # | ||
| + | # By default, we expect systemd mounts everything on boot, | ||
| + | # so there is not much to do. | ||
| + | # See man cgconfig.conf for further details, how to create groups | ||
| + | # on system boot using this file. | ||
| + | group helloworld2 { | ||
| + | cpu { | ||
| + | cpu.shares = 100; | ||
| + | } | ||
| + | memory { | ||
| + | memory.limit_in_bytes = 40000; | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | **Important** - Here you have created **two** limits : a memory limit of 40,000 Bytes and a **cpu.shares** limoit of **100**. This latter corresponds to about 9,77% of the CPU. | ||
| + | </ | ||
| + | |||
| + | Now create the **two** CGroups: | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cgcreate -g memory: | ||
| + | [root@centos8 ~]# ls -l / | ||
| + | total 0 | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:46 cgroup.clone_children | ||
| + | --w--w----. 1 root root 0 Jul 13 10:46 cgroup.event_control | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:46 cgroup.procs | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:46 memory.failcnt | ||
| + | --w--w----. 1 root root 0 Jul 13 10:46 memory.force_empty | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:46 memory.kmem.failcnt | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:46 memory.kmem.limit_in_bytes | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:46 memory.kmem.max_usage_in_bytes | ||
| + | -r--r--r--. 1 root root 0 Jul 13 10:46 memory.kmem.slabinfo | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:46 memory.kmem.tcp.failcnt | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:46 memory.kmem.tcp.limit_in_bytes | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:46 memory.kmem.tcp.max_usage_in_bytes | ||
| + | -r--r--r--. 1 root root 0 Jul 13 10:46 memory.kmem.tcp.usage_in_bytes | ||
| + | -r--r--r--. 1 root root 0 Jul 13 10:46 memory.kmem.usage_in_bytes | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:46 memory.limit_in_bytes | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:46 memory.max_usage_in_bytes | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:46 memory.memsw.failcnt | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:46 memory.memsw.limit_in_bytes | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:46 memory.memsw.max_usage_in_bytes | ||
| + | -r--r--r--. 1 root root 0 Jul 13 10:46 memory.memsw.usage_in_bytes | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:46 memory.move_charge_at_immigrate | ||
| + | -r--r--r--. 1 root root 0 Jul 13 10:46 memory.numa_stat | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:46 memory.oom_control | ||
| + | ----------. 1 root root 0 Jul 13 10:46 memory.pressure_level | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:46 memory.soft_limit_in_bytes | ||
| + | -r--r--r--. 1 root root 0 Jul 13 10:46 memory.stat | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:46 memory.swappiness | ||
| + | -r--r--r--. 1 root root 0 Jul 13 10:46 memory.usage_in_bytes | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:46 memory.use_hierarchy | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:46 notify_on_release | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:46 tasks | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cgcreate -g cpu: | ||
| + | [root@centos8 ~]# ls -l / | ||
| + | total 0 | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:47 cgroup.clone_children | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:47 cgroup.procs | ||
| + | -r--r--r--. 1 root root 0 Jul 13 10:47 cpuacct.stat | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:47 cpuacct.usage | ||
| + | -r--r--r--. 1 root root 0 Jul 13 10:47 cpuacct.usage_all | ||
| + | -r--r--r--. 1 root root 0 Jul 13 10:47 cpuacct.usage_percpu | ||
| + | -r--r--r--. 1 root root 0 Jul 13 10:47 cpuacct.usage_percpu_sys | ||
| + | -r--r--r--. 1 root root 0 Jul 13 10:47 cpuacct.usage_percpu_user | ||
| + | -r--r--r--. 1 root root 0 Jul 13 10:47 cpuacct.usage_sys | ||
| + | -r--r--r--. 1 root root 0 Jul 13 10:47 cpuacct.usage_user | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:47 cpu.cfs_period_us | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:47 cpu.cfs_quota_us | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:47 cpu.rt_period_us | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:47 cpu.rt_runtime_us | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:47 cpu.shares | ||
| + | -r--r--r--. 1 root root 0 Jul 13 10:47 cpu.stat | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:47 notify_on_release | ||
| + | -rw-rw-r--. 1 root root 0 Jul 13 10:47 tasks | ||
| + | </ | ||
| + | |||
| + | ==The cgconfigparser Command== | ||
| + | |||
| + | Apply the contents of the **/ | ||
| + | |||
| + | < | ||
| + | [root@centos8 ~]# cgconfigparser -l / | ||
| + | [root@centos8 ~]# cat / | ||
| + | 36864 | ||
| + | [root@centos8 ~]# cat / | ||
| + | 100 | ||
| + | </ | ||
| + | |||
| + | ----- | ||
| + | Copyright © 2021 Hugh Norris. | ||