2020/11/13

inode and partition space

在disk partition 中要能create 新檔,除了要有剩餘空間外,還有有inode 剩下才行。
一般用 df
# df -i
Filesystem              Inodes      Used Available Use% Mounted on
/dev/root                 3.6K      3.5K        66  98% /
devtmpfs                 23.6K       353     23.2K   1% /dev
tmpfs                   124.6K         1    124.6K   0% /dev/shm
tmpfs                   124.6K       384    124.2K   0% /run
tmpfs                   124.6K         6    124.6K   0% /sys/fs/cgroup
tmpfs                   124.6K         8    124.6K   0% /tmp
tmpfs                   124.6K         5    124.6K   0% /var/tmp
/dev/mmcblk0p8               0         0         0   0% /data
tmpfs                   124.6K         4    124.6K   0% /run/user/0

# df 
Filesystem                Size      Used Available Use% Mounted on
/dev/root               504.4M    422.5M     51.8M  89% /
devtmpfs                 94.2M         0     94.2M   0% /dev
tmpfs                   498.4M         0    498.4M   0% /dev/shm
tmpfs                   498.4M    268.0K    498.1M   0% /run
tmpfs                   498.4M         0    498.4M   0% /sys/fs/cgroup
tmpfs                   498.4M      4.0K    498.4M   0% /tmp
tmpfs                   498.4M         0    498.4M   0% /var/tmp
/dev/mmcblk0p8            6.6G      1.0M      6.6G   0% /data
tmpfs                    99.7M         0     99.7M   0% /run/user/0
像 df -i 中,/dev/root 已經用掉 98%,剩下 66 個 inode。
touch 66 個 file 後,inode 剩下 0
這時候,就算是 df 中 /dev/root 還有 50M 的空間,也沒辦法再 create 新檔了。

另外,..
du --inode folder
也會列出 folder 內的inode 用量。
其中根目錄會列出subfolder 的inode 用量總和。


如果是慢慢漲起來的..可以用 find . 然後依照 file time sorting,找出新增的檔案...
find . -type f -name '*.kk' -printf "%T+ %p\n" | sort

一般embedded system 是在 rootfs 遭遇這個問題,rootfs 又是一個 block device,用 loopback 做出來。
可以用tune2fs 來看,不用真的 mount 起來..
$ tune2fs -l ext4 
tune2fs 1.44.1 (24-Mar-2018)
Filesystem volume name:   
Last mounted on:          
Filesystem UUID:          a34e7a5d-cb27-4f62-bdce-3d68b3e55537
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal dir_index extent
Filesystem flags:         signed_directory_hash 
Default mount options:    (none)
Filesystem state:         clean
Errors behavior:          Unknown (continue)
Filesystem OS type:       Linux
Inode count:              3712
Block count:              468226
Reserved block count:     23411
Free blocks:              29952
Free inodes:              129
First block:              1
Block size:               1024
Fragment size:            1024
Blocks per group:         8080
Fragments per group:      8080
Inodes per group:         64
Inode blocks per group:   8
Last mount time:          n/a
Last write time:          Thu Oct 29 11:30:35 2020
Mount count:              0
Maximum mount count:      -1
Last checked:             Thu Oct 29 11:30:19 2020
Check interval:           0 ()
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:	          128
Journal inode:            8
Default directory hash:   half_md4
Directory Hash Seed:      0e89286e-5c9d-4f0c-9aad-37b2cd127b29
Journal backup:           inode blocks

ref:

沒有留言:

張貼留言