the file system
DESCRIPTION
The File System. Linux File System. Linux supports 15 file systems ext, ext2, xia, minix, umsdos, msdos, vfat, proc, smb, ncp, iso9660, sysv, hpfs, affs and ufs The separate file systems are combined into a single hierarchical tree structures mount on a directory (mount point). - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/1.jpg)
1
The File System
![Page 2: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/2.jpg)
2
Linux File System
• Linux supports 15 file systems
– ext, ext2, xia, minix, umsdos, msdos, vfat, proc, smb, ncp, iso9660, sysv, hpfs, affs and ufs
• The separate file systems are combined into a single hierarchical tree structures
– mount on a directory (mount point)
![Page 3: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/3.jpg)
3
Virtual File System
• Disks are initialized into logical partitions
• Each partition may hold a single file system
– EXT2
• The real file systems are separated from the operating system by an interface layer: Virtual File System
![Page 4: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/4.jpg)
4
The Second Extended File System (EXT2)
• File : data blocks
• inode : describe which blocks the data within a file occupies, access rights, modification time,…
• directory : special file which contains pointers to the inodes
![Page 5: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/5.jpg)
5
Physical Layout of EXT2
![Page 6: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/6.jpg)
6
The EXT2 Inode
![Page 7: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/7.jpg)
7
The EXT2 Inode
• Mode
– what this inode describes (file, directory, symbolic link, FIFO,…) and the permissions
• Owner Information
– user and group ids of the owners
• Size
![Page 8: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/8.jpg)
8
The EXT2 Inode
• Timestamps
– creation and modification
• Datablocks
![Page 9: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/9.jpg)
9
The EXT2 Superblock
• Basic size and shape of the file system– Magic Number :0xEF53– Revision Level– Mount Count and Maximum Mount Count– Block Group Number– Block Size– Block per Group
![Page 10: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/10.jpg)
10
The EXT2 Superblock
• Basic size and shape of the file system
– Blocks per Group
– Free Blocks
– Free Inodes
– First Inode
![Page 11: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/11.jpg)
11
The EXT2 Group Descriptor
• Block Bitmap
• Inode Bitmap
• Inode Table
• Free blocks count, Free inodes count, Used directory count
![Page 12: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/12.jpg)
12
EXT2 Directory
![Page 13: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/13.jpg)
13
Finding a File in an EXT2 File System
• /home/rusling/.cshrc
• system parse the filename a directory at a time until we get the file
![Page 14: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/14.jpg)
14
Changing the Size of a File in an EXT2 File System
• Lock EXT2 Superblock
• Check if there are preallocated blocks
• EXT2 allocate new block
– data block after the last block of the file
– data blocks within 64 blocks of the idea block
– data block in the same Block Group
![Page 15: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/15.jpg)
15
Changing the Size of a File in an EXT2 File System
– All of the other Block Groups in turns (allocate a cluster of eight blocks)
• Update the Block Group’s block bitmap and allocate a data buffer in the buffer cache
• Mark the superblock as “dirty” and unlock
![Page 16: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/16.jpg)
16
The Virtual File System(VFS)
![Page 17: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/17.jpg)
17
The VFS Superblock
• Device
• Inode pointers
• Blocksize
• Superblock operations
• File System Type
• File System specific
![Page 18: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/18.jpg)
18
The VFS Inode
• Device• Inode Number• Mode• User id• times• block size• inode operations
– a pointer to a block of routine addresses
• count• lock• dirty• file system specific
![Page 19: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/19.jpg)
19
Registering the File Systems
• Build Linux kernel : supported file systems
• Build file systems as modules
– load by ismod
![Page 20: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/20.jpg)
20
Mounting a File System
• $mount -t iso9600 -o ro /dev/cdrom /mnt/cdrom
• Search for the file system types( iso9600)
• Allocate a VFS superblock and pass it the mount information to the superblock read routine
![Page 21: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/21.jpg)
21
A Mounted File System
![Page 22: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/22.jpg)
22
Umount a File System
• Check whether someone is using the FS
• Check if the FS is dirty
– write back
• Return VFS superblock to kernel’s pool
• vfsmount is unlinked from vfsmntlist
![Page 23: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/23.jpg)
23
Speedup Access
• VFS Inode Cache
• Directory Cache
![Page 24: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/24.jpg)
24
The Buffer Cache
![Page 25: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/25.jpg)
25
The States of the Cache
• Clean :Unused, new buffers,
• Locked
– Buffers that are locked, waiting to be written,
• Dirty
– Dirty buffers. These contain new, valid data, and will be written but so far have not been scheduled to write,
![Page 26: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/26.jpg)
26
The States of the Cache
• Share
– Shared buffers,
• Unshared
– Buffers that were once shared but which are now not shared, clean :Unused, new buffers,
![Page 27: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/27.jpg)
27
The bdflush Kernel Daemon
• The bdflush kernel daemon is a simple kernel daemon that provides a dynamic response to the system having too many dirty buffers (default :60%)
• The value can be seen and changed using update command (a daemon)
![Page 28: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/28.jpg)
28
The /proc File System
• It does not really exist
• Presents a user readable windows into the kernel’s inner workings
![Page 29: The File System](https://reader033.vdocuments.net/reader033/viewer/2022051821/568150a8550346895dbeb887/html5/thumbnails/29.jpg)
29
Devices Special Files
• Hardware devices
• character and block devices
• device drivers
– major number, minor number