4.2 Lesson 1
Certificate: |
Linux Essentials |
---|---|
Version: |
1.6 |
Topic: |
4 The Linux Operating System |
Objective: |
4.2 Understanding Computer Hardware |
Lesson: |
1 of 1 |
Introduction
Without hardware, software is nothing more than another form of literature. Hardware processes the commands described by the software and provides mechanisms for storage, input, and output. Even the cloud is ultimately backed by hardware.
As an operating system, one of Linux' responsibilities is providing software with interfaces to access a system’s hardware. Most configuration specifics are beyond the scope of this lesson. However, users are often concerned with the performance, capacity, and other factors of system hardware since they impact the ability of a system to adequately support specific applications. This lesson discusses hardware as separate physical items using standard connectors and interfaces. The standards are relatively static. But the form factor, performance, and capacity characteristics of hardware are constantly evolving. Regardless of how changes may blur physical distinctions the conceptual aspects of hardware described in this lesson still apply.
Note
|
At various points within this lesson command line examples are used to demonstrate ways to access information about hardware. Most examples are from a Raspberry Pi B+ but should apply to most systems. Understanding these commands is not required to understand this material. |
Power Supplies
All of the active components in a computer system require electricity to operate. Unfortunately, most sources of electricity are not appropriate. Computer system hardware requires specific voltages with relatively tight tolerances. Which is not what is available from your local wall outlet.
Power supplies normalize available sources of power. Standard voltage requirements allow manufacturers to create hardware components that can be used in systems anywhere in the world. Desktop power supplies tend to use the electricity from wall outlets as a source. Server power supplies tend to be more critical so they can often connect to multiple sources to assure that they continue operating if one source fails.
Consuming power generates heat. Excessive heat can cause system components to operate slowly or even fail. Most systems have some form of fan to move air for more efficient cooling. Components such as processors often generate heat that air flow alone cannot dissipate. These hot components attach special fins known as heat sinks to help dissipate the heat they generate. Heat sinks often have their own small local fan to ensure adequate air flow.
Motherboard
All of a system’s hardware needs to interconnect. A motherboard normalizes that interconnection using standardized connectors and form factors. It also provides support for the configuration and electrical needs of those connectors.
There are a large number of motherboard configurations. They support different processors and memory systems. They have different combinations of standardized connectors. And they adapt to the different sizes of the packaging that contains them. Except perhaps for the ability to connect specific external devices, motherboard configuration is effectively transparent to users. Administrators are mostly exposed to motherboard configuration when there is a need to identify specific devices.
When power is first applied there is motherboard specific hardware that must be configured and initialized before the system can operate. Motherboards use programming stored in nonvolatile memory known as firmware to deal with motherboard specific hardware. The original form of motherboard firmware was known as BIOS (Basic Input/Output System). Beyond basic configuration settings BIOS was mostly responsible for identifying, loading, and transferring operation to an operating system such as Linux. As hardware evolved, firmware expanded to support larger disks, diagnostics, graphical interfaces, networking, and other advanced capabilities independent of any loaded operating system. Early attempts to advance firmware beyond basic BIOS was often specific to a motherboard manufacturer. Intel defined a standard for advanced firmware known as EFI (Extensible Firmware Interface). Intel contributed EFI to a standards organization to create UEFI (Unified Extensible Firmware Interface). Today, most motherboards use UEFI. BIOS and EFI are almost never seen on recent systems. Regardless, most people still refer to motherboard firmware as BIOS.
There are very few firmware settings of interest to general users so only individuals responsible for system hardware configuration typically need to deal with firmware and its settings. One of the few commonly changed options is enabling virtualization extensions of modern CPUs.
Memory
System memory holds the data and program code of currently running applications. When they talk about computer memory most people are referring to this system memory. Another common term used for system memory is the acronym RAM (Random Access Memory) or some variation of that acronym. Sometimes references to the physical packaging of the system memory such as DIMM, SIMM or DDR are also used.
Physically, system memory is usually packaged on individual circuit board modules that plug into the motherboard. Individual memory modules currently range in size from 2 GB to 64 GB. For most general purpose applications 4 GB is the minimum system memory people should consider. For individual workstations 16 GB is typically more than sufficient. However even 16 GB might be limiting for users running gaming, video, or high-end audio applications. Servers often require 128 GB or even 256 GB of memory to efficiently support user loads.
For the most part Linux allows users to treat system memory as a black box. An application is started and Linux takes care of allocating the system memory required. Linux releases the memory for use by other applications when an application completes. But what if an application requires more than the available system memory? In this case, Linux moves idle applications from system memory into a special disk area known as swap space. Linux moves idle applications from the disk swap space back to system memory when they need to run.
Systems without dedicated video hardware often use a portion of the system memory (often 1 GB) to act as video display storage. This reduces the effective system memory. Dedicated video hardware typically has its own separate memory that is not available as system memory.
There are several ways to obtain information about system memory. As a user, the total amount of memory available and in use are typically the values of interest. One source of information would be to run the command free
along with the parameter -m
to use megabytes in the output:
$ free -m total used free shared buff/cache available Mem: 748 37 51 14 660 645 Swap: 99 0 99
The first line specifies the total memory available to the system (total
), the memory in use (used
) and the free memory (free
). The second line displays this information for the swap space. Memory indicated as shared
and buff/cache
is currently used for other system functions, although the amount indicated in available
could be used for application.
Processors
The word “processor” implies that something is being processed. In computers most of that processing is dealing with electrical signals. Typically those signals are treated as having one of the binary values 1 or 0.
When people talk about computers they often use the word processor interchangeably with the acronym CPU (Central Processing Unit). Which is not technically correct. Every general purpose computer has a CPU that processes the binary commands specified by software. So it is understandable that people interchange processor and CPU. However, in addition to a CPU, modern computers often include other task specific processors. Perhaps the most recognizable additional processor is a GPU (Graphical Processing Unit). Thus, while a CPU is a processor, not all processors are CPUs.
For most people CPU architecture is a reference to the instructions that the processor supports. Although Intel and AMD make processors supporting the same instructions it is meaningful to differentiate by vendor because of vendor specific packaging, performance, and power consumption differences. Software distributions commonly use these designations to specify the minimum set of instructions they require to operate:
- i386
-
References the 32-bit instruction set associated with the Intel 80386.
- x86
-
Typically references the 32-bit instruction sets associated with successors to the 80386 such as 80486, 80586, and Pentium.
- x64 / x86-64
-
References processors that support both the 32-bit and 64-bit instructions of the x86 family.
- AMD
-
A reference to x86 support by AMD processors.
- AMD64
-
A reference to x64 support by AMD processors.
- ARM
-
References a Reduced Instruction Set Computer (RISC) CPU that is not based on the x86 instruction set. Commonly used by embedded, mobile, tablet, and battery operated devices. A version of Linux for ARM is used by the Raspberry Pi.
The file /proc/cpuinfo
contains detailed information about a system’s processor. Unfortunately the details are not friendly to general users. A more general result can be obtained with the command lscpu
. Output from a Raspberry Pi B+:
$ lscpu Architecture: armv7l Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 1 Core(s) per socket: 4 Socket(s): 1 Model: 4 Model name: ARMv7 Processor rev 4 (v7l) CPU max MHz: 1400.0000 CPU min MHz: 600.0000 BogoMIPS: 38.40 Flags: half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
To most people the myriad of vendors, processor families, and specification factors represent a bewildering array of choices. Regardless, there are several factors associated with CPUs and processors that even general users and administrators often need to consider when they need to specify operational environments:
- Bit size
-
For CPUs this number relates to both the native size of data it manipulates and the amount of memory it can access. Most modern systems are either 32-bit or 64-bit. If an application needs access to more than 4 gigabytes of memory then it must run on a 64-bit system since 4 gigabytes is the maximum address that can be represented using 32 bits. And, while 32-bit applications can typically run on 64-bit systems, 64-bit applications cannot run on 32-bit systems.
- Clock speed
-
Often expressed in megahertz (MHz) or gigahertz (GHz). This relates to how fast a processor processes instructions. But processor speed is just one of the factors impacting system response times, wait times, and throughput. Even an active multi-tasking user rarely keeps a CPU of a common desktop PC active more than 2 or 3 percent of the time. Regardless, if you frequently use computationally intensive applications involving activities such as encryption or video rendering then CPU speed may have a significant impact on throughput and wait time.
- Cache
-
CPUs require a constant stream of both instructions and data in order to operate. The cost and power consumption of a multi-gigabyte system memory that could be accessed at CPU clock speeds would be prohibitive. CPU-speed cache memory is integrated onto the CPU chip to provide a high-speed buffer between CPUs and system memory. Cache is separated into multiple layers, commonly referenced as L1, L2, L3 and even L4. In the case of cache, more is often better.
- Cores
-
Core refers to an individual CPU. In addition to core representing a physical CPU, Hyper-Threading Technology (HTT) allows a single physical CPU to concurrently process multiple instructions thus virtually acting as multiple physical CPUs. Most typically, multiple physical cores are packaged as a single physical processor chip. However, there are motherboards that support multiple physical processor chips. In theory having more cores to process tasks would always seem to yield better system throughput. Unfortunately, desktop applications often only keep CPUs busy 2 or 3 percent of the time, so adding more mostly idle CPUs is likely to result in minimal improvement to throughput. More cores are best suited to running applications that are written to have multiple independent threads of operation such as video frame rendering, web page rendering, or multi-user virtual machine environments.
Storage
Storage devices provide a method for retaining programs and data. Hard Disk Drives (HDDs) and Solid State Drives (SSDs) are the most common form of storage device for servers and desktops. USB memory sticks and optical devices such as DVD are also used but rarely as a primary device.
As the name implies, a hard disk drive stores information on one or more rigid physical disks. The physical disks are covered with magnetic media to make storage possible. The disks are contained within a sealed package since dust, small particles, and even finger prints would interfere with the ability of the HDD to read and write the magnetic media.
SSDs are effectively more sophisticated versions of USB memory sticks with significantly larger capacity. SSDs store information in microchips so there are no moving parts.
Although the underlying technologies for HDDs and SSDs are different, there are important factors that can be compared. HDD capacity is based on scaling physical components while SSD capacity depends on the number of microchips. Per gigabyte, SSDs cost between 3 and 10 times what an HDD costs. To read or write, an HDD must wait for a location on a disk to rotate to a known location while SSDs are random access. SSD access speeds are typically 3 to 5 times faster than HDD devices. Since they have no moving parts SSDs consume less power and are more reliable than HDDs.
Storage capacity is constantly increasing for HDDs and SSDs. Today, 5 terabyte HDDs and 1 terabyte SSDs are commonly available. Regardless, large storage capacity is not always better. When a storage device fails the information it contained is no longer available. And of course, backup takes longer when there is more information to back up. For applications which read and write a lot of data, latency and performance may be more important than capacity.
Modern systems use SCSI (Small Computer System Interface) or SATA (Serial AT Attachment) to connect with storage devices. These interfaces are typically supported by the appropriate connector on the motherboard. Initial load comes from a storage device attached to the motherboard. Firmware settings define the order in which devices are accessed for this initial loading.
Storage systems known as RAID (Redundant Array of Independent Disks) are a common implementation to avoid loss of information. A RAID array consists of multiple physical devices containing duplicate copies of information. If one device fails all of the information is still available. Different physical RAID configurations are referenced as 0, 1, 5, 6, and 10. Each designation has different storage size, performance characteristics and ways to store redundant data or checksums for data recovery. Beyond some administrative configuration overhead, the existence of RAID is effectively transparent to users.
Storage devices commonly read and write data as blocks of bytes. The lsblk
command can be used to list the block devices available to a system. The following example was run on a Raspberry Pi using an SD card as a storage device. The details of the output are covered by information in the Partitions and Drivers lessons that follow:
$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT mmcblk0 179:0 0 29.7G 0 disk +-mmcblk0p1 179:1 0 43.9M 0 part /boot +-mmcblk0p2 179:2 0 29.7G 0 part /
Partitions
A storage device is effectively a long sequence of storage locations. Partitioning is the mechanism that tells Linux if it is to see these storage locations as a single sequence or multiple independent sequences. Each partition is treated as if it is an individual device. Most of the time partitions are created when a system is first configured. If change is needed, administrative tools are available to manage device partitioning.
So why would multiple partitions be desirable? Some examples for using partitions would be managing available storage, isolating encryption overhead, or supporting multiple file systems. Partitions make it possible to have a single storage device that can boot under different operating systems.
While Linux can recognize the storage sequence of a raw device a raw device cannot be used as-is. To use a raw device it must be formatted. Formatting writes a file system to a device and prepares it for file operations. Without a file system a device cannot be used for file-related operations.
Users see partitions as if they are individual devices. This makes it easy to overlook the fact that they’re still dealing with a single physical device. In particular, device to device operations that are actually partition to partition operations will not have the expected performance. A single device is one physical mechanism with one set of read/write hardware. More importantly, you can’t use partitions of a single physical device as a fault tolerant design. If the device fails, all partitions fail so there would be no fault tolerance.
Note
|
Logical Volume Manager (LVM) is a software capability that allows administrators to combine individual disks and disk partitions and treat them as if they are a single drive. |
Peripherals
Servers and workstations need a combination of CPU, system memory, and storage to operate. But these fundamental components don’t directly interface with the external world. Peripherals are the devices that provide systems with input, output, and access to the rest of the real world.
Most motherboards have built-in external connectors and firmware support for common legacy peripheral interfaces supporting devices such as keyboard, mouse, sound, video, and network. Recent motherboards typically have an Ethernet connector to support networks, a HDMI connector supporting basic graphical needs, and one or more USB (Universal Serial Bus) connectors for mostly everything else. There are several versions of USB with different speed and physical characteristics. Several versions of USB ports are common on a single motherboard.
Motherboards may also have one or more expansion slots. Expansion slots allow users to add special circuit boards known as expansion cards that support custom, legacy, and non-standard peripherals. Graphics, sound, and network interfaces are common expansion cards. Expansion cards also support RAID, and special format legacy interfaces involving serial and parallel connections.
System on a Chip (SoC) configurations achieve power, performance, space, and reliability advantages over motherboard configurations by packaging processors, system memory, SSD, and hardware to control peripherals as a single integrated circuit package. The peripherals supported by SoC configurations are limited by the components packaged. Thus, SoC configurations tend to be developed for specific uses. Phones, tablets, and other portable devices are often based on SoC technology.
Some systems incorporate peripherals. Laptops are similar to workstations but incorporate default display, keyboard, and mouse peripherals. All-In-One systems are similar to laptops but require mouse and keyboard peripherals. Motherboard or SoC based controllers are often packaged with integral peripherals appropriate to a specific use.
Drivers and Device Files
So far, this lesson has presented information about processors, memory, disks, partitioning, formatting and peripherals. But requiring general users to deal with the specific details for each of the devices in their system would make those systems unusable. Likewise, software developers would need to modify their code for every new or modified device they need to support.
The solution to this “dealing with the details” problem is provided by a device driver. Device drivers accept a standard set of requests then translate those requests into the device appropriate control activities. Device drivers are what allow you and the applications you run to read from the file /home/carol/stuff
without worrying about whether that file is on a hard drive, solid state drive, memory stick, encrypted storage, or some other device.
Device files are found in the /dev
directory and identify physical devices, device access, and supported drivers. By convention, in modern systems using SCSI or SATA based storage devices the specification filename starts with the prefix sd
. The prefix is followed by a letter such as a
or b
indicating a physical device. After the prefix and device identifier comes a number indicating a partition within the physical device. So, /dev/sda
would reference the entire first storage device while /dev/sda3
would reference partition 3 in the first storage device. The device file for each type of device has a naming convention appropriate to the device. While covering all of the possible naming conventions is beyond the scope of this lesson it is important to remember that these conventions are critical to making system administration possible.
While it is beyond the scope of this lesson to cover the contents of the /dev
directory it is informative to look at the entry for a storage device. Device files for SD cards typically use mmcblk
as a prefix:
$ ls -l mmcblk* brw-rw---- 1 root disk 179, 0 Jun 30 01:17 mmcblk0 brw-rw---- 1 root disk 179, 1 Jun 30 01:17 mmcblk0p1 brw-rw---- 1 root disk 179, 2 Jun 30 01:17 mmcblk0p2
The listing details for a device file are different from typical file details:
-
Unlike a file or directory the first letter of the permissions field is
b
. This indicates that blocks are read from and written to the device in blocks rather than individual characters. -
The size field is two values separated by a comma rather than a single value. The first value generally indicates a particular driver within the kernel and the second value specifies a specific device handled by the driver.
-
The filename uses a number for the physical device so the naming convention adapts by specifying the partition suffix as a
p
followed by a digit.
Note
|
Each system device should have an entry in |
Guided Exercises
-
Describe these terms:
Processor
CPU
GPU
-
If you are primarily running video editing applications (a computationally intensive activity) which components and characteristics would you expect to have the most impact on system usability:
CPU cores
CPU speed
Available system memory
Storage system
GPU
Video display
None of the above
-
What would you expect the name of the device file in
/dev
to be for partition 3 of the third SATA drive in a system:sd3p3
sdcp3
sdc3
None of the above
Explorational Exercises
-
Run the
lsblk
command on your system. Identify the parameters below. If a system is not immediately available, consider thelsblk -f
listing for the Raspberry Pi system mentioned in the “Storage” section above:$ lsblk -f NAME FSTYPE LABEL UUID MOUNTPOINT mmcblk0 +-mmcblk0p1 vfat boot 9304-D9FD /boot +-mmcblk0p2 ext4 rootfs 29075e46-f0d4-44e2-a9e7-55ac02d6e6cc /
-
The type of devices and how many
-
The partition structure of each device
-
The type of file system and mount for each partition
-
Summary
A system is the sum of its components. Different components impact cost, performance, and usability in different ways. While there are common configurations for workstations and servers there is no single best configuration.
Answers to Guided Exercises
-
Describe these terms:
- Processor
-
A general term that applies to any type of processor. Often used incorrectly as a synonym for CPU.
- CPU
-
A Central Processing Unit. A processing unit providing support for general purpose computational tasks.
- GPU
-
A Graphical Processing Unit. A processing unit optimized for supporting activities relating to the presentation of graphics.
-
If you are primarily running video editing applications (a computationally intensive activity) which components and characteristics would you expect to have the most impact on system usability:
- CPU cores
-
Yes. Multiple cores support the concurrent presentation and rendering tasks required by video editing.
- CPU speed
-
Yes. Video rendering requires a significant amount of computational activity.
- Available system memory
-
Likely. The uncompressed video used in editing is large. General purpose systems often come with 8 gigabytes of memory. 16 or even 32 gigabytes of memory allows the system to handle more frames of uncompressed video making editing activities more efficient.
- Storage system
-
Yes. Video files are large. The overhead of local SSD drives supports more efficient transfer. Slower network drives are likely to be counterproductive.
- GPU
-
No. GPU primarily impacts the presentation of the rendered video.
- Video display
-
No. The video display primarily impacts the presentation of the rendered video.
- None of the above
-
No. Some of these factors have obvious impacts on how usable your system would be.
-
What would you expect the name of the device file in
/dev
to be for partition 3 of the third SATA drive in a system:sd3p3
Not correct. Drive 3 would be
sdc
notsd3
sdcp3
Not correct. Partition 3 would be
3
notp3
sdc3
Correct
None of the above
Not correct. The correct answer is one of the choices.
Answers to Explorational Exercises
-
Run the
lsblk
command on your system. Identify the parameters below. If a system is not immediately available, consider thelsblk -f
listing for the Raspberry Pi system mentioned in the “Storage” section above:$ lsblk -f NAME FSTYPE LABEL UUID MOUNTPOINT mmcblk0 +-mmcblk0p1 vfat boot 9304-D9FD /boot +-mmcblk0p2 ext4 rootfs 29075e46-f0d4-44e2-a9e7-55ac02d6e6cc /
Answers that follow are based the
lsblk -f
listing for the Raspberry Pi system above. Your answers may differ:- The type of devices and how many
-
There is one device:
mmcblk0
. You know by convention that themmcblk
would be an SD memory card. - The partition structure of each device
-
There are two partitions:
mmcblk0p1
andmmcblk0p2
. - The type of file system and mount for each partition
-
Partition 1 uses the
vfat
file system. It is used to boot the system and is mounted as/boot
. Partition 2 uses theext4
file system. It is used as the primary file system and is mounted as/
.