The Wayback Machine - https://web.archive.org/web/20241005225353/https://www.geeksforgeeks.org/disk-management-in-operating-system/
Open In App

Disk Management in Operating System

Last Updated : 03 Jul, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Disk management is one of the critical operations carried out by the operating system. It deals with organizing the data stored on the secondary storage devices which includes the hard disk drives and the solid-state drives. It also carries out the function of optimizing the data and making sure that the data is safe by implementing various disk management techniques. We will learn more about disk management and its related techniques found in operating system.

The range of services and add-ons provided by modern operating systems is constantly expanding, and four basic operating system management functions are implemented by all operating systems. These management functions are briefly described below and given the following overall context. The four main operating system management functions (each of which are dealt with in more detail in different places) are:

Most computer systems employ secondary storage devices (magnetic disks). It provides low-cost, non-volatile storage for programs and data (tape, optical media, flash drives, etc.). Programs and the user data they use are kept on separate storage devices called files. The operating system is responsible for allocating space for files on secondary storage media as needed. 

There is no guarantee that files will be stored in contiguous locations on physical disk drives, especially large files. It depends greatly on the amount of space available. When the disc is full, new files are more likely to be recorded in multiple locations. However, as far as the user is concerned, the example file provided by the operating system hides the fact that the file is fragmented into multiple parts.

The operating system needs to track the location of the disk for every part of every file on the disk. In some cases, this means tracking hundreds of thousands of files and file fragments on a single physical disk. Additionally, the operating system must be able to locate each file and perform read and write operations on it whenever it needs to. Therefore, the operating system is responsible for configuring the file system, ensuring the safety and reliability of reading and write operations to secondary storage, and maintains access times (the time required to write data to or read data from secondary storage). 

Disk Management of the Operating System Includes:

  • Disk Format
  • Booting from disk
  • Bad block recovery

The low-level format or physical format:

 Divides the disk into sectors before storing data so that the disk controller can read and write Each sector can be:

The header retains information, data, and error correction code (ECC) sectors of data, typically 512 bytes of data, but optional disks use the operating system’s own data structures to preserve files using disks.

 It is conducted in two stages:

1. Divide the disc into multiple cylinder groups. Each is treated as a logical disk.

2. Logical format or “Create File System”. The OS stores the data structure of the first file system on the disk. Contains free space and allocated space.

For efficiency, most file systems group blocks into clusters. Disk I / O runs in blocks. File I / O runs in a cluster.

For example, the sizes can be 256,512, and 1,024 bytes. If disk is formatted with larger sector size, fewer sectors can fit on each track.

As a result fewer headers and trailers are written on each track and more space is obtainable for user data. – Some operating systems can handle a sector size of 512 bytes.

Operating system keeps its own data structures on disk before it use disk to store the files. It performs this with following two steps:

1. It partitions the disk into one or more groups of cylinders. Each partition is treated by OS as a separate disk.

2. Logical formatting: That means creation of file system.

In order to increase the efficiency, file system groups blocks in chunks called as clusters.

Some operating systems give special programs the ability to use a disk partition as a large sequential array of logical blocks, without any file-system data structures. This array is sometimes called the raw disk, and I/O to this array is called as raw I/O.

 Boot block:

  • When the computer is turned on or restarted, the program stored in the initial bootstrap ROM finds the location of the OS kernel from the disk, loads the kernel into memory, and runs the OS. start.
  •  To change the bootstrap code, you need to change the ROM and hardware chip. Only a small bootstrap loader program is stored in ROM  instead.
  •  The full bootstrap code is stored in the “boot block” of the disk.
  •  A disk with a boot partition is called a boot disk or system disk. 
  • The bootstrap program is required for a computer to initiate the booting after it is powered up or rebooted.
  • It initializes all components of the system, from CPU registers to device controllers and the contents of main memory, and then starts the operating system.
  • The bootstrap program then locates the OS kernel on disk, loads that kernel into memory, and jumps to an initial address to start the operating-system execution.
  • The Read Only Memory (ROM) does not require initialization and is at a fixed location that the processor can begin executing when powered up or reset. Therefore bootstrap is stored in ROM.
  • Because of read only feature of ROM; it cannot be infected by a computer virus. The difficulty is that modification of this bootstrap code requires changing the ROM hardware chips.
  • Therefore, most systems store a small bootstrap loader program in the boot ROM which invokes and bring full bootstrap program from disk into main memory.
  • The modified version of full bootstrap program can be simply written onto the disk.
  • The fixed storage location of full bootstrap program is in the “boot blocks”.
  • A disk that has a boot partition is called a boot disk or system disk.

 Bad Blocks:

  • Disks are error-prone because moving parts have small tolerances.
  •   Most disks are even stuffed from the factory with bad blocks and are handled in a variety of ways.
  •  The controller maintains a list of bad blocks.
  • The controller can instruct each bad sector to be logically replaced with one of the spare sectors. This scheme is known as sector sparing or transfer.
  •  A soft error triggers the data recovery process.
  • However, unrecoverable hard errors may result in data loss and require manual intervention.
  • Failure of the disk can be:

1. Complete, means there is no way other than replacing the disk. Back up of content must be taken on new disk.

2. One or more sectors become faulty.

3. After manufacturing, the bad blocks exist. Depending on the disk and controller in use, these blocks are handled in a different ways.

Disk management in operating systems involves organizing and maintaining the data on a storage device, such as a hard disk drive or solid-state drive. The main goal of disk management is to efficiently utilize the available storage space and ensure data integrity and security.

Some common disk management techniques used in operating systems include:

  1. Partitioning: This involves dividing a single physical disk into multiple logical partitions. Each partition can be treated as a separate storage device, allowing for better organization and management of data.
  2. Formatting: This involves preparing a disk for use by creating a file system on it. This process typically erases all existing data on the disk.
  3. File system management: This involves managing the file systems used by the operating system to store and access data on the disk. Different file systems have different features and performance characteristics.
  4. Disk space allocation: This involves allocating space on the disk for storing files and directories. Some common methods of allocation include contiguous allocation, linked allocation, and indexed allocation.
  5. Disk defragmentation: Over time, as files are created and deleted, the data on a disk can become fragmented, meaning that it is scattered across the disk. Disk defragmentation involves rearranging the data on the disk to improve performance.

Advantages of disk management include:

  1. Improved organization and management of data.
  2. Efficient use of available storage space.
  3. Improved data integrity and security.
  4. Improved performance through techniques such as defragmentation.

Disadvantages of disk management include:

  1. Increased system overhead due to disk management tasks.
  2. Increased complexity in managing multiple partitions and file systems.
  3. Increased risk of data loss due to errors during disk management tasks.
  4. Overall, disk management is an essential aspect of operating system management and can greatly improve system performance and data integrity when implemented properly.

Conclusion

Disk management is a pivotal part of the operating system which includes managing and optimizing the storage resources. It paves a way for us to organize the way our data is stored on the system. Disk management also facilitates data integrity, which is very important in today’s time. All the techniques supported by the disk management helps us in enhancing the overall performance of the operating system.

Frequently Asked Questions on Disk Management in Operating System – FAQ’s

Q.1. How is partitioning different from formatting?

Partitioning helps us in dividing the physical disk into different logical units. Formatting helps us prepare these logical units formed using partitioning, for data storage using file system.

Q.2. What is the role of disk fragmentation in improving the system performance?

Disk fragmentation helps in reducing access time by reorganizing fragmented data on a disk. This help in improving the overall system efficiency.

Q.3. What are the various disk management functions that can be found in Linux?

Common disk management functionalities that can be found in Linux includes fdisk and mkfs. fdisk is used for partitioning and mkfs is used for formatting disks in various formats of the file system.



Similar Reads

Difference between Seek Time and Disk Access Time in Disk Scheduling
Seek Time: A disk is divided into many circular tracks. Seek Time is defined as the time required by the read/write head to move from one track to another. Example, Consider the following diagram, the read/write head is currently on track 1. Now, on the next read/write request, we may want to read data from Track 4, in this case, our read/write hea
3 min read
Difference between Transfer Time and Disk Access Time in Disk Scheduling
1. Transfer Time : Time required to transfer the required amount of data. It can be calculated by the given formula Transfer time, = Data to be transfer / transfer rate Data to be transfer is given in the question and transfer rate is sometimes given and sometimes it may not be given. It can be calculated by the given formula. Transfer Rate, = {(Nu
2 min read
Difference between Rotational Latency and Disk Access Time in Disk Scheduling
1. Rotational Latency : Rotational Latency is also known as Rotational time. The amount of time taken by the disk to rotate the track when the read/write head come to exact sector or we can also say that the time taken by the desired sector to come under the read/write head is called rotational latency. Rotational Latency is depends on the rotation
4 min read
Difference between Magnetic Disk and Optical Disk
The magnetic and optical disks are the storage devices that provide a way to store data for a long duration. Both are categorized as secondary storage devices. In this article, we are going to discuss the Difference between Magnetic Disks and Optical disks in detail. What is a Magnetic Disk?A magnetic disk is a storage device that uses a magnetizat
4 min read
Difference Between Basic Disk and Dynamic Disk
When managing storage in Windows operating systems, you might come across two primary kinds of disk configurations: Basic Disk and Dynamic Disk. To do this well and make sure that your data is organized according to your needs, it becomes important to know the differentiation between these disk types. This article will explore the main features and
6 min read
Disk Attachment in Operating System
The disk attachment is a special feature that allows you to attach a disk (such as a USB flash drive) to your computer’s hard drive. Users can use this feature to store files in the cloud or transfer files between computers on their network. Host-Attached StorageHost-attached storage (HAS) is a form of internal computer storage that can be attached
5 min read
Disk Defragmentation in Operating System
In the world of computer storage management, retaining the performance of Hard Disk Drives (HDDs) is important for ensuring easy operation and responsiveness of the running system. One key method used to obtain this is disk defragmentation. As data is written, modified, and deleted on a disk through the years, it will become fragmented, leading to
5 min read
Swap-Space Management in Operating system
Swapping is a memory management technique used in multi-programming to increase the number of processes sharing the CPU. It is a technique of removing a process from the main memory and storing it into secondary memory, and then bringing it back into the main memory for continued execution. This action of moving a process out from main memory to se
6 min read
Best Ways for Operating System Memory Management
Prerequisite - Partition Allocation Methods Contiguous Memory Allocation :Probably the least difficult technique for the memory portion is to isolate memory into a few fixed partitions. Each partition contains precisely one process. The level of multi-programming relies upon the number of partitions. In the different partition technique, when a par
7 min read
Memory Management in Operating System
The term memory can be defined as a collection of data in a specific format. It is used to store instructions and process data. The memory comprises a large array or group of words or bytes, each with its own location. The primary purpose of a computer system is to execute programs. These programs, along with the information they access, should be
14 min read
Tertiary Device Management in Operating System
As we know about tertiary devices, let us now dive deeper into OS support which is required to manage tertiary devices. The operating system provides support to tertiary storage devices as removable media. It involves the transfer of data between different systems. In order to manage the tertiary devices, the OS must have support for the device. Th
2 min read
Resource Management in Operating System
Resource Management in Operating System is the process to manage all  the resources efficiently like CPU, memory, input/output devices, and other hardware resources among the various programs and processes running in the computer. Resource management is an important thing because resources of a computer are limited and multiple processes or users m
3 min read
Device Management in Operating System
The process of implementation, operation, and maintenance of a device by an operating system is called device management. When we use computers we will have various devices connected to our system like mouse, keyboard, scanner, printer, and pen drives. So all these are the devices and the operating system acts as an interface that allows the users
9 min read
Free Space Management in Operating System
Free space management is a critical aspect of operating systems as it involves managing the available storage space on the hard disk or other secondary storage devices. The operating system uses various techniques to manage free space and optimize the use of storage devices. Here are some of the commonly used free space management techniques: Free
7 min read
System Protection in Operating System
Introduction: System protection in an operating system refers to the mechanisms implemented by the operating system to ensure the security and integrity of the system. System protection involves various techniques to prevent unauthorized access, misuse, or modification of the operating system and its resources. There are several ways in which an op
3 min read
User View Vs Hardware View Vs System View of Operating System
User View of Operating System: The Operating System is an interface, hides the details which must be performed and present a virtual machine to the user that makes it easier to use. Operating System provides the following services to the user. Execution of a programAccess to I/O devicesControlled access to filesError detection (Hardware failures, a
1 min read
Xv6 Operating System -adding a new system call
Prerequisite - Xv6 Operating System -add a user program In last post we got to know how to add user program in Xv6 Operating System. Now here you will see how to add new system call in Xv6 Operating System. A dding new system call to xv6: A system call is way for programs to interact with operating system. A computer program makes system call when
6 min read
Traps and System Calls in Operating System (OS)
Traps and system calls are two mechanisms used by an operating system (OS) to perform privileged operations and interact with user-level programs. Here is an overview of each mechanism: Traps: A trap is an interrupt generated by the CPU when a user-level program attempts to execute a privileged instruction or encounters an error. When a trap occurs
3 min read
Fork System Call in Operating System
In many operating systems, the fork system call is an essential operation. The fork system call allows the creation of a new process. When a process calls the fork(), it duplicates itself, resulting in two processes running at the same time. The new process that is created is called a child process. It is a copy of the parent process. The fork syst
5 min read
System Programs in Operating System
System Programming can be defined as the act of building Systems Software using System Programming Languages. According to Computer Hierarchy, Hardware comes first then is Operating System, System Programs, and finally Application Programs. Program Development and Execution can be done conveniently in System Programs. Some of the System Programs ar
3 min read
File System Implementation in Operating System
A file is a collection of related information. The file system resides on secondary storage and provides efficient and convenient access to the disk by allowing data to be stored, located, and retrieved. File system implementation in an operating system refers to how the file system manages the storage and retrieval of data on a physical storage de
11 min read
Difference between System Software and Operating System
Software is like a set of instructions that tell a computer what to do. There are two main types application software and system software. Application software is extra programs you can add to your computer to do specific things, like write documents or play games. You don't need these to use your computer, but they help you do particular tasks. Sy
5 min read
Operating Systems | Memory Management | Question 1
Which of the following page replacement algorithms suffers from Belady’s anomaly? (A) FIFO (B) LRU (C) Optimal Page Replacement (D) Both LRU and FIFO Answer: (A) Explanation: Belady’s anomaly proves that it is possible to have more page faults when increasing the number of page frames while using the First in First Out (FIFO) page replacement algor
1 min read
Operating Systems | Process Management | Question 6
Consider the following code fragment: if (fork() == 0) { a = a + 5; printf("%d,%d\n", a, &a); } else { a = a –5; printf("%d, %d\n", a, &a); } Let u, v be the values printed by the parent process, and x, y be the values printed by the child process. Which one of the following is TRUE? (A) u = x + 10 and v = y (B) u = x +
2 min read
Operating Systems | Process Management | Question 6
Three concurrent processes X, Y, and Z execute three different code segments that access and update certain shared variables. Process X executes the P operation (i.e., wait) on semaphores a, b and c; process Y executes the P operation on semaphores b, c and d; process Z executes the P operation on semaphores c, d, and a before entering the respecti
2 min read
Operating Systems | Process Management | Question 6
A shared variable x, initialized to zero, is operated on by four concurrent processes W, X, Y, Z as follows. Each of the processes W and X reads x from memory, increments by one, stores it to memory, and then terminates. Each of the processes Y and Z reads x from memory, decrements by two, stores it to memory, and then terminates. Each process befo
2 min read
Python | Monitor hard-disk health using smartmontools
Smartmontools, an acronym for 'S.M.A.R.T monitoring' tools is a package that is used to control and monitor computer storage systems using S.M.A.R.T. (Self-Monitoring, Analysis and Reporting Technology) system built into most modern (P)ATA, Serial ATA, SCSI/SAS devices. It contains 2 utility programs: smartctl and smartd. These utilities give warni
10 min read
FCFS Disk Scheduling Algorithms
Prerequisite: Disk scheduling algorithms.Given an array of disk track numbers and initial head position, our task is to find the total number of seek operations done to access all the requested tracks if First Come First Serve (FCFS) disk scheduling algorithm is used. First Come First Serve (FCFS) FCFS is the simplest disk scheduling algorithm. As
6 min read
LOOK Disk Scheduling Algorithm
The LOOK Disk Scheduling Algorithm is the advanced version of the SCAN (elevator) disk scheduling algorithm which gives slightly better seek time than any other algorithm in the hierarchy (FCFS->SRTF->SCAN->C-SCAN->LOOK). It is used to reduce the amount of time it takes to access data on a hard disk drive by minimizing the seek time bet
13 min read
Difference between SCAN and LOOK Disk scheduling algorithms
SCAN disk scheduling algorithm: In SCAN disk scheduling algorithm, head starts from one end of the disk and moves towards the other end, servicing requests in between one by one and reach the other end. Then the direction of the head is reversed and the process continues as head continuously scan back and forth to access the disk. So, this algorith
4 min read
Article Tags :
Practice Tags :