Chapter 3 The File System

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 34

Chapter three

THE FILE SYSTEM

11/07/2022 1
Contents
What is file system
Types of file system

11/07/2022 2
File System
File system is a method for storing and organizing computer files
and the data they contain to make it easy to find and access
them.
Most file systems make use of an underlying data storage device
such as Hard Disks that offers access to an array of fixed-size
blocks which is the smallest logical amount of disk space that can
be allocated to hold a file.
File systems typically have directories which associate file names
with files, usually by connecting the file name to an index in a file
allocation table of some sort, such as the FAT in a DOS file
system, or an incode in a Unix-like file system.
11/07/2022 3
File System
File names are simple strings, and per-file Metadata is
maintained which is the bookkeeping information, typically
associated with each file within a file system.
Metadata could contain file attributes such as file size, data
and time of creation or modification of the file, owner of the
file, access permissions etc.

11/07/2022 4
Types of File System
File system types can be classified into

disk file systems,


network file systems ()
flash file systems.
A disk file system is a file system designed for the storage of files on a data storage device, most
commonly a disk drive e.g. FAT, NTFS, etx2, ext3 etc.
A network file system is a file system that acts as a client for a remote file access protocol,
providing access to files on a server e.g. NFS(Network File System), SMB(Server Message Block) etc.
A flash file system is a file system designed for storing files on flash memory devices.

11/07/2022 5
File System and OS
Operating systems provide a file system, as a file system is an integral part of
any modern operating system.
Windows Operating system supports FAT and NTFS File Systems
Linux popularly supports ext2 and ext3 File Systems
Other flavors of Operating Systems may support other File Systems like UFS
in many UNIX Operating Systems and HFS in MAC OS X.
All Operating Systems provide a user interface like Command Line (CLI) or
File Browser to access and manage File System information.

11/07/2022 6
FAT DOS/Windows File System
The File Allocation Table (FAT) file system was initially developed for DOS
Operating System and was later used and supported by all versions of
Microsoft Windows.
It was an evolution of Microsoft's earlier operating system MS-DOS and
was the predominant File System in Windows versions like 95, 98, ME etc.
All the latest versions of Windows still support FAT file system although it
may not be popular.
FAT had various versions like FAT12, FAT16 and FAT32. Successive versions
of FAT were named after the number of bits in the table: 12, 16 and 32.

11/07/2022 7
Windows File System

NTFS New Technology File System


NTFS or the NT File System was introduced with the Windows NT operating
system.
NTFS allows ACL-based permission control which was the most important
feature missing in FAT File System.
Later versions of Windows like Windows 2000, Windows XP, Windows Server
2003, Windows Server 2008, and Windows Vista also use NTFS.
NTFS has several improvements over FAT such as security access control lists
(ACL) and file system journaling.

11/07/2022 8
File System in Linux
Linux supports many different file systems,
but common choices for the system disk include the ext family (such as ext2 and
ext3), XFS, JFS and Reiser FS.
The ext3 or third extended file system is a journaled file system and is the default
file system for many popular Linux distributions .
It is an upgrade of its predecessor ext2 file system and among other things it has
added the journouling feature.
A journaling file system is a file system that logs changes to a journal (usually a
circular log in a dedicated area) before committing them to the main file system.
Such file systems are less likely to become corrupted in the event of power failure
or system crash.

11/07/2022 9
FAT
FAT == File Allocation Table
FAT is located at the top of the volume.
two copies kept in case one becomes damaged.
Cluster size is determined by the size of the volume.

11/07/2022 10
Volume size V.S. Cluster size
Drive Size Cluster Size Number of Sectors
--------------------------------------- -------------------- ---------------------------
512MB or less 512 bytes 1
513MB to 1024MB(1GB) 1024 bytes (1KB) 2
1025MB to 2048MB(2GB) 2048 bytes (2KB) 4
2049MB and larger 4096 bytes (4KB) 8

11/07/2022 11
FAT block indexing

11/07/2022 12
FAT Limitations
Entry to reference a cluster is 16 bit
Thus at most 2^16=65,536 clusters accessible.
Partitions are limited in size to 2~4 GB.
Too small for today’s hard disk capacity!
For partition over 200 MB, performance degrades rapidly.
Wasted space in each cluster increases.

Two copies of FAT…


 still susceptible to a single point of failure!

11/07/2022 13
FAT32
Enhancements over FAT
More efficient space usage
◦ By smaller clusters.
◦ Why is this possible? 32 bit entry…

More robust and flexible


◦ root folder became an ordinary cluster chain, thus it can be located anywhere
on the drive.
◦ back up copy of the file allocation table.
◦ less susceptible to a single point of failure.

11/07/2022 14
NTFS
MFT == Master File Table
◦ Analogous to the FAT

Design Objectives
1) Fault-tolerance
 Built-in transaction logging feature.
2) Security
 Granular (per file/directory) security support.
3) Scalability
 Handling huge disks efficiently.

11/07/2022 15
NTFS
Scalability
◦ NTFS references clusters with 64-bit addresses.
◦ Thus, even with small sized clusters, NTFS can map disks up to sizes that we
won't likely see even in the next few decades.
Reliability
◦ Under NTFS, a log of transactions is maintained so that CHKDSK can roll back
transactions to the last commit point in order to recover consistency within
the file system.
◦ Under FAT, CHKDSK checks the consistency of pointers within the directory,
allocation, and file tables.

11/07/2022 16
NTFS
It allows you to access files on remote hosts in exactly the same way
you would access local files.
NFS offers a number of useful features:
Data accessed by all users can be kept on a central host, with
clients mounting this directory at boot time.
For example, you can keep all user accounts on one host and
have all hosts on your network mount /home from that host.
If NFS is installed beside NIS, users can log into any system and
still work on one set of files.

11/07/2022 17
Cont..
Data consuming large amounts of disk space can be kept
on a single host.
For example, all files and programs relating to LaTeX and
METAFONT can be kept and maintained in one place.
Administrative data can be kept on a single host.
There is no need to use rcp to install the same stupid file
on 20 different machines.

11/07/2022 18
NTFS Metadata Files
Name MFT Description
$MFT Master File Table
$MFTMIRR Copy of the first 16 records of the MFT
$LOGFILE Transactional logging file
$VOLUME Volume serial number, creation time, and dirty flag
$ATTRDEF Attribute definitions
. Root directory of the disk
$BITMAP Cluster map (in-use vs. free)
$BOOT Boot record of the drive
$BADCLUS Lists bad clusters on the drive
$QUOTA User quota
$UPCASE Maps lowercase characters to their uppercase version

11/07/2022 19
NTFS : MFT record

11/07/2022 20
MFT record for directory

11/07/2022 21
Application~ File System Interaction
Process Open file
control table File descriptors
block (system-wide) (Metadata) File system
info
File
descriptors

Open Directories
file
pointer
..
array
.
File data

11/07/2022 22
open(file…) under the hood
1. Search directory structure fd = open( FileName, access)
for the given file path
2. Copy file descriptors into in-
memory data structure PCB Allocate & link up
data structures
3. Create an entry in system-
wide open-file-table
Open
Directory look up
4. Create an entry in PCB file
table by file path
5. Return the file pointer to
user
Metadata File system on disk

11/07/2022 23
read(file…) under the hood
read( fd, userBuf, size )
PCB
Find open file
descriptor
Open
file read( fileDesc, userBuf, size )
table
Logical  phyiscal

Metadata read( device, phyBlock, size )


Get physical block to sysBuf
Buffer copy to userBuf
cache
Disk device driver

11/07/2022 24
Types of Linux file systems

11/07/2022 25
1. Ordinary files
is a file on the system that contains data, text, or program
instructions.
Used to store your information, such as some text you have written
or an image you have drawn.
This is the type of file that you usually work with.
Always located within/under a directory file.
Do not contain other files.
In long-format output of ls -l, this type of file is specified by the “-”
symbol.

11/07/2022 26
2. Directories –
 Directories store both special and ordinary files.
For users familiar with Windows or Mac OS, UNIX directories are
equivalent to folders
A directory file contains an entry for every file and subdirectory
that it houses.
If you have 10 files in a directory, there will be 10 entries in the
directory.
Each entry has two components.
(1) The Filename
(2) A unique identification number for the file or directory
(called the inode number)
11/07/2022 27
3. Special Files –
Used to represent a real physical device such as a
printer, tape drive or terminal, used for Input/Ouput
(I/O) operations. 
Device or special files are used for device
Input/Output(I/O) on UNIX and Linux systems.

11/07/2022 28
4. Pipes
– UNIX allows you to link commands together using a
pipe.
The pipe acts a temporary file which only exists to hold
data from one command until it is read by another.
A Unix pipe provides a one-way flow of data.
The output or result of the first command sequence is
used as the input to the second command sequence.

11/07/2022 29
5. Sockets –
A Unix socket (or Inter-process communication socket) is
a special file which allows for advanced inter-process
communication.
A Unix Socket is used in a client-server application
framework. In essence, it is a stream of data, very similar
to network stream (and network sockets), but all the
transactions are local to the filesystem.
In long-format output of ls -l, Unix sockets are marked by
“s” symbol.
.
11/07/2022 30
6. Symbolic Link
Symbolic link is used for referencing some other file of the file
system.
Symbolic link is also known as Soft link.
It contains a text form of the path to the file it references.
To an end user, symbolic link will appear to have its own name, but
when you try reading or writing data to this file, it will instead
reference these operations to the file it points to.
If we delete the soft link itself , the data file would still be there.
If we delete the source file or move it to a different location,
symbolic file will not function properly
11/07/2022 31
Log files and syslog
Syslog is a way for network devices to send event messages
to a logging server – usually known as a Syslog server.
System logs deal primarily with the functioning of the
Ubuntu system, not necessarily with additional applications
added by users.
Examples include authorization mechanisms, system
daemons, system messages, and the all-encompassing
system log itself, syslog.

11/07/2022 32
.

11/07/2022 33
nde
The

11/07/2022 34

You might also like