##### Disk space management

Free space management:

1. Operating system maintains a Free disks spaces to keep track all the free disks block which are not used by any file
2. To reuse the space released from deleting the files ,free space management is used .

there are two methods :

1-Bitmap or Bit vector

2-Free List Approach

Bitmap or Bit vector

1. In the Bit map approach every disk block will be mapped with a binary bit.
2.  The bit can take two values: 0 and 1: 0 indicates that the block is allocated and 1 indicates a free block.
3. To map 20k disks blocks we need 20k bits .
4. The given instance of disk blocks on the disk in Figure 1 (where green blocks are allocated) can be represented by a bitmap of 16 bits as: 000011100000011 • It is easy to understand
• Finding the first free block is efficient. It requires scanning the words (a group of 8 bits) in a bitmap for a non-zero word. (A 0-valued word has all bits 0). The first free block is then found by scanning for the first 1 bit in the non-zero word.
• The block number can be calculated as:
• (number of bits per word) *(number of 0-values words) + offset of bit first bit 1 in the non-zero word .
• For the Figure-1, we scan the bitmap sequentially for the first non-zero word.
• The first group of 8 bits (00001110) constitute a non-zero word since all bits are not 0. After the non-0 word is found, we look for the first 1 bit. This is the 5th bit of the non-zero word. So, offset = 5.
• Therefore, the first free block number = 8*0+5 = 5.

Free list approach:

1. In the free list approach some disks block are used just to store the free disks block addresses
2. Number of disks blocks addresses possible to store the in a one disk block=(disk block size/disk block address).