linux-Disk Management Basic command __linux

Source: Internet
Author: User
Tags create directory disk usage

Du: To count the size of files on a disk
-B statistics file in byte
-K statistics files in kilobytes
-m statistics file in MB
-H in accordance with 1024 to the most appropriate unit statistics file
-H in accordance with 1000 to the most appropriate unit statistics file
-s Specifies the statistic target

DF: View Disk partition usage
-L: Show only local default disks (default)
-A: Displays disk usage for all file systems
-h displays disk capacity in the most appropriate unit in 1024-based
-H: Displays disk capacity in the most appropriate unit for 1000-in-system calculations
-t display disk partition type
-T displays disk partitions for the file system of the specified type
-X does not display disk partitions for the file system of the specified type

the hardware devices in the Linux system are in the form of files in the root directory under the dev directory.

You must partition, format, and mount the hard disk before you can use it.

there are two criteria for the partition: MBR partition and GTP partition. GPT brings a lot of new features, but the MBR still has the best compatibility.
The MBR has obvious drawbacks : a maximum of four primary partitions cannot exceed 2T. The GTP primary partition is almost unlimited, with a single partition capacity of up to 128, with a single partition capacity of up to 18EB (1eb=1024pb,1pb=1024tb,1tb=1024gb,18eb=18432pb=18874368tb= 19327352832GB)).
GPT Partitioning disadvantage : GPT primary partitions are not suitable for installing x86 systems

Partition:

MBR partitions : Using the tool fdisk (this is interactive mode, ask and answer the create partition)

Fdisk-l  //view partition FDISK/DEV/SDB//partition  mode into SDB hard drive

#sdb硬盘的分区模式下的命令
m  //partition mode help
n  // Add a new partition
P  //Add primary partition
e  //Add extended partition
L  //Add logical partition
D/  /delete partition
P  //view partition status
W  //Save end Partition ' Write code here '

GPT Partitioning : Using tool parted (parted can also be used for MBR)

1. Enter the parted command, start the parted partition tool, the default partition target is the system's first hard drive
2. Enter Help to view assistance
3. Toggle partition Destination disk, enter SELECT/DEV/SDC
4. Specify the type of partition table for the target hard disk before you can add partitions to the hard disk, enter the mklable command
(if you use an MBR partition, enter Mklabel msdos; Use GPT partitioning, enter Mklabel GPT)
5. Enter print View the details of the current partition; Enter the print all command to view all partition details,
6.parted partition mode (2 option 1 implementation): ① interactive mode (use questioning mode selection) ② Command mode (Recommended direct command mode command)

① interactive mode Add partition:
add partition directive: Enter Mkpart command
enter partition name
File system type?[ EXT2]?    Select the partition system type (default ext2),
Start?  Partitions start with the first few MB: End from 0
?    End Position: 2000MB
ignore/cancel?  Enter Cancel

to cancel # 4K alignment, it is very important for hard disk partition, in order to achieve the best performance, divide 1-2000mb space, let block align

② command mode add partition (one sentence):
mkpart Test (partition name) 2000 ( Start position 2000MB) 3000 (end MB)
Note: When you add a partition using command mode, the partition name is not an omitted

deletion of the partition numbered 3: RM 3 Unit
GB command:  Specify a start and end position for the partition by using GB (change the default MB for the specified location)
quit command: Exit Partition tool (after the Fdisk partition is finished, it will be written to the hard drive through W, parted not need to be saved with W)

The parted partitioning tool parted the-MKFS tool (expense MBR and GPT) to start the partition from the first few MB when specifying the start and end positions for sector data block numbers with Fdisk different fdisk start and end positions :

MKFS command Formatting (writing 1): MKFS.EXT3/DEV/SDB1; (MKFS. [File format] source file location)
mkfs command Formatting (writing 2): Mkfs-t ext4/dev/sdb2 (mkfs-t [file format] source file location) an

extended partition in the MBR cannot be formatted. Only primary and logical partitions can be formatted (the MBR is divided into primary and extended partitions, and logical partitions are established in an extended partition and can be understood to account for the actual disk capacity of the extended partition.) Primarily to address the creation of up to four primary partition records, a logical partition based on an extended partition & an extended partition is established. Note:

after the hard disk formatted for the GPT partition table within the extended partition, we have no way to see the file system type of each partition, we must
start the parted partition tool, use the print instruction, To view the partition table for GPT hard disk partitions
Mount Partition: Partitions that are not mounted are not available
The partition default mount directory is the/mnt directory. For example: Hang in to Imooc directory,
1. Create directory command: Mkdir-p/MNT/IMOOC
2. Mount Directory command: MOUNT/DEV/SDB1  /MNT/IMOOC (mount [partition disk] [mounted target directory]

Uninstall command: umount/mnt/mount directory

Note: Manually mounted partitions are not permanent, and the mount will fail after the system restarts. Need to modify/etc/fstab file: Vim +/etc/fstab
append:/dev/sdb1   /mnt/imooc   ext3    defaults   0   0
      # Device name     mount point    file system type
Swap swap 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.