OS-File System

Source: Internet
Author: User

Information Storage: stores information in a unit, that is, files, on disks or other external media.

Files are managed by the operating system. The files managed in the operating system are called file systems.


From the user's perspective:

File Name

File structure

Three Common Methods

Non-structured byte sequence: the operating system does not care about what the file content is, but the operating system sees bytes. Any meaning is explained by the user program. Linux, UNIX, and Windows use this method.

Record sequence: a file is a record sequence with a fixed length. Each record has its internal structure. Few general operating systems are used.

Tree Structure: a file in this type of structure is composed of a tree record. Each record does not have to have the same length. The record has a key at a fixed position. This tree is sorted by keys. I don't know what operating system to use.

File Type

For example, common files, block device files, directory files, and character device files in Linux.

File Access, Sequential, random

File AttributesFor example, what are the permissions in Linux?

File OperationsSuch as creat, read, delete, etc.

Directory:

Level-1 Directory: contains all files in a directory. General operating systems seem to be rarely used.

Level-2 directory system: to avoid conflicts between different users who select the same name for their files, each user is provided with a private directory. It is rarely used.

Hierarchical Directory System: A directory system for Linux and Windows. This method is used in almost modern operating systems.

Path Name: Absolute path name and relative path.

Directory operations, Such as mkdir.


From the perspective of implementation:

The implementers are interested in how files and directories are stored and how disk space is managed.

File System layout

The file system is stored on the disk. A disk can be divided into one or more partitions. Each partition can have an independent file system, such as ext2, ext3, and NTFS.

The hard disk has 0 cylinders, 0 heads, and 1-sector names as the primary Boot Sector (MBR ).

It consists of three parts: the Main Boot Program, the hard disk partition table DPT (Disk
Partition Table) and hard disk valid identifier (55aa ). In a 512-byte primary Boot Sector
Loader) occupies 446 bytes, and the second part is the Partition Table area (Partition Table), that is, DPT, which occupies 64 bytes. The number of partitions in the hard disk and the size of each partition are recorded in this section. The third part is magic number, which occupies 2 bytes and is fixed to 55aa. Partition Table (DPT, disk
Partition Table) contains four partition items, the offset address 01beh--01fdh, each partition table item is 16 bytes long, A total of 64 bytes are partition item 1, partition item 2, partition item 3, and partition item 4.

When a computer is booted, the BIOS reads and executes MBR. The first part of MBR determines the active partition and reads the first part of MBR, which is called the boot block and runs it. The program in the boot block loads the operating system in the partition.

Each partition has a boot block, whether or not it contains an operating system.

File implementation

A \ continuous allocation. Store each file as a continuous data block on the disk. Easy to implement and high read performance. There will be a lot of fragments. In modern operating systems, disk file systems are rarely used; cd_rom, DVD, and other storage media are continuously allocated.

B \ linked list allocation. Component disk block linked list for each file. The first byte of each block points to the next disk block of the file. Sequential reading of blocks slows down random reading and slows down fragmentation issues.

C \ I node, inode. Linux and UNIX methods. Each file has an inode data structure.

Directory implementation

The main function of a directory is to map the file name to the information required to locate the file, and also include the file attributes.

Disk Space Management

There are two policies for storing n Bytes of Files: allocating continuous disk space or splitting files into multiple consecutive blocks.

Almost all file systems divide files into fixed block sizes for storage, and each block is not necessarily adjacent.

1. Block Size Selection: slice, track, and cylinder.

It is too large, a waste of space, and too small. Each file is composed of multiple parts, each of which has a seek and rotation delay time.

2. Record idle blocks. two common methods

First, the disk block chain table is used to record multiple idle disk block numbers in each block.

Second: bitmap. If I remember correctly, ext2 should be used.


File System Performance

Cache.

Block read ahead.

Reduce the seek time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.