Making and Mounting a File System

 

1. Why Do We Need This?

A system may have:

  • Multiple disks

  • Multiple partitions

  • Different file system types

👉 But users should see one unified directory tree

✔ Solution:

  • Create file systems

  • Mount them into a single hierarchy


2. Making a File System

📌 Tool: mkfs (make file system)

🔑 Purpose

Creates a new, empty file system on a storage device (like a disk partition)


📖 Syntax

mkfs -t <filesystem_type> <device>

Example

mkfs -t ext3 /dev/sda1

⚙️ What mkfs Does Internally

When you run mkfs, it:

  1. Initializes the disk partition

  2. Creates essential structures:

    • Root directory (/)

    • Inodes

    • Free space management

  3. Writes metadata structures onto disk

👉 After this:

  • The disk contains a valid file system

  • But it is still not accessible to users


3. Mounting a File System

📌 System Call: mount()

📌 Command:

mount -t <type> <device> <mount_point>

🔑 Concept

👉 Mounting =
Attaching a file system to an existing directory


📖 Example

mount -t ext3 /dev/sda1 /home/users

🔄 What Happens During Mount?

  • /home/users becomes the entry point (mount point)

  • The root of new file system is attached there


📂 Before Mount

/ ├── home │ └── users (empty or existing dir)

📂 After Mount

/ ├── home │ └── users → root of new filesystem ├── a │ └── foo └── b └── foo

📌 Accessing Files

PathMeaning
/home/users/    root of new FS
/home/users/a    subdirectory
/home/users/a/foo    file

4. Key Insight: Unified Namespace

👉 Mount creates a single global directory tree

✔ User does NOT see:

  • Different disks

  • Different partitions

✔ Everything appears under /


5. Multiple File Systems in One Tree

Example output of mount:

/dev/sda1 on /     type ext3 proc on /proc      type proc tmpfs on /dev/shm type tmpfs

🔍 Types of File Systems

TypePurpose
ext3    Disk-based storage
proc    Process information
tmpfs    Temporary memory-based FS
AFS    Distributed file system

🔑 Insight

👉 Different file systems can coexist:

  • Disk storage

  • Memory storage

  • Network storage

✔ All appear as one system


6. Important Concepts

📌 Mount Point

  • A directory where new FS is attached

  • Must exist before mounting


📌 Root of Mounted FS

  • The root (/) of new FS appears at mount point


📌 Transparency

👉 Users don’t need to know:

  • Where data is physically stored

  • Which device is used


7. Advantages

✅ Simplicity

  • Single directory structure

✅ Flexibility

  • Add/remove storage easily

✅ Modularity

  • Different FS types supported


8. Summary

Emphasize:

👉 Key abstraction

Multiple file systems → One unified tree

👉 Two-step process:

  1. mkfs → create filesystem

  2. mount → make it accessible



Comments

Popular posts from this blog

Operating Systems OS PCCST403 Semester 4 BTech KTU CS 2024 Scheme

Introduction to Operating System -Virtualization, Concurrency, and Persistence

Operating Systems PCCST403 Scheme and Syllabus