Linux partition formatted

Format (format) refers to an operation to initialize a disk or a partition in the disk. This operation usually causes all files in the existing disk or partition to be erased. Formatting is usually divided into low-level formatting and high-level formatting. Unless otherwise specified, the formatting of the hard disk usually refers to advanced formatting. UUID will be generated after formatting.

1. Partition formatting commands supported by linux

CentOS7-1810 and Ubuntu18.04 support formatting commands

mkfs mkfs.cramfs mkfs.ext3 mkfs.fat mkfs .msdos mkfs.xfs
mkfs.btrfs mkfs.ext2 mkfs.ext4 mkfs.minix mkfs. vfat

formatting commands supported by openSUSE15

mkfs    mkfs.btrfs   mkfs.ext2   mkfs.ext4   mkfs.minix   mkfs.ntfs    mkfs.xfs    mkfs.xfs

Debian9.5 supported formatting commands
mkfs    mkfs.cramfs   mkfs.ext2   mkfs.ext4    mkfs.minix    mkfs.minix    mkfs.ntfs -size mkfs.bfs   mkfs.exfat    mkfs.ext3   mkfs.fat    mkfs.msdos   mkfs.vfat

II. Description of commonly used formatting commands

1, mkfs
mkfs is a front-end program for mkfs.fs-type, a special program for various file systems under Linux. mkfs itself does not perform the work of establishing the file system, but calls related programs to execute it. For example, if ext4 is specified in the “-t” parameter, then
mkfs will call mkfs.ext4 to create the file system. The mkfs command is part of the util-linux package.

Usage:
mkfs [Options] [Type] [Device]

Options:
-t, file system type; if not specified, ext2 will be used. If you want to know what file systems are supported behind -t, you can enter mkfs in the command line. After pressing the Tab key twice, several commands will be displayed Remove the mkfs in the front. The back is the supported file system. For example, mkfs.ext4 clearly supports the ext4 file system.

For example: format to ext4 file system
————————————————- ——
[[emailprotected] ~]# mkfs -t ext4 /dev/sdb1
< span style="font-size: 15px;">mke2fs 1.42.9 (28-Dec-2013)
File system tag=
OS type: Linux
block size=4096 (log=2)
Block size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
The first data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Allocating group tables: Complete
Writing to the inode table: Complete< br>Creating journal (8192 blocks): Complete
Writing superblocks and filesystem accounting information: Done #successful
————————— —————————-

Example: File system formatted as xfs
——————– ———————————–
[[emailprotected] ~]# mkfs -t xfs /dev/sdb1
mkfs.xfs: /dev/sdb1 appears to cont ain an existing filesystem (ext4). #Prompt that this partition already has an ext4 file system
mkfs.xfs: Use the -f option to force overwrite. #Use the -f option to force overwrite.
[[emailprotected] ~]# mkfs -t xfs -f /dev/sdb1
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=65536 blks
= sectsz= 512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=262144, imaxpct=25
= sunit=0 swidth=0 blks< /span>
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count =1
realtime =none extsz=4096 blocks=0, rtextents=0
[[email protected] ~]#
—————– ————————————- –

2, mke2fs
mke2fs command is a special tool used to manage ext series file system. There are also derivative commands like mkfs.ext2, mkfs.ext3, mkfs.ext4, etc. Their usage is similar to mke2fs, and their help manuals will directly jump to the help manuals of mke2fs commands under the system man. There are many options under this command for the needs of formatting features. There are many options for such a command. Here are just a few more to view through man mke2fs

Command format:

mke2fs [option] [device]

-t    specify the file system type (such as ext2, ext3, ext4, etc.), the default configuration will be read from the /etc/mke2fs.conf file;
-b   Set the block size of the hard disk.
-L    set volume label;
-j    create ext3 File system, mkfs.ext3 comes with this option;
-N    sets the number of inode nodes;
-m    is set as the percentage of the block reserved by the file system;
-c    before creating the file system Process hard disk self-check;
-U    Use the specified UUID to create the file system. The UUID must conform to his naming format. This option is very useful. The existing partition is formatted as the UUID of the previous partition.

Example: Create an ext4 file system and set the volume label to vname:
——————————————- ————
[[emailprotected] ~]# mke2fs -t ext4 -L vname /dev/ sdb1
mke2fs 1.42.9 (28-Dec-2013)
File system tag=vname
OS type: Linux
Block size=4096 (log=2) #block default size
Block size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 262144 blocks< /span>
13107 blocks (5.00%) reserved for the super user
The first data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768 , 98304, 163840, 229376

Allocating group tables: complete
Writing to the inode table: Finished
Creating journal (8192 blocks): Finished
Writing superblocks and filesystem accounting information: Complete

——– ———————————————–

3, mkfs.xfs
XfS file system is an advanced log file system developed by SGI. XFS is extremely scalable and robust. Fortunately, SGI ported it to the Linux system. The default file system after RedHat7.

Command format:

mkfs.xfs [options] [device]

options
< span style="font-size: 15px;">-b size=    Set the block size of the hard disk, the default is 4096 bytes, after the equal sign is your own size, do not add a unit
-m uuid=    Change the UUID number of the partition, and the equal sign is followed by the uuid that is actually set, and the UUID must conform to his naming format.
-f        Mandatory coverage
There are many options for this command here Just introduce the following more to view through man mkfs.xfs

Example: Format Change the partition block size to 1024B and uuid to 0dd5db1c-2f1f-45e7-bbc1-0cbd68ca2f2d and force to overwrite the existing file system
—— ————————————————-< /span>
[[emailprotected] ~]# mkfs.xfs -b size=1024 -m uuid=0dd5db1c-2f1f-45e7-bbc1-0cbd68ca2f2d -f /dev/sdb1
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=262144 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt= 0, sparse=0
data = bsize=1024 blocks=1048576, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=1024 blocks=10240, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0< /span>
——————————- ————————

4. mkfs.ext3
formatted partition as ext3 file system, here is not an example.

Command format:

mkfs.ext3 [Options] [Device]      #You can directly format the partition to ext3 without adding options

5, mkfs.vfat
This command is to format the U disk, vfat is the file system type, linux is called vfat, windows The next name is FAT32. After the grid is finished, all windows and linux can be recognized by default, so I won’t give an example here.

Command format:

mkfs.vfat   [选项]  [设备]      #可以不加选项直接将分区格式化成FAT32

6、mkfs .btrfs
Btrfs is a new type of copy-on-write (COW) Linux file system that has been incorporated into the mainline of the kernel. While Btrfs is designed to achieve advanced functions, it focuses on fault tolerance, repair, and ease of management. It is jointly developed by companies and developers such as Oracle, Red Hat, Fujitsu, Intel, SUSE, STRATO, Btrfs is licensed under the GNU GPL license, and anyone’s contribution is welcome. Here is an example of bu.

Command format:

mkfs.btrfs [Options] [Device]      #You can directly format the partition into btrfs without adding options

Leave a Comment

Your email address will not be published.