This article is a mirror article of machine translation, please click here to jump to the original article.

View: 13119|Reply: 0

[linux] 6 Ways to Check Hard Disk Disk Usage in Linux

[Copy link]
Posted on 10/21/2014 6:18:15 PM | | |

1. df -lh command
df comes from the coreutils package, which comes with the system when it is installed; With this command, we can see the disk usage and where the file system is mounted;
[root@localhost ~]# df -l
File System Capacity Used Available Used % Mount Points
/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: SDA6/SDA1/SDA5.


Twofdisk-l command
fdisk is a powerful disk operation tool from the util-linux package, we will only talk about how to view disk partition table and partition structure here; Through the -l parameter, the partition status of all hard disks in the machine can be obtained.
[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 isExchange partitions; sda4 isExtended partitions, including two logical partitions, SDA5 and SDA6. When the system divides partitions, it can only divide 4 main partitions (extended partitions are also considered primary partitions), I divided 3 main partitions + 1 Extended partition above, and 5.6 is logical partition. That's why there is SDA1.2.3.4.5.6. If you only divide 1 main partition + 1 extended partition, then the logical partition starts with SDA5, SDA1.2.5.6...


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; CFDiDisk is characterized by its simplicity and ease of use;
ViewDisk partitionsThe usage of cfdisk -ps disk device name can also be used with cfdisk -ps for only one hard drive
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     63     9767520 Linux (83)           None
6 Logical    34314840    44082359     63     9767520 Linux (83)           None
   Logical    44082360    78124094      0    34041735 Free Space           None


4. Orders to parted
parted partitioning tool with good function; In Fedora 8, there is a strap, you can install it yourself; The calling method is simple, parted is the default open device is /dev/hda, or you can specify it yourself; For example, parted /dev/hda or /dev/sda, etc.; The way to quit is quit
After entering the parted command, it will take a while for the following content to 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 in the cursor and the following content appears:
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 booted
2 5240MB 7329MB 2089MB primary partition linux-swap        
3 7329MB 12.6GB 5240MB main partition ext3              
4 12.6GB 22.6GB 10.0GB Extended Partition                    
5 12.6GB 17.6GB 5001MB logical partition ext3              
6 17.6GB 22.6GB 5001MB logical partition ext3              
(parted)


Type 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 the application > system tools > disk usage analyzer to check the disk usage.






Previous:Taobao Tmall Double 11 red envelope collection, free red envelope, come and grab it!
Next:Yang Dechang's "One by One" is a hot recommendation
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com