Linux Learning Notes (14) DF command, du command, disk partition

Source: Internet
Author: User
Tags delete key

First, DF

#查看文件系统的使用情况

The Tmpfs end of the first column of the file system is a temporary file system, with the default file units being kb

df -h

Automatically adapts to file size units

Free
You can see how swap is used

df -i

View the usage of each partition inode

Sometimes the memory of the disk is still remaining, but can not write new files, this time it may be the inode ran out.

Second, Du

View File Size

du -sh

Auto Fit units Show file or folder size

Du does not add suffixes to the same time as du-l, the size of the file under the display folder

du -lh

Automatically adapts the size of the file under the display folder

Third, disk partitioning

#首先为我们的linux系统增加一块硬盘,

In the virtual machine settings for Linux Add new hard disk, all the way to default, the final size arbitrary, default 20G, I choose 10G here;
Linux Server system is to support hot plug mobile device, because we use the virtual machine, unrecognized, we need to restart the virtual machine

fdisk -l

List disk information for Linux

You can see there are two disks, one/DEV/SDA, one/dev/sdb

fdisk /dev/sdb

/DEV/SDB partition for the newly added disk

Enter M to get help, you can see the specific meaning of each command

n

is to create a new partition

The following will make the choice P or e,p is the primary partition in Windows, E is an extended partition, the primary partition has a maximum of four, and the number of primary partitions + extended partitions can not be greater than 4,
Here we choose P to establish the primary partition
Partition code Default 1
Start sector default 2048 is OK, last sector +2g is the size of partition one is set to 2G;

p

To view the number and size of partitions on a hard disk

The same method continues to create three partitions, which will be an error if you continue to create a new partition

You must delete a partition before you can create a new partition
Enter d to delete the partition

Here we have removed Partition 4,
Continue creating new partition, this time select E extended partition
If you lose the command in the middle, you cannot delete it with the DELETE key

CTRL +u
can be emptied

Blocks is the size of the partition, system is the type of partition, the primary and logical partitions are Linux, and the extended partition is extended
We continue to add new partitions
The number of primary partitions is full and you can add logical partitions
We add two logical partitions

Delete 1 partition
We'll find out that SDB1 is gone.

Delete 5 partition

SDB5 still in, but will find that at this time the SDB5 is actually before the SDB6;
The partition number of the primary partition can be empty, and the partition number of the logical partition must be contiguous;
Partition after the input w can save the partition, Q does not save the operation to exit directly
This time again Fdisk/dev/sdb
You'll find a partition and no

We first set up an extended partition and then continue to create the new partition,

At this point it is necessary to create a primary partition or logical partition, the primary partition can create 3, the partition number of the logical partition starting from 5, because the first four is left to the primary partition and extended partition;
We create a primary partition, the partition number specifies 3, and then a logical partition is created
View partition status

SDB2 is found to be empty, logical partitions start with SDB5

connections and differences between primary, logical, and extended partitions

Basic concepts

    • There are three types of hard disk partitions, primary partition, extended disk partition, logical partition.
      A hard disk primary partition has at least 1, a maximum of 4, and an extended partition can be no more than 1. and the primary partition + extended partition must not exceed 4 total. A logical partition can have several.
    • The primary partition that is activated under Windows is the boot partition of the hard disk, and he is the first partition of the hard disk, and the normal division is the C zone. Both the primary and logical partitions under Linux can be used to put the system on, booting the OS, and grub will be compatible with Windows system boot.
      After dividing the main partition, the rest of the sections can be divided into extended partitions, which are generally divided into extended partitions, or not fully divided, and the remainder is wasted.
      However, the extended partition is not used directly, and is used in logical partitioning, so the extended partition can be divided into logical partitions. Their relationship is a contained relationship, and all logical partitions are part of the extended partition.
    • In Linux, the first hard disk partition is HDA partition, the primary partition number is hda1-4, and the logical partition starts from 5.
      Capacity of the hard disk = capacity of primary partition + capacity of extended partition
      Capacity of the extended partition = The sum of the capacity of each logical partition
    • The primary partition can also become a "boot partition", which is identified by the operating system and the motherboard as the first partition of the hard disk. So the C-disk will always be in the first place on all partitions.
      MBR (master boot Record) of the partition table (primary partition table) can only hold 4 partitions, if you want to divide more partitions will be an extended partition table (EBR), the extended partition table is placed on a system ID 0x05 primary partition, the primary partition is an extended partition, the extended partition can be divided into several partitions, Each partition is a logical partition

Linux Learning Notes (14) DF command, du command, disk partition

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.