file system and file allocation tables

25
File allocation table(FAT) PREPARED BY: DAVE SUSHILKUMAR A. PABARI SHASHIKANT C. PAMBHAR VISHAL G.

Upload: shashikant-pabari

Post on 08-Aug-2015

107 views

Category:

Engineering


0 download

TRANSCRIPT

Page 1: File System and File allocation tables

File System & File allocation table(FAT)

PREPARED BY:

DAVE SUSHILKUMAR A.PABARI SHASHIKANT C.PAMBHAR VISHAL G.

Page 2: File System and File allocation tables

2File System

The collection of algorithms and data structures which perform the translation from logical file operations (system calls) to actual physical storage of information.

Page 3: File System and File allocation tables

3What Does a File System Do?

Responsibilities

Creating, manipulating, renaming, copying, and removing files to and from a storage device

Organizing files into common storage units

Called directories

Keeping track of file and directory locations

Assisting users

Relate files and folders to the physical structure of the storage medium

Page 4: File System and File allocation tables

4 Files used by operating systems and applications

Word-processing documents

Source code for programs you have written

Music files

Movie files

Spreadsheets

Photos

Operating systems use a file folder icon to represent a directory

Page 5: File System and File allocation tables

5Layered File System

Logical File System Maintains file structure via FCB

(file control block)

File organization module Translates logical block to physical

block

Basic File system Converts physical block to disk

parameters (drive 1, cylinder 73, track 2, sector 10 etc)

I/O Control Transfers data between memory

and disk

Page 6: File System and File allocation tables

6Physical Disk Structure Parameters to read from disk:

cylinder(=track) #

platter(=surface) #

sector #

transfer size

Tracks

Sectors within a

Track

Cluster

Page 7: File System and File allocation tables

7File system Units Sector – the smallest unit that can be accessed on

a disk (typically 512 bytes)

Block(or Cluster) – the smallest unit that can be allocated to construct a file

What’s the actual size of 1 byte file on disk? takes at least one cluster,

which may consist of 1~8 sectors,

thus 1byte file may require ~4KB disk space.

Page 8: File System and File allocation tables

8Sector~Cluster~File layout

Page 9: File System and File allocation tables

9FCB – File Control Block Contains file attributes + block locations

Permissions

Dates (create, access, write)

Owner, group, ACL (Access Control List)

File size

Location of file contents

UNIX File System I-node

FAT/FAT32 part of FAT (File Alloc. Table)

NTFS part of MFT (Master File Table)

Page 10: File System and File allocation tables

10File System Implementation

Contiguous allocation Linked list allocation Linked list allocation using an index (DOS file allocation table - FAT)

Page 11: File System and File allocation tables

11Contiguous Allocation The file is stored as a contiguous block of data

allocated at file creation

(a) Contiguous allocation of disk space for 7 files

(b) State of the disk after files D and E have been removed

Page 12: File System and File allocation tables

12Contiguous Allocation (Cont.) FAT (file allocation table) contains file name, start block, length

Advantages Simple to implement (start block & length is enough to define a file) Fast access as blocks follow each other

Disadvantages Fragmentation Re-allocation (compaction)

Page 13: File System and File allocation tables

13Linked List Allocation The file is stored as a linked list of blocks

Page 14: File System and File allocation tables

14Linked List Allocation (Cont.)

Each block contains a pointer to the next block FAT (file allocation table) contains file name, first block address Advantages

Fragmentation is eliminated Block size is not a power of 2 because of pointer space

Disadvantages Random access is very slow as links have to be followed

Page 15: File System and File allocation tables

15Indexed Block Allocation

Indexed allocation

Each file has its own index block(s) of pointers to its data blocks

Logical view

index table

Page 16: File System and File allocation tables

16Indexed Allocation (Cont.) Need index table

Random access

Dynamic access without external fragmentation, but have overhead of index block

Mapping from logical to physical in a file of maximum size of 256K bytes and block size of 512 bytes. We need only 1 block for index table

Q = displacement into index tableR = displacement into block

LA/512Q

R

Page 17: File System and File allocation tables

17Indexed Allocation – Mapping (Cont.)

Mapping from logical to physical in a file of unbounded length (block size of 512 words)

Linked scheme – Link blocks of index table (no limit on size)

LA / (512 x 511)Q1

R1

Q1 = block of index tableR1 is used as follows:

R1 / 512Q2

R2

Q2 = displacement into block of index tableR2 displacement into block of file:

Page 18: File System and File allocation tables

18Indexed Allocation – Mapping (Cont.)

Two-level index (4K blocks could store 1,024 four-byte pointers in outer index -> 1,048,567 data blocks and file size of up to 4GB)

LA / (512 x 512)Q1

R1

Q1 = displacement into outer-indexR1 is used as follows:

R1 / 512Q2

R2

Q2 = displacement into block of index tableR2 displacement into block of file:

Page 19: File System and File allocation tables

19File Allocation Table

FAT File System

• The File Allocation Table (FAT) file system is a simple file system originally designed for small disks and simple folder structures.

• The FAT file system is named for its method of organization, the file allocation table, which resides at the beginning of the volume.

• To protect the volume, two copies of the table are kept, in case one becomes damaged. In addition, the file allocation tables and the root folder must be stored in a fixed location so that the files needed to start the system can be correctly located.

• A volume formatted with the FAT file system is allocated into clusters.

• The default cluster size is determined by the size of the volume.

• For the FAT file system, the cluster number must fit in 16 bits and be a power of 2.

FAT File System

Page 20: File System and File allocation tables

20• The way FAT works is that it keeps a record at the start of the drive of all

the files, and to point to the files, it points to the clusters that contain the files.

• The main rule of clusters is that there cannot be more than 1 file per cluster; otherwise, pointing to that cluster would cause problems, as it would be pointing and doing read/write operations on two files at once, which would cause Windows to crash.

• Depending on the size and FAT version of the partition, the cluster size can vary.

• Also keep in mind that a section of the partition is reserved for the FAT, which is the record of each file and where it can be found. This changes in size depending on the size of the partition and clusters.

How FAT Works

The FAT Family FAT12, FAT16, FAT32

12, 16, and 32 are the number of bits used in the FAT for cluster addresses

Page 21: File System and File allocation tables

21

FAT32 is a derivative of the File Allocation Table (FAT) file system that supports drives with over 2GB of storage. Because FAT32 drives can contain more than 65,526 clusters, smaller clusters are used than on large FAT16 drives. This method results in more efficient space allocation on the FAT32 drive.

The largest possible file for a FAT32 drive is 4GB minus 2 bytes.

The FAT32 file system includes four bytes per cluster within the file allocation table. Note that the high 4 bits of the 32-bit values in the FAT32 file allocation table are reserved and are not part of the cluster number.

FAT32 File System

Page 22: File System and File allocation tables

22 Creating a FAT File System High-level formatting creates file system data structures

Boot sector

Cluster allocation File Allocation Table (FAT)

$Bitmap in the Master File Table (MFT) for NTFS

Exact details depend on operating system

Root Directory

Page 23: File System and File allocation tables

23

Each FAT type has its limits; this table displays these limits:

FAT type Max Clusters Cluster sizes Max volume size

FAT12 4,086 0.5 to 4KB 16,736,256 bytes(16MB)

FAT16 65,526 2KB to 32KB 2,147,483,648 bytes(2GB)

FAT32 268,435,456 4KB to 32KB 8,796,093,022,208 bytes(8TB)

FAT Limitations

Page 24: File System and File allocation tables

24Deleted File RecoveryAll Cluster Pointers in the FAT are gone!

Option 1

Grab the next n-1 consecutive clusters.

Call it the file.

May have allocated or unallocated clusters from other files.

WinHex uses this option.

Option 2

Grab the next n-1 unallocated clusters using the FAT.

Call it the file.

May have unallocated clusters from other deleted files.

EnCase uses this option.

• Get the first cluster from the directory entry• Get size from directory entry• Calculate the number of clusters allocated

to the file, n.

Page 25: File System and File allocation tables

25

Than

k

You…

.