anatomy of file_system
TRANSCRIPT
![Page 1: Anatomy of file_system](https://reader035.vdocuments.site/reader035/viewer/2022062515/55d745c8bb61eb847d8b4611/html5/thumbnails/1.jpg)
Anatomy of Filesystems..
![Page 2: Anatomy of file_system](https://reader035.vdocuments.site/reader035/viewer/2022062515/55d745c8bb61eb847d8b4611/html5/thumbnails/2.jpg)
Anatomy of Hardisks
“Platter” – A circular piece of magnetic material
Track 0
Track 1
“Tracks” – Platters divided into concentric circles
“Sector” – Each track is divided into sectors
Which store data, usually 512 bytesPlatter1,track0
Platter2,track0
Platter3,track0
Cylinder 0
Disk Controller.Does operations like read, write etc..
Read/Write Head 0
Read/Write data from Hardisk ?Read Cylinder
0,head 0,sector 0.
CHS Addressing
![Page 3: Anatomy of file_system](https://reader035.vdocuments.site/reader035/viewer/2022062515/55d745c8bb61eb847d8b4611/html5/thumbnails/3.jpg)
Anatomy of Communication
Hello
Communication in Humans:
Requirements:
• Speaker/Listener
• Voice/Language
• Medium: Air
Linda, Hello
• Addressing
![Page 4: Anatomy of file_system](https://reader035.vdocuments.site/reader035/viewer/2022062515/55d745c8bb61eb847d8b4611/html5/thumbnails/4.jpg)
Communicating with your Hardisk
Various communication standards exist to talk to our Harddisks:
Examples:• ATA• SCSI (Small Computer System Interface “Skuzzy”).
(NARROW SCSI)
Communication Requirements SCSI SpecificationSpeaker/Listener Initiator/Target Voice/Language SCSI Commands Medium SCSI Bus Addressing SCSI ID
![Page 5: Anatomy of file_system](https://reader035.vdocuments.site/reader035/viewer/2022062515/55d745c8bb61eb847d8b4611/html5/thumbnails/5.jpg)
SCSI Overview
CPUPCI -BusConverts:PCI -> SCSI
Initiator
Host Bus Adapter(HBA)8 Bit wide wires SCSI Bus
TargetID: 0
TargetID: 1
TargetID: 7
Logical Block Addressing (LBA) – A Data Addressing Standardization:
Track 0 Track 1Block 0/1 Block 2/3
Sector 0 Sector 1 Sector 0 Sector 1
SCSI Command
![Page 6: Anatomy of file_system](https://reader035.vdocuments.site/reader035/viewer/2022062515/55d745c8bb61eb847d8b4611/html5/thumbnails/6.jpg)
SCSI Communication in Action
OS:
CPU
Bus Adapter:Initiator
HBA: Give me Block 1, From Disk 0
Target Disk0ID 0
Hey, Disk 0, I Need your attention
Ok Bus, You have my attention
Thanks, READ LBA 2 for me
Ok, Here is LBA 2 Data: “Hello”Converts LBA 2 –> CHS 0/0/1
CPU: Your data “Hello”
CPU: Give me Block 1, from disk0
OS: your data, ”Hello”
![Page 7: Anatomy of file_system](https://reader035.vdocuments.site/reader035/viewer/2022062515/55d745c8bb61eb847d8b4611/html5/thumbnails/7.jpg)
FileSystems
Organize Scattered Data:
For FileSystems:
• Index(TOC) = Metadata
• Contents = Data
Visible part of Metadata:
![Page 8: Anatomy of file_system](https://reader035.vdocuments.site/reader035/viewer/2022062515/55d745c8bb61eb847d8b4611/html5/thumbnails/8.jpg)
FileSystems - Dig Deeper
FileSystem Blocks:
Sector 8
Block 8
Disk Block
SCSI Block (LBA)
FileSystem Block
Sector 0 Sector 1 Sector …
Block 0 Block 1 Block …
Block 0 (4Kb, Block size)
Fileystem layout on Disk:
Boot Block Block Group 0 Block Group… Block Group .. N
Block 0 Block 1 Block 2 Block 3 Block 4 Block N
![Page 9: Anatomy of file_system](https://reader035.vdocuments.site/reader035/viewer/2022062515/55d745c8bb61eb847d8b4611/html5/thumbnails/9.jpg)
FileSystems – Contd…
Block Group 0
Super Block
Group Descriptor Blocks..
InodeBlocks
Data Blocks … N
Block Groups:
Inodes :Every file or Directory will have a corresponding Inode, which contains information corresponding to the file or directory
Inode 1128 bytesInode 2
Inode …
Inode 32
Inode Block: OwnerMode (permission/Directory/File)
TimeStampAddress of 1st Data BlockAddress of 2nd Data Block
Address of Direct and Indirect Data Block
Entries in an Inode :
![Page 10: Anatomy of file_system](https://reader035.vdocuments.site/reader035/viewer/2022062515/55d745c8bb61eb847d8b4611/html5/thumbnails/10.jpg)
FileSystems – Contd…
OwnerMode (File)TimeStamp
Data Block 22Address of 2nd Data Block
Address of Direct and Indirect Data Block
File Inode :
Difference between file and directory Inode:
Hello World !
Data Block 22:
OwnerMode (Directory)
TimeStamp Data Block 50
Address of 2nd Data BlockAddress of Direct and Indirect Data Block
Directory Inode :
“File1” - 32“File2” - 36
Data Block 50:
![Page 11: Anatomy of file_system](https://reader035.vdocuments.site/reader035/viewer/2022062515/55d745c8bb61eb847d8b4611/html5/thumbnails/11.jpg)
FileSystems – Contd…
Free BlocksFree Inodes
Size Block Size etc..
SuperBlock :
Block Number of First InodeNo of free blocks in group
Group Descriptor :
Revisit the FileSystem Layout in Disk:
![Page 12: Anatomy of file_system](https://reader035.vdocuments.site/reader035/viewer/2022062515/55d745c8bb61eb847d8b4611/html5/thumbnails/12.jpg)
FileSystem in Action
Listing Contents of a file:
• Read the inode entry of / (Root directory)
• The root inode is fixed, inode entry 2 in the first inode block of the first blockgroup
Inode1 Inode2 Inode3 Inode4 Inode5 Block1 Block2 Block3 Block4 Block5
Root Inode
Mode (Directory)
Data Block 1
“Test” – Inode(3)“Bin” – Inode(4)
Test Inode
Mode (Directory)
Data Block 2“a” – Inode(5)
A Inode
Mode (File)
Data Block 3
“hello world”