Article directory
1. The virtual machine allocates a 10G disk to mount the ext4 file system
2. Disk partition
fdisk /dev/sdb
3. Create a file system
mkfs.ext4 /dev/sdb1
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
4. Mount the file system
mount -t ext4 /dev/sdb1 /mnt/ext4
When mounting the file system, you can specify the journal optional:
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
6. Use ior to test ext4 three log modes
(1)ordered
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
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
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.