Lecture03 File Systems
Lecture03 File Systems
Topic 3
2
Objectives
• List the basic functions common to all file systems
2
3
Fedora root
folders
Tanenbaum & Bo, Modern Operating
Systems:4th ed., (c) 2013 Prentice-
Hall, Inc. All rights reserved.
File Systems (1)
Essential requirements for long-term information storage:
1. It must be possible to store a very large amount of
information.
2. Information must survive termination of the process using
it.
3. Multiple processes must be able to access information
concurrently.
Tanenbaum & Bo, Modern Operating
Systems:4th ed., (c) 2013 Prentice-
Hall, Inc. All rights reserved.
File Systems (2)
Files
• In computing, abstractions are important:
• Processor processes
• Physical memory (virtual) address space
• Disk storage & management the file
• Files: logical units of information created by processes.
• A disk will usually contain thousands/millions of them
• Each one independent of the others
• Files model the disk
• Shield user from details of how/where information is stored and
how disks work.
• Files managed by OS.
• How they are structured, named, accessed, used,
protected, implemented, and managed major topics
• Part of OS dealing with files file system
CC216 Lecture 3 - File Systems 16
File system
• Can be understood from:
1. End-users’ perspective
2. Implementation (i.e. file system designers’) perspective.
• Earlier slides have explained a lot from the end user’s
perspective.
• Now, we cover both of them systematically.
CC216 Lecture 3 - File Systems 17
1. Naming
conventions
2. Two-part name
• Simplest
• Common in early PCs (only 1 user).
• World’s 1st supercomputer CDC 6600
had only 1 directory.
• Advantages:
• Keep software design simple.
• Locate files quickly for small
number of files.
• Good for simple embedded
devices, e.g. telephones, cameras
Implementing Files
• Most important issue: keep track of which disk blocks go
with which file.
• Various methods are used in different OSs.
• We examine a few of them in the coming slides:
• Contiguous Allocation
• Linked-List Allocation
• Linked-List Allocation Using a Table in Memory
• I-nodes
CC216 Lecture 3 - File Systems 44
Implementing Files
Contiguous Layout
• Simplest allocation scheme
• Stores each file as a contiguous run of disk blocks.
• 1-KB blocks 50-KB file allocated 50 consecutive blocks.
• 2-KB blocks 50-KB file allocated 25 consecutive blocks.
• Example shown in Fig next slide.
• 40 disk blocks starting with block 0 on the left.
• Initially, empty disk. Then file A written. Then B.
• Each file begins at start of new block.
• If a file size is really 3.5 blocks, space wasted at end of last block.
Implementing Files
Contiguous Layout
Implementing Files
Contiguous Layout (cont’d)
• Advantages
1. Simple to implement: keeping track of where a file’s blocks
remembering: disk address of first block and # blocks occupied by file.
2. Excellent read performance
• Only 1 seek needed (to first block).
• No more seeks or rotational delays after that data come in at full
bandwidth of the disk.
• Drawback
• Over course of time, disk becomes fragmented: the disk ultimately
consists of files and holes (see Fig).
• Compacting disk prohibitively expensive (moving millions of blocks).
• Reuse free space in the holes doable but impractical (whenever a new
file created, need to know its final size in order to choose hole of correct
size to place it in).
Implementing Files
Linked List Allocation
• Two files.
• File A uses blocks 4,7,2,10,12
• File B uses blocks 6,3,11,14
• Both chains terminated with
special marker (“-1”).
Figure 4-13. An
example i-node.
Implementing Files
I-nodes (cont’d)
• Problem with i-nodes
• If each one has room for fixed number of disk addresses, what
happens when a file grows beyond this limit?
• Solution
• Reserve last disk address not for a data block but instead for
address of a block containing more disk block addresses.
Implementing Directories
• Before file is read, must be opened.
• When file opened, OS uses path name supplied by user
to locate directory entry.
• Directory entry provides info needed to find disk blocks.
• This info may be:
• The disk address of entire file (with contiguous allocation)
• The number of the first block (both linked list schemes)
• The number of the i-node.
• Main function of directory system is to map ASCII
name of file onto info needed to locate the data.
Implementing Directories
Example: reading a file
• Assume you want to open “/foo/bar”, read and close it.
• For simplicity, assume its size is 4KB (i.e. 1 block).
• File system (FS) first needs to inode for the file “bar”
• to obtain some basic information about the file (permissions
info, file size, etc.).
• To do so, FS must be able to find the inode, but all it
has right now is the full pathname.
• FS must traverse pathname and locate desired inode.
• All traversals begin at the root of the file system, in the
root directory which is simply called “/”.
Implementing Directories
Example: reading a file (cont’d)
• Thus, first thing FS will read from disk is the inode of
the root directory.
• But where is this inode? To find an inode, we must
know its i-number. Usually, we find the i-number of a file
or directory in its parent directory; the root has no
parent (by definition).
• Thus, the root inode number must be “well known”; the
FS must know what it is when the file system is
mounted. In most UNIX file systems, the root inode
number is 2.
• Thus, to begin the process, the FS reads in the block
that contains inode number 2 (the first inode block).
Implementing Directories
Example: reading a file (cont’d)
• Once the inode is read in, FS can look inside of it to find
pointers to data blocks, which contain the contents of the
root directory.
• FS will read through these looking for an entry for foo
• Once found, FS will also have found the inode number of
foo (say it is 44) which it will need next.
• The next step is to recursively traverse the pathname until
the desired inode is found.
• FS reads the block containing the inode of foo and then
its directory data, finally finding the inode number of bar.
• Then contents of bar can be read from following pointers
to data blocks inside the inode of bar.
Tanenbaum & Bo, Modern Operating
Systems:4th ed., (c) 2013 Prentice-
Journaling File Systems Hall, Inc. All rights reserved.
FAT32
• Support for FAT32 started with Windows 95 Release 2
• Designed to accommodate larger capacity disks
• FAT32:
• Root folder does not have to be at the beginning of a volume
• Can use disk space more efficiently than FAT16 (because it uses
smaller cluster sizes)
• Largest volume that can be formatted is 32 GB
• Maximum file size is 4 GB
• Offers fast response on small 1 or 2 GB partitions
66
FAT64
• FAT64 is also known as exFAT
• Proprietary file system introduced by Microsoft for mobile
personal storage
• Good choice for USB flash devices that may store large
files (such as pictures, videos, etc…)
• Available in Service Pack 1 for Windows Vista, Windows
7, and Windows Server 2008, Mac OS X Snow Leopard
• Support is available for Linux from a third party
67
NTFS
• NTFS – dominant Windows file system for all Windows
operating systems starting with Windows 2000
• Uses a Master File Table (MFT) instead of FAT tables
• The MFT and related files take up about 1 MB of disk
space
• When a file is created, a record for that file is added to the
MFT
• Contains additional attributes such as security settings, ownership,
and permissions
68
NTFS
• The MFT record reflects the sequence of disk blocks that
a file uses
• It is possible to have multiple filenames that refer to the
same file
• A technique known as hard linking
• This feature is also available in UNIX/Linux file systems
• Windows Vista, Server 2008, and 7 use NTFS version 6
• Windows XP and Server 2003 use NTFS version 5
• Windows NT 4.0 used NTFS 4
69
NTFS
• Basic features of NTFS:
• Long filenames
• Built-in security features
• Better file compression than FAT
• Ability to use larger disks and files than FAT
• File activity tracking for better recovery and stability than FAT
• Portable Operating System Interface for Unix (POSIX) support
• Volume striping and volume extensions
• Less disk fragmentation than FAT
70
NTFS
• NTFS is equipped with security features that meet the US
government’s C2 security specifications
• Refers to high-level, “top-secret” standards for data protection,
system auditing, and system access
• Examples:
• System files can be protected so only the server administrator has
access
• A folder of databases can be protected with read access, but no
access to change data
• Public folder can give users in a designated group access to read
and update files, but not to delete files
71
NTFS
• Some files can be compressed by more than 40%, saving
disk storage for other storage needs
• NTFS has the ability to keep a log or journal of file system
activity (called journaling)
• Makes it possible for files to be restored in the event of a power failure
• NTFS supports volume striping
• A striped volume uses more than one physical hard disk to create a
bigger volume.
• Faster than simple volume because reads and writes happen across
multiple disks at the same time.
• Increased risk of catastrophic failure leading to data loss
• NTFS has hot fix capabilities
• If a bad disk area is detected, automatically copies the information to
another disk area that is not damaged
CC216 Lecture 3 - File Systems 72
NTFS
Summary
• When seen from the outside, a file system is a collection
of files and directories, plus operations on them.
• Files can be read and written, directories can be created
and destroyed, and files can be moved from directory to
directory.
• Most modern file systems support a hierarchical directory
system in which directories may have subdirectories and
these may have subsubdirectories ad infinitum.
• When seen from the inside, a file system looks quite
different. The file system designers have to be concerned
with how storage is allocated, and how the system keeps
track of which block goes with which file.
74
Chapter Summary
• Possibilities include contiguous files, linked lists, file-
allocation tables, and i-nodes.
• Different systems have different directory structures.
• Disk space can be managed using free lists or bitmaps.
• The main file systems used in Windows since Windows
2000 are extended FAT16, FAT32, and NTFS.
• NTFS is the native file system for Windows 2000 and after
with the advantage of better security, larger disk and file
sizes, better management tools, and greater stability than
FAT16 and FAT32.
• UNIX and Linux support many support many different file
systems but typically employ ufs or ext.
• ufs and ext use information nodes (inodes) to organize
information about files.