Linux check disk, mount disk, disk size common operations

  1. df -h: View disk size The
    df (English: disk free) command is used to display the current file system disk usage statistics on the Linux system.
[root@testvc ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        20G   12G  6.8G  64% /
devtmpfs         16G     0   16G   0% /dev
tmpfs            16G   12K   16G   1% /dev/shm
tmpfs            16G  873M   15G   6% /run
tmpfs            16G     0   16G   0% /sys/fs/cgroup
tmpfs           2.6G     0  2.6G   0% /run/user/0
tmpfs           2.6G     0  2.6G   0% /run/user/3265
/dev/vdb         50G   14G   34G  29% /logdisk

  Among them, /dev/vda1 is the system boot disk, which is mounted under the root path. Its size is 20 G.
/dev/vdb is the mounting disk, mounted under /logdisk, its size is 50 G, and 14 G has been used.

  1. fdisk -l: find information about unmounted disks
[root@iZuf6crxor2b7uwzq9sutyZ ~]# fdisk -l

Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000aaa23

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    83875364    41936658+  83  Linux
  1. lsblk: View the size of the mounted disk
[testuser@testvc ~]$ lsblk
NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda    253:0    0  20G  0 disk 
└─vda1 253:1    0  20G  0 part /
vdb    253:16   0  50G  0 disk /logdisk

  The size of the mounted disk vdb is 50 G, and the mount point is /logdisk.

  1. du -sh *: View the space occupied by each file and directory in the current directory
[root@iZuf6crxor2b7uwzq9sutyZ]# du -sh *
8.0K    conf
329M    data
265M    logs
4.0K    start1.sh
4.0K    start2.sh
4.0K    start3.sh
34M     testapp1.jar
66M     testapp2.jar
  1. du -sh: View the total size of the current directory
[root@iZuf6crxor2b7uwzq9sutyZ]# du -sh
693M    .
  1. The root directory of the disk space is full, use the du -h -x --max-depth=1 command to find large files level by level
[testuser@iZuf6crxor2b7uwzq9sutyZ testdir]$ du -h -x --max-depth=1
265M    ./logs
8.0K    ./conf
329M    ./data
693M    .
[testuser@iZuf6crxor2b7uwzq9sutyZ testdir]$ cd data/
[testuser@iZuf6crxor2b7uwzq9sutyZ data]$ du -h -x --max-depth=1
185M    ./scenic
145M    ./product
329M    .
  1. lsof | grep delete: Check whether the deleted data is still occupying disk space. If there are processes occupying files, kill -9 PID can be released

Guess you like

Origin blog.csdn.net/piaoranyuji/article/details/113740221