加入星计划,您可以享受以下权益:

  • 创作内容快速变现
  • 行业影响力扩散
  • 作品版权保护
  • 300W+ 专业用户
  • 1.5W+ 优质创作者
  • 5000+ 长期合作伙伴
立即加入
  • 正文
  • 相关推荐
  • 电子产业图谱
申请入驻 产业图谱

Linux的df命令

10/02 11:25
472
阅读需 8 分钟
加入交流群
扫码加入
获取工程师必备礼包
参与热点资讯讨论

帮助文档

openailab@openailab-System-Product-Name:~/oaldata$ df --help
Usage: df [OPTION]... [FILE]...
Show information about the file system on which each FILE resides,
or all file systems by default.

Mandatory arguments to long options are mandatory for short options too.
  -a, --all             include pseudo, duplicate, inaccessible file systems
  -B, --block-size=SIZE  scale sizes by SIZE before printing them; e.g.,
                           '-BM' prints sizes in units of 1,048,576 bytes;
                           see SIZE format below
  -h, --human-readable  print sizes in powers of 1024 (e.g., 1023M)
  -H, --si              print sizes in powers of 1000 (e.g., 1.1G)
  -i, --inodes          list inode information instead of block usage
  -k                    like --block-size=1K
  -l, --local           limit listing to local file systems
      --no-sync         do not invoke sync before getting usage info (default)
      --output[=FIELD_LIST]  use the output format defined by FIELD_LIST,
                               or print all fields if FIELD_LIST is omitted.
  -P, --portability     use the POSIX output format
      --sync            invoke sync before getting usage info
      --total           elide all entries insignificant to available space,
                          and produce a grand total
  -t, --type=TYPE       limit listing to file systems of type TYPE
  -T, --print-type      print file system type
  -x, --exclude-type=TYPE   limit listing to file systems not of type TYPE
  -v                    (ignored)
      --help     display this help and exit
      --version  output version information and exit

Display values are in units of the first available SIZE from --block-size,
and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.
Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).

The SIZE argument is an integer and optional unit (example: 10K is 10*1024).
Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000).

FIELD_LIST is a comma-separated list of columns to be included.  Valid
field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent',
'size', 'used', 'avail', 'pcent', 'file' and 'target' (see info page).

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Full documentation at: <http://www.gnu.org/software/coreutils/df>
or available locally via: info '(coreutils) df invocation'

有个疑惑

在这里插入图片描述
如图,我的Linux系统,有1T固态硬盘和3.6T机械硬盘,我想知道“/home/openailab/oaldata/datasets”路径使用哪个磁盘进行存储。我该怎么做?

Linux文件存储在哪里?

一个想法

从挂载情况来看,根目录挂载在固态硬盘上,也就是所有路径的起点 “/”。如果这样的话,目测路径“/home/openailab/oaldata/datasets”的存储,使用的就是固态硬盘。

一个实践

为了验证这个想法,我们往这个路径下存东西,先存他一个T。

在这里插入图片描述

结果没到1个T,固态硬盘就满了。这也就验证了我的想法,该路径使用的是固态硬盘存储。

两个需求

1、我该如何判断该路径使用的是哪个磁盘?

通过帮助文档,df命令带了一个参数file:df [OPTION]… [FILE]…

所以,可以把这个file加上,来查看挂载目录:

df -h /home/openailab/oaldata

在这里插入图片描述

2、我想让该路径使用机械硬盘,我该如何做?

因为这个路径下面已经存有东西,如果直接挂载的话,将会导致该目录下的文件直接丢失。因此,我们需要进行备份,请看我下一篇博客:mount命令。

相关推荐

电子产业图谱