Linux disk management notes
Disk Management
1. df view disk partition usage
-L only display local disks (default)
-A: displays the disk usage of all file systems.
-H: Calculate the disk capacity in December 1024.
-H: Calculate the disk capacity in December 1000.
-T display file system type
-T: displays the specified file system type
-X filters the specified file system type
Df-lahT-t ext4
2. du: Count the file size on the disk.
-B is measured in bytes.
-K
-M
-H
-H
-S: Specify the statistical target
Du-hs/root/
3. Hard Disk partitioning and formatting
View partitions
Fdisk-l
Create a partition
Fdisk/dev/sdb
Hard Disk partitioning Mode
The number of primary MBR partitions cannot exceed 4. A single partition cannot exceed 2 TB.
The maximum number of GPT primary partitions is 128. A single partition cannot exceed 18EB.
1EB = 1024PB 1PB = 1024 TB 1 TB = 1024 GB
Parted
Select/dev/sdb
Mklabel gpt # select a partition table
Print
Print all
Mkpart partition name partition start position partition end position
Mkpart centos 1 1000
Rm Partition Number # delete a partition
Unit GB # specify GB to allocate partitions.
Quit
Partition formatting
Mkfs
Ls-l/dev/sdb *
Mkfs. ext4/dev/sdb1
Mkfs-t ext4/dev/sdb2
Only the primary partition can be formatted. GPT can be a primary partition.
Mount a partition
Mkdir/mnt/centos
Mount/dev/sdb1/mnt/centos # restart failed, permanent save need to modify/etc/fstab
Umount/mnt/centos
Add a swap partition (the whole process is the same as that of a common partition, which must go through the above three partitions)
Create a common Linux partition
Modify the hexadecimal encoding of the partition type
Format the swap partition mkswap/dev/sdb?
Enable swapon/dev/sdb? Swapoff/dev/sdb?
# Swap is a file system type and cannot be mounted to a file using common methods