Ubuntu mounts ext4 file system

1. The virtual machine allocates a 10G disk to mount the ext4 file system

insert image description here

insert image description here

insert image description here

insert image description here

insert image description here

2. Disk partition

fdisk /dev/sdb

insert image description here

insert image description here

3. Create a file system

mkfs.ext4 /dev/sdb1

insert image description here

When creating a file system, you can add options -b to specify blocksize, and -I to specify Inodesize.

mkfs.ext4 -b 1024 -I 1024 /dev/sdb1

insert image description here

4. Mount the file system

mount -t ext4 /dev/sdb1 /mnt/ext4

insert image description here

When mounting the file system, you can specify the journal optional:

insert image description here

About the journal optional:

  • The journal
    data=journal mode provides a complete log of data blocks and metadata blocks. All data will be written to the journal first, and then written to the disk (non-volatile storage medium after power failure). When the file system crashes, the log can be replayed to bring the data and metadata back to a consistent state. The performance of the journal mode is the lowest among the three modes, because all data needs to be recorded by the log.
  • ordered
    In the data=ordered mode, the ext4 file system only provides a log of metadata, but it logically groups metadata information and data blocks related to data changes into a unit called a transaction. When metadata needs to be written to disk, the data blocks associated with the metadata are written first. That is, the data is placed on the disk first, and then the metadata is logged. In general, the performance of this mode is slightly inferior to writeback but much faster than journal mode.
  • writeback
    In the data=writeback mode, when the metadata is submitted to the log, the data can be directly submitted to the disk. That is, the metadata log will be done, but the data will not be logged, and there is no guarantee that the data will be placed on the disk before the metadata. writeback is the best performance mode provided by ext4.

5. Unmount the file system

umount /mnt/ext4

insert image description here

6. Use ior to test ext4 three log modes

(1)ordered

insert image description here

The average write bandwidth bw is 330MiB/s, the average iops is 330, and the average delay is 0.04700s.
The average read bandwidth bw is 14000MiB/s, the average iops is 14000, and the average delay is 0.01200s.

(2)journal

insert image description here

The average write bandwidth bw is 280MiB/s, the average iops is 280, and the average delay is 0.05500s.
The average read bandwidth bw is 16700MiB/s, the average iops is 16700, and the average delay is 0.00950s.

(3)writeback

insert image description here

The average write bandwidth bw is 800MiB/s, the average iops is 800, and the average delay is 0.02000s.
The average read bandwidth bw is 16000MiB/s, the average iops is 16000, and the average delay is 0.01000s.

Writeback has the best performance, followed by ordered, and journal is the worst, which meets expectations.

Guess you like

Origin blog.csdn.net/weixin_43912621/article/details/131729367