Linux commands (23) Disk Management commands (i) DF,DU,TUNE2FS

Source: Internet
Author: User
Tags disk usage

One, view disk space situation DF

The DF command is used to view hard disk space usage, as well as to see the type of hard disk partition or the usage of inode nodes.

The common parameters of the DF command are as follows:

-a  显示所有文件系统的磁盘使用情况,包括0块(block)的文件系统,如 /proc 文件系统-k  以 k 字节为单位显示-i  显示 i 节点信息,而不是磁盘块-t  显示各指定类型的文件系统的磁盘空间使用情况-x  列出不是某一指定类型文件系统的磁盘空间的使用情况(与 t 选项相反)-T  显示文件系统类型

The DF command uses an instance:

    • View all partition usage of the current system, h means to display the current disk space in a readable manner, similar parameters and k,m, etc.
[[email protected] ~]$ df -ahFilesystem           Size  Used Avail Use% Mounted onsysfs                   0     0     0    - /sysproc                    0     0     0    - /procdevtmpfs             463M     0  463M   0% /devsecurityfs              0     0     0    - /sys/kernel/securitytmpfs                488M     0  488M   0% /dev/shmdevpts                  0     0     0    - /dev/ptstmpfs                488M   13M  475M   3% /runtmpfs                488M     0  488M   0% /sys/fs/cgroup
    • To view inode node usage per partition
   [[email protected] ~]$ df -i   Filesystem            Inodes IUsed    IFree IUse% Mounted on   devtmpfs              118349   358   117991    1% /dev   tmpfs                 124703     1   124702    1% /dev/shm   tmpfs                 124703   444   124259    1% /run   tmpfs                 124703    14   124689    1% /sys/fs/cgroup   /dev/mapper/cl-root 19394560 40825 19353735    1% /   /dev/sda1             524288   338   523950    1% /boot   tmpfs                 124703     1   124702    1% /run/user/1000   tmpfs                 124703     1   124702    1% /run/user/0
    • Show partition type
[[email protected]localhost ~]$ df -TFilesystem          Type     1K-blocks    Used Available Use% Mounted ondevtmpfs            devtmpfs    473396       0    473396   0% /devtmpfs               tmpfs       498812       0    498812   0% /dev/shmtmpfs               tmpfs       498812   12988    485824   3% /runtmpfs               tmpfs       498812       0    498812   0% /sys/fs/cgroup/dev/mapper/cl-root xfs       38770180 3704948  35065232  10% //dev/sda1           xfs        1038336  251388    786948  25% /boottmpfs               tmpfs        99764       0     99764   0% /run/user/1000tmpfs               tmpfs        99764       0     99764   0% /run/user/0
    • Displays the disk usage for the specified file type
[[email protected] ~]$ df -t xfsFilesystem          1K-blocks    Used Available Use% Mounted on/dev/mapper/cl-root  38770180 3704948  35065232  10% //dev/sda1             1038336  251388    786948  25% /boot
Second, view the file or directory occupied space du

The du command can look at disk space consumed by disks or a directory, and common scenarios such as the need to find the most space-intensive directories or files when the hard disk is full.

The common parameters of the du command are as follows:

-a 显示全部目录呃其次目录下的每个档案所占用的磁盘空间-b 大小用 bytes 来表示(默认为 k bytes)-c 最后再加上统计(默认加上)-h 打印出可识别的格式,如 1KB,234M,5GB--max-depth=N 只打印层级大小等于指定数值的文件夹的大小-s 显示各档案大小的总和-x 只计算同属一个档案系统的档案-L 计算所有档案大小

Use of the Du command instance

    • Statistics the size of the current folder, by default does not count the destination folder that the soft link points to
[[email protected] ~]$ du -sh .122M    .
    • Statistics folder size by level, useful when locating folders that occupy disk hits
[[email protected] boot]# du --max-depth=1 -h4.0K    ./grub8.1M    ./grub2214M    .[[email protected] boot]# du --max-depth=2 -h4.0K    ./grub0       ./grub2/themes2.4M    ./grub2/i386-pc3.3M    ./grub2/locale2.5M    ./grub2/fonts8.1M    ./grub2214M    .
Third, adjust and view the file system parameters TUNE2FS

The TUNE2FS is used to view and adjust file system parameters, similar to the self-test under Windows for an exception shutdown startup, which can be set by the Linux command for self-test times and cycles.

TUNE2FS common parameters are as follows:

-l 查看详细信息-c 设置自检次数,每挂载一次mount,count就会加1,超过次数就会强制自检-e 设置当错误发生时内核的处理方式-i 设置自检天数,d表示天,m为月,w为周-m 设置预留空间-j 用于文件系统格式转换-L 修改文件系统的标签-r 调整系统保留空间

TUNE2FS Usage Examples:

    • viewing partition information
 [email protected]:/home/hk# tune2fs-l/dev/sda1 tune2fs 1.42.13 (17-may-2015) Filesystem volume name: <none&  Gt Last mounted on:/Filesystem uuid:6120d692-790d-4e20-bd3b-af331e43d54f Filesystem Magic Number:0xe  F53 Filesystem Revision #: 1 (dynamic) Filesystem features:has_journal ext_attr resize_inode dir_index filetype         needs_recovery extent FLEX_BG Sparse_super large_file huge_file uninit_bg dir_nlink extra_isize Filesystem Flags:          Signed_directory_hash Default Mount options:user_xattr ACL Filesystem state:clean Errors behavior: Continue Filesystem OS type:linux Inode count:2559088 Block count:10235392 Res              Erved block count:511769 free blocks:9163524 free inodes:2359392 first block:         0 Block size:4096 Fragment size:4096 Reserved GDT blocks:1021 blocks per group: 32768 Fragments per group:32768 inodes per group:8176 Inode blocks per group:511 Flex block Group Size:16          Filesystem Created:sun June 09:39:28 2018 last Mount Time:sun June-14:15:46 2018 last Write Time:  Sun June 14:15:39 2018 Mount Count:7 Maximum mount Count:-1 Last Checked:sun       June 09:39:28 2018 Check interval:0 (<none>) Lifetime writes:8116 MB Reserved blocks UID:   0 (user root) Reserved blocks gid:0 (group root) First inode:11 inode size:256 Required extra isize:28 desired extra isize:28 Journal inode:8 Default directory hash:half_ MD4 Directory Hash seed:c67d66dc-ddab-475d-be4b-1fefb58c6656 Journal backup:inode blocks [email p  rotected]:/home/hk#
    • Set the self-test after six months
[email protected]:/home/hk# tune2fs -i 1m /dev/sda1tune2fs 1.42.13 (17-May-2015)Setting interval between checks to 2592000 seconds
    • Set the disk to be re-mounted as read-only when an error occurs
[email protected]:/home/hk# tune2fs -e remount-ro /dev/sda1tune2fs 1.42.13 (17-May-2015)Setting error behavior to 2
    • Set the disk to not self-test permanently
[email protected]:/home/hk# tune2fs -c -1 -i 0 /dev/sda1tune2fs 1.42.13 (17-May-2015)Setting maximal mount count to -1Setting interval between checks to 0 seconds

Linux commands (23) Disk Management commands (i) DF,DU,TUNE2FS

Related Article

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.