A file system is responsible to allocate the free blocks to the file therefore it has to keep track of all the free blocks present in the disk.
There are mainly four approaches by using which, the free blocks in the disk are managed.
Bit Vector
Linked List
Grouping
Counting
Bit Vector:
The free-space list is implemented as a bit map or bit vector.
Each block is represented by 1 bit. If the block is free, the bit is 1; if the block is allocated, the bit is 0.
For example, consider a disk where blocks
2, 3, 4, 5, 8, 9, 10, 11, 12, 13 are free and the rest of the blocks are allocated.
The free-space bit map would be : 0011110011111100
The main advantage of this approach is its relative simplicity and its efficiency in finding the first free block or n consecutive free blocks on the disk.
Linked List
In this approach, the free disk blocks are linked together i.e. a free block contains a pointer to the next free block.
The block number of the very first disk block is stored at a separate location on disk and is also cached in memory.
In this approach, link all the disk blocks together, keeping a pointer to the first free block.
This block contains a pointer to the next free disk block, and so on.