Linux command manual view (linux view hard disk usage command)

王林
Release: 2024-02-11 10:21:27
forward
733 people have browsed it

Linux command manual view (linux view hard disk usage command)

php editor Xiaoxin introduces to you the command to check the hard disk usage in the Linux operating system. In Linux systems, we often need to understand the usage of hard disks in order to reasonably manage storage space. Fortunately, Linux provides some convenient and practical commands to check hard disk usage. Through these commands, you can easily understand the total capacity, used capacity, available capacity and other information of the hard disk, so that you can clean up and manage the space in a timely manner. Next, let's learn about these commands.

df comes from the coreutils software package and comes with it when the system is installed; we can use this command to check the disk usage and the location where the file system is mounted;
[root@localhost ~ ]# df -l
File system capacity used available used% mount point
/dev/sda3 4956316 3565088 1135396 76% /
tmpfs 241320 12 241308 1% /dev/shm
/ dev/sda6 4806904 2523708 2039012 56% /media/disk
/dev/sda1 4956284 3529796 1170656 76% /media/_
/dev/sda5 4845056 2581484 2019388 57% /media/disk-1

You can see that the system is hung on sda3, and there are also three systems hanging on sda6/sda1/sda5.

2. fdisk -l command

fdisk is a powerful disk operation tool from the util-linux software package. Here we only talk about how to view the disk partition table and partition structure; Through the -l parameter, you can obtain the partition status of all hard disks in the machine;
[root@localhost ~]# fdisk -l

Disk /dev/sda: 40.0 GB, 40000000000 bytes
255 heads, 63 sectors/track, 4863 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x62a9f8d0

Device Boot Start End Blocks Id System
/dev/sda1 * 1 637 5116671 83 Linux
/dev/sda2 638 891 2040255 82 Linux swap / Solaris
/dev/sda3 892 1528 5116702 83 Linux
/dev/sda4 1529 2744 9767520 5 Extended
/dev/ sda5 1529 2136 4883728 83 Linux
/dev/sda6 2137 2744 4883728 83 Linux

sda1 is the partition where the MBR (Master Boot Record) is located, sda2 is the swap partition, and sda4 is the extended partition, including sda5 and sda6 two logical partitions. When the system is divided into partitions, it can only be divided into four primary partitions (extended partitions are also considered primary partitions). In my setup, I divided 3 primary partitions and 1 extended partition, so numbers like sda1.2.3.4.5.6 appeared. If only one primary partition and one extended partition are divided, then the logical partition will start from sda5, followed by sda5.6.7...

3. cfdisk -Ps command (note that P is capitalized)
cfdisk is also a good partitioning tool; in some distributions, this tool has been removed from the util-linux package; cfdisk is simple and easy to use;
View the usage of disk partitions cfdisk -Ps disk device name You can also use cfdisk -Ps

if you have only one hard disk. Example 1: [root@localhost ~]# cfdisk -Ps
Partition Table for /dev/sda

First Last
# Type Sector Sector Offset Length Filesystem Type (ID) Flag
— ——- ————– ————– —— ————– ——————– ——————-
1 Primary 0 10233404 63 10233405 Linux (83) Boot
2 Primary 10233405 14313914 0 4080510 Linux swap / So (82) None
3 Primary 14313915 24547319 0 10233405 Linux (83) None
4 Primary 24547320 44082359 0 19535040 Extended ( 05) None
5 Logical 24547320 34314839 63 9767520 Linux (83) None
6 Logical 34314840 44082359 63 9767520 Linux (83) None
Logical 44082360 78124094 0 34041735 Free Space None

Example 2 :[root@localhost ~]# cfdisk -Ps /dev/sda
Partition Table for /dev/sda

First Last
# Type Sector Sector Offset Length Filesystem Type (ID) Flag
— ——- ————– ————– —— ————– ——————– —-
1 Primary 0 10233404 63 10233405 Linux (83) Boot
2 Primary 10233405 14313914 0 4080510 Linux swap / So (82) None
3 Primary 14313915 24547319 0 10233405 Linux (83) None
4 Primary 24547320 44082359 0 19535040 Extended (05) None
5 Logical 24547320 34314839 6 3 9767520 Linux (83) None
6 Logical 34314840 44082359 63 9767520 Linux (83) None
Logical 44082360 78124094 0 34041735 Free Space None

4. parted command
parted is a partitioning tool with good functions; in Fedora 8 There is a tape, you can install it yourself; the calling method is simple, the default device opened by parted is /dev/hda, you can also specify it yourself; such as parted /dev/hda or /dev/sda, etc.; the exit method is quit

It will take a while after entering the parted command before the following content will appear:
[root@localhost ~]# parted
GNU Parted 1.8.6
Use /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)

Enter p under the cursor and press Enter. The following content will appear:

Model: ATA Maxtor 5T040H4 (scsi )
Disk /dev/sda: 40.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End S ize Type File system flag
1 32.3kB 5240MB 5239MB Primary partition ext3 boot
2 5240MB 7329MB 2089MB Primary partition linux-swap
3 7329MB 12.6GB 5240MB Primary partition ext3
4 12.6GB 22.6GB 10.0GB Extended partition
5 12.6 GB 17.6GB 5001MB Logical partition ext3
6 17.6GB 22.6GB 5001MB Logical partition ext3

(parted)
Enter quit after the cursor to exit.

5. sfdisk -l

[root@localhost ~]# sfdisk -l

Disk /dev/sda: 4863 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System
/dev/sda1 * 0 636 637- 5116671 83 Linux
/dev/sda2 637 890 254 2040255 82 Linux swap / Solaris
/dev/sda3 891 1527 637 5116702 83 Linux
/dev/sda4 1528 2743 1216 9767520 5 Extended
/dev/sda5 1528 2135 608 - 4883728 83 Linux
/dev/sda6 2136 2743 608- 4883728 83 Linux

6. You can also use Applications>System Tools>Disk Usage Analyzer to view disk usage

The above is the detailed content of Linux command manual view (linux view hard disk usage command). For more information, please follow other related articles on the PHP Chinese website!

source:jingfakeji.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template