Linux disk management notes

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.