Disk Management in Operating System
The operating system is responsible for various operations of disk management. Modern operating systems are constantly growing their range of services and add-ons, and all operating systems implement four essential operating system administration functions. These functions are as follows:
Most systems include secondary storage devices (magnetic disks). It is a low-cost, non-volatile storage method for data and programs. The user data and programs are stored on different storage devices known as files. The OS is responsible for allocating space to files on secondary storage devices as required.
It doesn't ensure that files are saved on physical disk drives in contiguous locations. It is highly dependent on the provided space. New files are mostly stored in various locations if the disk drive is full. On the other hand, the OS example file hides that the file is divided into several parts.
The OS requires tracking the position of the disk drive for each section of every file on the disk. It may include tracking many files and file segments on a physical disk drive in some circumstances. Furthermore, the OS must be able to identify each file and conduct read and writes operations on it according to the requirements. As a result, the OS is mainly responsible for setting the file system, assuring the security and reliability of reading and writing activities to secondary storage, and keeping access times consistent.
Disk Management of the OS includes the various aspects, such as:
1. Disk Formatting
A new magnetic disk is mainly a blank slate. It is platters of the magnetic recording material. Before a disk may hold data, it must be partitioned into sectors that may be read and written by the disk controller. It is known as physical formatting and low-level formatting.
Low-level formatting creates a unique data structure for every sector on the drive. A data structure for a sector is made up of a header, a data region, and a trailer. The disk controller uses the header and trailer to store information like an error-correcting code (ECC) and a sector number.
The OS must require recording its own data structures on the disk drive to utilize it as a storage medium for files. It accomplishes this in two phases. The initial step is to divide the disk drive into one or more cylinder groups. The OS may treat every partition as it were a separate disk. For example, one partition could contain a copy of the OS executable code, while another could contain user files. The second stage after partitioning is logical formatting. The operating store stores the initial file system data structure on the disk drive in this second stage.
2. Boot Block
When a system is turned on or restarted, it must execute an initial program. The start program of the system is called the bootstrap program. It starts the OS after initializing all components of the system. The bootstrap program works by looking for the OS kernel on disk, loading it into memory, and jumping to an initial address to start the OS execution.
The bootstrap is usually kept in read-only memory on most computer systems. It is useful since read-only memory does not require initialization and is at a fixed location where the CPU may begin executing whether powered on or reset. Furthermore, it may not be affected by a computer system virus because ROM is read-only. The issue is that updating this bootstrap code needs replacing the ROM hardware chips.
As a result, most computer systems include small bootstrap loader software in the boot ROM, whose primary function is to load a full bootstrap program from a disk drive. The entire bootstrap program can be modified easily, and the disk is rewritten with a fresh version. The bootstrap program is stored in a partition and is referred to as the boot block. A boot disk or system disk is a type of disk that contains a boot partition.
3. Bad Blocks
Disks are prone to failure due to their moving parts and tight tolerances. When a disk drive fails, it must be replaced and the contents transferred to the replacement disk using backup media. For some time, one or more sectors become faulty. Most disks also come from the company with bad blocks. These blocks are handled in various ways, depending on the use of disk and controller.
On the disk, the controller keeps a list of bad blocks. The list is initialized during the factory's low-level format and updated during the disk's life. Each bad sector may be replaced with one of the spare sectors by directing the controller. This process is referred to as sector sparing.