Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unix File System Internal Structures By C. Shing ITEC Dept Radford University.

Similar presentations


Presentation on theme: "Unix File System Internal Structures By C. Shing ITEC Dept Radford University."— Presentation transcript:

1 Unix File System Internal Structures By C. Shing ITEC Dept Radford University

2 Objectives Understand partition and file system Understand the file system components Understand the component structure Understand the difference between file and directory Understand how a new file is stored Understand how Unix search file through directory tree

3 Partition Partition: logically independent disk, accessed by own devices (SCSI disk supports 8 sd, IDE disk can have 4 hd) Example: Linux IDE w 400 cylinders: –3 Primary (/dev/hda[1-3]): cylinder 1-300 –1 Extend partitions(/dev/hda4): cylinder 301- 400, used up to logical partitions (replace.dev/had[5-63], can combine adjacent logical partitions)

4 File System A file system: has directory structure, created to store and retrieve data in files and directory (using disk blocks) Note: One file system is usually on one partition

5 File System Type Ext2, ext4: for Linux ufs: for SVR4 hsfs or iso9660: for CD-ROM msdos or pcfs: for DOS

6 Filesystem - Creation Unix commands: –mkfs ext2 /dev/fd0 construct a filesystem –format –t ext2 /dev/fd0 format, repair and analyze disk –fdisk /dev/fd0 create/modify disk partition table

7 System Components File System 1.Boot block: disk block #0 2.Super-block: disk block #1 3.Inode table: disk block #2 on 4.Data blocks: disk block # starts after inode table blocks

8 System Components – boot block (1 st Sector) contains MBR (Master Boot Record like in Windows)- 446 bytes –Contains bootstrap program & boot loader and disk partition table- 64 bytes Note: Boot up process: BIOS->run bootsrap(MBR) ->partition disk (partition table) ->select boot loader (CMOS) -> load kernel to disk

9 System Components – super-block Similar to Windows Boot Block –has boot loader A bitmap of blocks –1: block used –0: free block A bitmap of inode –1: inode used –0: inode block Note: newer system has super-block back- up to prevent system corruption

10 System Components – inode table List of inodes (index nodes): starts from inode #2 –Inode: 128 Bytes size, represents file, unique in a file system, contains 1.Meta-data 2.Direct block pointers: 10, points to data block 3.Indirect block pointers: 4GB> file size > 40K(for 4K block) 4.Double block pointers: file size > 4 GB 5.… Note: Inode #1 not used: bad block (location of un-usable blocks), prevent from allocating to other files

11 System Components – data block Store actual user data (contents of file)

12 File and Directory File: stream of bytes, represented by inode Directory: filenames and their location of inodes

13 File and Directory Example: –File: inode Meta-dataData Block location

14 File and Directory Example: –Directory: / NameInode Number.2..2 adminrootfile100 /usr32704

15 Store New File When a new file is created, the file system will perform the following: 1.Find a free inode (from super-block) to store file properties 2.Find a free block (from super-block) to store the file contents from Kernel buffer 3.Store the block number in the inode 4.Puts filename and the inode number in the current directory

16 Directory/File Traversal 1.Starts from / (. has inode #2) 2.Find the subdirectory name 3.Find its inode number and its block number 4.Go to the block 5.Go back to step 2, until filename is found

17 Reference Ch. 14: Unix Internals


Download ppt "Unix File System Internal Structures By C. Shing ITEC Dept Radford University."

Similar presentations


Ads by Google