加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

在linux上,当目录的大小为0而不是4096时,它意味着什么?

发布时间:2020-12-13 17:19:52 所属栏目:Linux 来源:网络整理
导读:这是一个我以前没见过的奇怪的事情 – 一个目录,其大小由ls报告为0而不是4096,我无法在其中创建任何文件. # ls -ld lib homedrwxr-xr-x. 2 root root 0 Feb 7 03:10 home -- it has zero sizedr-xr-xr-x. 11 root root 4096 Feb 4 09:28 lib# touch home/foo
这是一个我以前没见过的奇怪的事情 – 一个目录,其大小由ls报告为0而不是4096,我无法在其中创建任何文件.
# ls -ld lib home
drwxr-xr-x.  2 root root    0 Feb  7 03:10 home  <-- it has zero size
dr-xr-xr-x. 11 root root 4096 Feb  4 09:28 lib
# touch home/foo
touch: cannot touch `home/foo': No such file or directory  <-- and I can't create files in it
# rm home
rm: cannot remove `home': Is a directory   <-- look,it really is a dir

那么一个目录的大小为0而不是4096意味着什么呢?

文件系统在fedora核心14上是ext4.

mount的输出是:

/dev/mapper/vg_dev-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/vda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

du -s / home的输出:

0   /home

stat / home的输出:

File: `/home'
  Size: 0           Blocks: 0          IO Block: 1024   directory
Device: 15h/21d Inode: 34913       Links: 2
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2011-02-07 03:45:46.188995765 -0800
Modify: 2011-02-07 03:11:59.980995019 -0800
Change: 2011-02-06 07:58:45.874995002 -0800

解决方法

我猜你正在为你的主目录使用autofs.

几个不同的伪文件系统将会出现这样的情况.伪文件系统是不真正保存文件的文件系统.你会注意到/ proc也是这样的.基本上它是因为/ home中没有任何内容,没有文件,没有任何内容.当您尝试访问它时,autofs会看到请求并尝试按要求安装相应的主目录.使用proc,那些不是真正的文件,它们只是由系统上运行的各种驱动程序(和内核)提供的文件的表示.

编辑:关闭autofs,它将显示为普通目录.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读