Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Cloud Computing Learning Route course syllabus Courseware: EXT2/3/4 File system

2025-03-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Cloud Computing Learning Route course outline Courseware: EXT2/3/4 File system:

Indexed file system

=

Basic structure of Ext3/Ext4 file system

Superblock: record the overall information of this file system, including the total amount, usage, remaining amount of inode/block, and the format of the file system, etc.

Inode: record the attributes of a file (the metadata metadata of a file). A file occupies an inode and records the block number in which the file data is located.

Block: actually stores the content of a file. If the file is too large, it will take up multiple block.

Without Superblock in Superblock, there is no filesystem.

Total amount of block and inode

Number of unused and used inode / block

The size of block and inode (block is 1, 2, 4K is 128bytes or 256bytes)

File system-related information such as the mount time of filesystem, the time when the data was last written, and the time of last check (fsck)

Each block group may contain superblock so that repairs can be made for superblock

Inode table: storing metadata for files

Permissions for the file (read/write/excute)

The owner / group of the document (owner/group)

The size of the file

File (ctime)

File (atime)

File (mtime)

Block number (pointer) where the contents of the file are recorded

Data block: stores the actual data of the file

View file system information

Dumpe2fs

[root@tianyun ~] # dumpe2fs / dev/sda2

Tune2fs

[root@tianyun ~] # tune2fs-l / dev/sda3

Tune2fs 1.39 (29-May-2006)

Filesystem volume name: yang

Last mounted on:

Filesystem UUID: 28459f88-87dc-4624-94a7-07b0f3eb2420

Filesystem magic number: 0xEF53

Filesystem revision #: 1 (dynamic)

Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery sparse_super

Default mount options: (none)

Filesystem state: clean

Errors behavior: Continue

Filesystem OS type: Linux

Inode count: 48960

Block count: 195312

Reserved block count: 9765

Free blocks: 183410

Free inodes: 48946

First block: 1

Block size: 1024

First inode: 11

Inode size: 128

Journal inode: 8

EXT2/EXT3/EXT4 journal file system

The process of creating a new file:

1. First determine whether the user has w and x permissions for the newly created file directory.

two。 Find the unused inode number according to inode bitmap, and write the permissions and attributes of the file to

3. According to block bitmap, find the unused block number, write the actual data of the file to block, and update the block pointing information of inode.

4. Synchronize the inode and block information you just wrote to update inode bitmap and block bitmap, and update the content of superblock.

Inconsistent (Inconsistent) state of the file

For example, sudden power outage, kernel error, and so on. The only information that can be written in this way is inode table and data block, the last step to synchronize updates.

If it is not done, there will be an Inconsistent between the content of the metadata and the actual information.

Journal file system (Journaling filesystem)

1. Preparation: when the system is about to write a file, it first records the information that a file is ready to write in the log area.

two。 Actual write: write permissions and data to the file, update metadata information

3. End: after updating the data and metadata, complete the recording of the file in the logging block.

Repair the file system fsck,e2fsck-fy

Case 1: the system cannot be started

Case 2: Read-only file system

If readonly appears in a partition of a running server, the process cannot write to the partition (for example, the nginx process cannot write log files to this partition)

Manually testing touch to this partition also shows: cannot touch 'xxxxx':Read-only file system), what should I do?

Solution: there are generally two reasons for disk read-only, one is caused by no normal shutdown, and the other is caused by hard disk failure.

If it is / partition, in this case, you can only go offline to repair the disk.

If it is a different partition, you can try to resolve this problem in three steps:

1. Unmount this partition first

two。 Then fsck.ext4-fy / dev/sdb1

3. Finally, mount the partition to check whether it can be read and written properly.

If you still can't read and write normally, please report to repair the disk.

Note: the above operation procedure, please ensure that the server does not provide services online.

Case 3: fix superblock

Find the backed-up superblock

[root@tianyun ~] # dumpe2fs-h / dev/datavg/lv1 | grep 'Blocks per group'

Dumpe2fs 1.42.9 (28-Dec-2013)

Blocks per group: 8192

Restore superblock with backed-up superblock

[root@tianyun] # fsck.ext4-b 8192 / dev/datavg/lv1

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report