In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "the usage of Linux basic command mke2fs". In daily operation, I believe many people have doubts about the usage of Linux basic command mke2fs. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "the usage of Linux basic command mke2fs"! Next, please follow the editor to study!
Mke2fs
Create ext2, ext3, ext4 file systems on disk partitions, and ext2 is created by default. The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.
1. Grammar
Mke2fs [option] [device]
Mke2fs [- c |-l filename] [- b block-size] [- f fragment-size] [- g blocks-per-group] [- G number-of-groups] [- I bytes-per-inode] [- I inode-size] [- j] [- J journal-options] [- K] [- N number-of-inodes] [- n] [- m reserved-blocks- percentage] [ -o creator-os] [- O feature [ [- Q] [- r fs-revision-level] [- E extended-options] [- v] [- F] [- L volume-label] [- M last-mounted-directory] [- S] [- t fs-type] [- T usage-type] [- U UUID] [- V] device [blocks-count]
Mke2fs-O journal_dev [- b block-size] [- L volume-label] [- n] [- Q] [- v] external-journal [blocks-count]
Device is a special file corresponding to the device (for example: g/dev/hdXX). Blocks-count is the number of blocks on the device. If omitted, mke2fs automatically configures the size of the file system. If the call is mkfs.ext3, a journal is created as if the "- j" option was specified. The default values for newly created file system parameters (if not overridden by the options listed below) are controlled by the "/ etc/mke2fs.conf" configuration file.
2. List of options
Option
Description
-V
Display command version information
-b block-size
Specifies the size of the block on the file system (kb), with valid values of 1024, 2048, 4096. If omitted, the block size is determined by the file system size and expected file system usage (see the-T option). If the block size is negative, mke2fs uses heuristics to determine the appropriate block size while limiting the block size to at least block-size bytes. This is useful for some hardware devices that require multiples of the block size of 2k.
-c
Bad track detection. If this option is specified twice, a slower read-write test is used instead of a fast read-only test.
-E extended-options
Set extension options for the file system. Extension options are comma-separated and can be copied using an equal sign. In earlier versions of mke2fs, the "- E" option used to be "- R". For backward compatibility, the "- R" option is still accepted. The following extension options are supported:
1) stride=stride-size. Use stride-size blocks to configure the RAID array, which is the number of blocks read or written to disk before moving to the next disk, sometimes referred to as block size. This mainly affects where file system metadata is stored in mke2fs to avoid placing it on a single disk, which may affect performance. The block allocator may also use it.
2) stripe-width=stripe-width. Use stripe-width blocks to configure the RAID array, which is usually stride-size * n, where N is the number of data disks contained in RAID (for example, for RAID 5, there is a parity disk, so N will be the number of disks in the array minus 1), which allows the block allocator to prevent parity in RAID from being modified when writing data.
3) resize=max-online-resize. Leave enough space so that the block group descriptor can grow to support file systems with online block resizing.
4) lazy_itable_init [=]. If enabled and the uninit_bg feature is also enabled, the inode table will not be fully initialized by mke2fs. This significantly speeds up the initialization of the file system, but it requires the kernel to initialize the file system in the background when the file system is mounted for the first time. If the option value is omitted, the default is 1 to enable delayed inode initialization.
5) test_fs. Set a flag in the filesystem superblock to indicate that it can be mounted using experimental kernel code such as the ext4dev filesystem.
6) discard. Try to discard blocks on mkfs (useful in solid-state devices and sparse / sparse Provi-Sied storage). When the device advertises discarded data, it marks all inode tables that have not yet been zeroed to zero. This greatly speeds up the initialization of the file system. This setting is the default.
7) nodiscard. Blocks are not discarded during mkfs.
-f fragment-size
Sets the size of the file system fragment. Mke2fs accepts the "- f" option, but currently ignores it because the second extended file system does not yet support fragments
-F
Forces mke2fs to create a file system, even if the specified device is not a partition on a block special device, or other parameters are meaningless. Since this instruction is dangerous, it must be confirmed twice.
-g blocks-per-group
Specifies the number of blocks in the block group. Users usually have no reason to set this parameter because the default setting is best for the file system. Developers who develop test cases usually use this option.
-G number-of-groups
Specifies the number of groups that will be packaged together to create larger virtual block groups. The number of groups must be a power of 2 and can only be specified when the Flex_BG file system feature is enabled.
-I bytes-per-inode
Mke2fs creates an inode for each inode byte on disk. The higher the bytes/inode ratio, the less inode is created. This value should generally not be less than the block size of the file system, because in this case, more inode will be generated than ever before. It is not possible to extend the number of inode on a file system after it is created, so be careful to determine the correct value of this parameter.
-I inode-size
Specifies the size of each inode in bytes. Mke2fs creates a 256byte inode by default. In kernels after 2.6.10 and in some earlier vendor kernels, inode storage extension attributes larger than 128 bytes can be used to improve performance. The inode table consumes, which reduces the free space in the file system and has a negative impact on performance. The extended attributes stored in a large inode are not visible in the old kernel, and such a file system cannot be mounted with the 2.4 kernel at all. It is not possible to change this value after the file system is created.
-j
Create an ext3 file system. If the "- j" option is not specified, the default log parameter is used to create logs of the appropriate size stored in the file system
-J journal-options
Create ext 3 logs using the options specified on the command line. Options are comma-separated and can be assigned to parameters using an equal sign. The following two parameters are supported, and only one of them can be specified.
Size=journal-size . Specifies the size of the internal log in MB. The size of the log must be at least 1024 file system blocks (1MB if 1k blocks are used, 4MB if 4k blocks are used), and may not exceed 102400 file system blocks.
Device=external-journal . To attach a file system to a log block device located at the specified "external-journal", "external-journal" must have been created with the following command: mke2fs-O journal_dev external-journal. Note that "external-journal" must have the same block size as the new file system. In addition, although multiple file systems are supported for attaching to a single "external-journal", the linux kernel and e2fsck (8) do not currently support sharing "external-journal".
-K
Keep, do not attempt to discard blocks during mkfs
-l filename
Read the disk bad block information from the file. Note that the block size used by mke2fs must be used to generate the block number in the list of bad blocks. Therefore, the-c option of mke2fs is a much simpler and less error-prone way to check for error blocks before formatting the disk, because mke2fs will automatically pass the correct parameters to the bad block program.
-L new-volume-label
Set the file system volume label, up to 16 bytes
-m reserved-blocks-percentage
Specifies the percentage of file system blocks reserved for the superuser. This avoids fragmentation and allows root useful daemons, such as syzabd (8), to continue to run correctly after unprivileged processes are prevented from writing to the file system. The default percentage is 5%.
-M last-mounted-directory
Set the last mount directory of the file system. Some utilities can select keys from the last mount directory to determine where the file system should be installed.
-n
Instead of creating a file system, demonstrate what to do when creating a file system
-N number-of-inodes
Override the default value of the number of inode that should be reserved for the file system.
-o creator-os
Overrides the default value of the creator operating system field of the file system. By default, the creator field is set to the name of the operating system compiled by mke2fs.
-O feature [,...]
Creates a file system with the given functionality (file system options), overriding the default file system options. The features enabled by default are specified by the base_features relationship, either in the [defaults] section of the / etc/mke2fs.conf configuration file, or in the [fs_type] section of the usage type specified by the-T option, and the usage type is further modified by the property relationship in the [fs_types] sub-section of the file system.
The file system property set is further edited using the property set specified by this option, or, if this option is not given, by the default_features relationship of the file system type being created, or in the [defaults] section of the configuration file.
The file system feature set consists of a series of comma-separated features to enable. To disable a feature, simply insert a caret ('^') before the feature name. The pseudo file system feature "none" clears all file system functions. A feature can be the following:
1) dir_index. Use hashed b-trees to speed up lookups in large directories
2) extent. Use inter-extent blocks to store the location of data blocks in the inode. This is a more efficient encoding that speeds up access to the file system, especially for large files.
3) filetype. Store the file type information in the directory entry.
4) flex_bg. Allows each block group metadata (assigned bitmaps and inode tables) to be placed anywhere on the storage media. In addition, mke2fs puts each block group metadata in the first block group of each "flx_bg group". You can use the-G option to specify the size of the flx_bg group.
5) has_journal. Create ext 3 logs, the same as the "- j" option.
6) journal_dev. Create external ext 3 logs on a given device instead of a regular ext 2 file system.
7) large_file. A file system can contain files larger than 2GB. (when you create a file > 2GB, the modern kernel automatically sets this feature.)
8) resize_inode. Space is reserved so that the block group descriptor table may grow in the future. Useful for online resizing using regze2fs. By default, mke2fs will try to reserve enough space so that the file system can grow to 1024 times its original size.
9) sparse_super. Create a file system with fewer SuperBlock backups (saving space on large file systems).
10) uninit_bg. Create a file system without initializing all the block groups. This feature also allows the checksum function, as well as highest-inode-used statistics in each block group. This feature can significantly speed up file system creation time (if lazable_init is enabled) and greatly reduce e2fsck time. It is only supported by the recent ext 4 file system in the Linux kernel.
-Q
Execute silently, usually in script files.
-r revision
Set the file system revision number for the new file system.
-S
Write only super blocks and group descriptors. This is useful if all super blocks and backup super blocks are damaged and a final recovery method is needed. It causes mke2fs to reinitialize super blocks and group descriptors without touching inode tables, blocks, and inode bitmaps. The e2fsck program should run immediately after using this option, and there is no guarantee that any data will be salvaged. It is critical to specify the correct file system block size when using this option, otherwise recovery is not possible.
-t fs-type
Specifies the file system type, which defaults to ext2. This option controls which file system options are used by default based on the fstypes configuration section in "/ etc/mke2fs.conf (5)"
If you use the "- O" option to explicitly add or remove file system options that should be set in the newly created file system, the requested fs-type may not support the resulting file system. (for example, "mke2fs-t ext3-O extents / dev/sdXX" will create a file system that is not supported by the ext3 implementation. "" mke2fs-t ext3-O ^ has _ journal / dev/hdXX "will create a file system without logs, so the ext3 file system code in the Linux kernel will not support the file system.)
-T usage-type [,...]
Specify how the file system is used so that mke2fs can choose the best file system parameters. The supported usage-type is defined in the configuration file "/ etc/mke2fs.conf (5)". Users can specify one or more usage-type using a comma-separated list.
-U
Create a system with the specified UUID
-v
Show detailed execution process
3. Examples
Create an ext2 file system
[root@localhost ~] # mknod / dev/sdb4 b 1 1 / / create a device
[root@localhost ~] # mke2fs / dev/sdb4 / / create a file system. No type is specified. Default is ext2.
Mke2fs 1.41.12 (17-May-2010)
File system label =
Operating system: Linux
Block size = 1024 (log=0)
Chunk size = 1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
4096 inodes, 16384 blocks
819 blocks (5.00%) reserved for the super user
First data block = 1
Maximum filesystem blocks=16777216
2 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193
Writing inode table: complete
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first. Use tune2fs-c or-i to override.
[root@localhost ~] # mount / dev/sdb4 / media/disk / / Mount the file system
[root@localhost ~] # df-T / / View the file system already in use
Filesystem Type 1K-blocks Used Available Use% Mounted on
/ dev/mapper/VolGroup-lv_root ext4 25552764 13250844 11003900 55%
Tmpfs tmpfs 829656 829388 829388 / dev/shm
/ dev/sda1 ext4 495844 32996 437248 8% / boot
/ dev/sr0 iso9660 56618 56618 0 / media/VBox_GAs_5.2.18
/ dev/sdb1 vfat 15863 140 14904 / media/disk
/ dev/sdb4 ext2 15863 140 14904 / media/disk / / you can see that this is the ext2 type
At this point, the study of "the usage of the Linux basic command mke2fs" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.