The Storage Beneath File Systems, Explained

UPI Study › Courses › Introduction to Operating Systems › Free lessons › Lesson 6.1 Free with a free account

The Storage Beneath File Systems

Introduction to Operating Systems · Chapter 6: File Systems and Data ManagementSection 6.1 · lesson 48 of 838 min · free with a free account

← RAIDNext lesson: The Anatomy of a File System →

A free account plays all of Chapter 1 and 3 more lessons of Introduction to Operating Systems. Create a free account →

Earn 3 college credits for Introduction to Operating SystemsRecommended for credit by NCCRS · Computer Science 354 · self-paced · one payment, lifetime access

In this lesson

How sectors, blocks, partitions, formatting and mounting prepare a drive.

  • Explain how sectors and blocks divide a drive and why the last block wastes space
  • Calculate how many blocks a file needs and how many bytes it leaves unused
  • Describe the roles of partitioning, formatting and mounting, in that order

Free study notes

Get this lesson's notes by email

The key points and 4 practice questions with answers, in your inbox. One email, free.

One email. Unsubscribe in one click.

Transcript

Everything said in the video, section by section (1,090 words). Read along, or search it.

Opening Puzzle

From Numbered Slots to Named Files

Sam, who runs a small online bakery, keeps thousands of files on an old laptop: orders, recipes, and photos of birthday cakes. But the drive inside has no idea what a recipe is. To the drive, it's just a very long row of numbered slots. So how does that blank row turn into folders and files with names? It takes three steps: cut the drive into pieces, prepare each piece, and attach it to the file tree.

Definition

Sectors Are the Smallest Slots

Think of a library shelf with thousands of numbered boxes, all the same size. You can't put half a book in a box. A drive works the same way. Its smallest slot is a sector: a fixed number of bytes, classically five hundred twelve, read or written in one piece. Every sector has a number, and the drive can fetch sector four million as easily as sector one. Many modern drives use bigger physical sectors, of four thousand ninety-six bytes. Most still answer in pieces of five hundred twelve, so older software keeps working.

Blocks and Clusters

Grouping Sectors Into Blocks

Asking for one sector at a time would be slow and fussy. So the operating system groups sectors into a block, which some systems call a cluster. A common block size is four thousand ninety-six bytes: eight sectors of five hundred twelve. The block is the smallest piece the file system hands out. In most file systems, a file's contents are stored in whole blocks.

Worked Example

Wasted Space in the Last Block

That has a cost. A one byte file still reserves a whole block, so four thousand ninety-five bytes sit unused. A file of exactly four thousand ninety-six bytes wastes nothing. One byte more, and it needs a second block. A ten thousand byte file needs three blocks. That reserves twelve thousand two hundred eighty-eight bytes, and wastes two thousand two hundred eighty-eight. For ordinary files, that's small. For ten thousand tiny files, it adds up. So big blocks suit big files, and small blocks suit many tiny ones. A few systems dodge the cost. NTFS, on Windows, can keep a very small file inside the file's own record.

Quick Check

A Five Thousand Byte File

Quick check, with a different block size. A drive is formatted with blocks of two thousand forty-eight bytes. Sam saves a five thousand byte file on it. How many blocks does it take, and how many bytes are wasted? Two blocks with nothing wasted, three blocks wasting two thousand forty-eight, or three blocks wasting one thousand one hundred forty-four? Pause, and decide. Three blocks, with one thousand one hundred forty-four bytes wasted. Two blocks hold only four thousand ninety-six bytes, which is too few. Three blocks reserve six thousand one hundred forty-four. Take away the five thousand bytes of the file, and one thousand one hundred forty-four are left over. Two thousand forty-eight is the size of a full block. It's never the waste, since a completely empty block wouldn't be reserved at all.

Step One

Cutting a Drive Into Partitions

Step one: cut the drive into pieces. A large drive is rarely used as one lump. It's divided into partitions: separate ranges of sectors that the operating system treats like independent drives. A small table at the start of the drive, the partition table, records where each partition starts and how long it is. Why cut it up? The OS stays apart from your files, so reinstalling it leaves them alone. Two operating systems can sit side by side. And a mistake in one area stays there.

Step Two

Formatting Writes a File System

Step two: prepare each piece. A fresh partition is like a new, empty notebook: blank pages, no table of contents. Formatting writes the starting structures of a file system into the partition: the records that will keep names, folders, and where each file's blocks are. Before formatting, the partition can't hold files. After, it can. That's why reformatting a USB stick makes its old files vanish. A quick format only writes fresh, empty records. The old bytes may still sit on the drive. So don't count on it to erase secrets, or to get files back.

Common Mistake

A Partition Is Not a Folder

A common mix-up: a partition is not a folder. A folder lives inside a file system, and it's just a list of names. A partition is a slice of the raw drive, and it must be formatted before it can hold any folders at all. Format the wrong partition, and everything on that slice is gone. So check its name and size first.

Step Three

Mounting Attaches a Drive to the Tree

Step three: attach it to the tree. When Sam plugs in a USB stick, its files aren't usable yet. The operating system must mount the stick: attach its file system to a folder in the existing tree, called the mount point. Then the stick's files appear like ordinary folders. On Windows, as a drive letter such as D. On a Mac, under slash Volumes. On Linux, often under slash media. Unmounting, the eject button, tells the OS to finish every pending write first, so nothing is left half-written. If eject says the device is busy, some program still has a file open there. Close it, wait a moment, and try again.

Quick Check

A Partition With No Folder

Quick check, with a new case. Ivy, who looks after the computers at a school, adds a new partition to a spare drive. Her disk tool lists the new partition. But no folder for it appears anywhere, and nothing can be saved there. What's missing: formatting the partition, mounting it, or a second partition table? Pause, and decide. Formatting. The partition has no file system yet: no records for names, folders or blocks. Mounting is tempting, but mounting attaches a file system to the tree. With no file system, there's nothing to attach. So the order never changes: partition, then format, then mount.

Real Example

Two Partitions on One Laptop

Back to Sam's laptop. Its one drive has two partitions: a system area for Windows, and a data area for the bakery's files. The system partition kept running out of space, while the data partition sat half empty. Ivy explained that the wall between partitions is fixed in the table. So instead of moving the wall, Sam moved the photo folder to the data partition, and the warnings stopped. One more link to remember: two partitions on one drive still share that drive. A big backup in one can slow down work in the other.

Key Takeaways

Sectors, Blocks, Partitions and Mounting

To recap. A drive is a row of numbered sectors, and the file system hands them out in blocks. A file takes whole blocks, so its last block is rarely full. Partitions cut the drive into pieces, and formatting gives each piece a file system. Mounting attaches it to the tree, and ejecting finishes the writes first.

About Introduction to Operating Systems at UPI Study

Introduction to Operating Systems (Computer Science 354) is a self-paced online course of 83 video lessons in 10 chapters, from what an operating system does and process scheduling to concurrency, memory, devices, file systems, networks, the internet, security and virtual machines. It carries a NCCRS credit recommendation for 3 semester credits.

Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

Compare: Linux vs Operating Systems

Why take it here

Why students take Introduction to Operating Systems with UPI Study

What happens under every app you runIntroduction to Operating Systems explains the software that runs a computer: processes and scheduling, threads and synchronization, deadlock, memory and paging, devices and storage, file systems, networking, security and virtualization. It suits computer science and information technology degrees.
Credit at a fraction of the priceThe same 3 credits can cost $750 or more at a US college. Here it is one payment, self-paced, with lifetime access.
Finish your degree soonerTransfer credits reduce the courses you still owe, so you can graduate earlier or lighten a heavy semester.
Strengthen an applicationA completed college-level course on an official transcript shows admissions and scholarship committees you can do the work.
Study on your own scheduleNo start dates, no deadlines. Watch the lessons, practice, and take the final when you are ready.
130,000+students helped with college creditsACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

Where the credit goes

Universities that work with NCCRS

Introduction to Operating Systems carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.

FAQ

Questions students ask us

About The Storage Beneath File Systems

What is the difference between a sector and a block?
A sector is the drive's smallest physical slot, while a block, also called a cluster, is a group of sectors that the file system hands out as one unit. Sectors are classically 512 bytes, and many modern drives use 4,096-byte physical sectors. A common block size is 4,096 bytes, which equals eight 512-byte sectors.
How do you calculate wasted space in a file system block?
Divide the file size by the block size, round up to get the number of blocks, then subtract the file size from the space those blocks reserve. With 4,096-byte blocks, a 10,000-byte file needs three blocks, reserving 12,288 bytes and wasting 2,288. A one-byte file still reserves a whole block, so many tiny files can waste a lot of space.
What does formatting a drive actually do?
Formatting writes the starting structures of a file system into a partition, creating the empty records that will track names, folders and the blocks each file uses. Before formatting, a partition cannot hold files. A quick format writes fresh empty records but may leave old bytes on the drive, so it is not a reliable way to erase secrets or to recover lost files.
What does it mean to mount a drive?
Mounting a drive attaches its file system to a folder in the existing file tree, called the mount point, so its files appear like ordinary folders. Windows shows a mounted drive as a letter such as D, a Mac lists it under /Volumes, and Linux often places it under /media. Ejecting, or unmounting, finishes pending writes first so nothing is left half-written.

About the Introduction to Operating Systems course

How many college credits is Introduction to Operating Systems?
Introduction to Operating Systems (Computer Science 354) carries a NCCRS credit recommendation for 3 semester credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
How much does Introduction to Operating Systems cost and what is included?
$250, paid once, with lifetime access: all 83 video lessons, a practice quiz after each, the graded work and final exam, and an official transcript when you finish. Students who want several courses choose UPI Study PRO instead.
Which universities accept UPI Study credits?
UPI Study has signed partner agreements with universities such as Thomas Edison State University, University of the People and Charter Oak State College, and works with universities such as Penn State, SNHU and SUNY. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities. Use "Find my college" on this page to check yours.
How long does Introduction to Operating Systems take?
It is self-paced with no deadlines. The 83 lessons total about 10 hours of video; most students add reading and practice time and finish in a few weeks to a few months, on their own schedule.
How are the exams done?
Quizzes and assignments are online in the course. The final exam is taken online with proctoring; a person on the UPI Study team checks assignments, usually within two days.
How do my credits reach my college?
When the course shows 100% complete, request the official transcript from your dashboard. It is sent to the college you name, and you can send it to more than one. Check your college first with "Find my college" on this page, or ask Athena.

Ready for the full course? Earn 3 credits in Introduction to Operating Systems.

83 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.

Updated

Introduction to Operating Systems
3 credits · NCCRS
Enroll →