Linux disk partition command
1. fdisk [-l] device name: view the disk partition, or partition the disk. parameters:
-L: Output all the partition content of the device to be followed. If there is only fdisk-l, the system will list the partitions of the devices that can be searched in the system.
After the command is executed, you only need to enter m after for help: to view the meaning of each parameter.
2. mkfs [-t File System Format] Device File Name: Format File System. parameters:
1)-t: file format, such as ext3, ext2, and vfat.
3. mke2fs [-B block size] [-I block size] [-L header] [-cj] device: Command Parameter for creating a file system,
1)-B: You can set the size of each block. Currently, 2048, and 4096bytes are supported;
2)-I: How much capacity is given to an inode?
3)-c checks for disk errors. If only-c is issued once, the system will perform a quick read test. If-c is issued twice, the system will test reading and writing, which is a little slow.
4)-L: the header name can be followed.
5)-j: the original mke2fs is EXT2. After adding-j, mke2fs will take the initiative to join journal and become EXT3.
4. fsck [-t file system] [-ACay] device name: check and correct the file system. Only the root permission can use this command. parameter:
1)-t: file system type, ext3, etc. Now linux will automatically analyze the file system through superblock, so this option is generally not required
2)-A: According to/etc/fstab, scan the device once and execute the command during startup.
3)-a: automatically fixes problematic sectors,
4)-y: similar to-a, but some filesystems only support the-y parameter.
5)-C: This Histogram can be used during the test to display the current progress.
In addition, for ext2 and ext3 file systems, there are:
6)-f: force check. Generally, if no non-clean labels are found, they will not take the initiative to go to the detail check. If you want to force the details check, add this parameter.
7)-D: optimizes directories in the file system.
This command can only be executed after the device is detached. If the command is executed on the mounted device, the system will be down.
5. badblocks [-svw] device name: Command for checking whether the hard disk or floppy sector has bad track. parameters:
1)-s: List progress on the screen
2)-v: You can view the progress on the screen.
3)-w: Use the write Method for Testing. We recommend that you do not use this parameter, especially when the device to be checked has an archive.
6. mount [-al] [-t file system] [-L label name] [-o additional options] [-n] device file name mount point: mount the device to the specified directory, parameters:
1)-a: Mount all unmounted Disks Based on the data in the configuration file/etc/fstab.
2)-l: Enter mount to display the current mount information. After adding-l, you can add a Label name.
3)-t: add the file system type to specify the type to be mounted.
4)-n: by default, the system will try to write the actual mounting data to/etc/mtab to facilitate the operation of other programs, however, in some cases (such as the standalone mode), you can choose not to write data to avoid problems. In this case, you have to use the-n option.
5)-L: in addition to the device file name (/dev/hd6), the system can also use the header name (Label) of the file system for mounting. It is best to give your file system a unique name.
6)-o: You can add additional parameters when mounting! For example, account, password, and read/write permissions:
Ro, rw: The mounted file system is called read-only or erasable
Async, sync whether the file system uses the memory mechanism of synchronous write or asynchronous write. The default value is asynchronous.
Auto, noauto: Allow this partition to be automatically mounted as mount-
Dev, nodev: whether to allow the creation of files on this partition
Suid, nosuid: whether to allow this partition to contain suid/sgid File Format
Exec, noexec: whether to allow this partition to have executable binary files
User, nouser: whether to allow this partition for any user to execute mount. Generally, mount can only be run by root, but after the user parameter is set, the general user can also mount the partition.
Defaults: Default Value: rw, suid, dev, exec, auto, nouser, async
Remount: remount,
Normally, these parameters do not need to be specified, and the system will automatically obtain them based on superblock.
Mount -- bind source directory destination Directory: mount a directory to another directory. The inode nodes in the two directories are the same.
7. umount [-fn] device file name or mount point: unmount device, directory, parameters:
1)-f
2)-n: unload without updating/etc/mtab/
8. mknod device file name [bcp] [Major] [Minor]: Option parameter:
1) B: set the device to a peripheral storage device file, such as a hard disk
2) c: set the device name to a peripheral input device file, such as a mouse or keyboard.
3) set the device name to a FIFO file.
9. e2label device name new Label name: change file system header name
10. tune2fs [-jlL] device code: convert file system type, parameter:
1)-l: similar to the dumpe2fs-h function, reads data in the superblock.
2)-j: Convert the ext2 File System to the ext3 File System
3)-L: You can modify the label name of the file system, similar to the e2label function.
11. hdparm [-icdmXTt] device name: Adjust the hard disk parameters and only apply to hard disks whose interface is IDE. parameters:
1)-I: displays the hard disk parameters detected by the core.
2)-c: Set the 32-bit access mode. The 32-bit access mode refers to the transmission mode between the hard disk and the PCI interface, while the hard disk itself is still stored in the 16-Bit mode.
3)-d: Set whether to enable the dma mode.-d1 is enabled,-d0 is canceled.
4)-m: sets the mode for Synchronous reading of multiple sector. Generally, this mode can reduce the system's efficiency due to disk reading. However, we do not recommend setting this value for WD hard disks. Generally, setting it to 16/32 is optimized. However, the recommended value for W/D is 4/8. the maximum value can be set using MaxMultSect output by hdparm-I/dev/had. Generally, if you do not know the value, setting 16 is reasonable.
5)-X: Set the UtraDMA mode. Generally, adding 64 to the UDMA mode value is the set value. In addition, the hard disk and the motherboard chip must be synchronized. Therefore, the smallest one is used. Generally:
33 MHz DMA mode 0 ~ 2 (X64 ~ 66)
66 MHz DMA mode 3 ~ 4 (X67 ~ 68)
100 MHz DMA mode 5 (69)
If UTA 100 or above is displayed on your hard disk, the X69 setting is also good.
-T: test the cache access efficiency in the temporary storage area.
-T: test the actual access efficiency of the hard disk.
This article permanently updates the link address: