LMLPHP后院

Linode - Why No Space Left On Device技术

maybe yes 发表于 2021-09-17 10:16

近来遇到的两次问题,两个主机都发生了,我发了信件,收到了回复!

Hi,

Recently, I have encountered this situation twice. What is the reason? The disk shows that there is still space, but it cannot be written.

rsync: open failed: No space left on device (28)

df -h
Filesystem Size Used Avail Use% Mounted on
udev 480M 0 480M 0% /dev
tmpfs 99M 6.7M 93M 7% /run
/dev/sda 25G 14G 9.2G 60% /
tmpfs 494M 0 494M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 494M 0 494M 0% /sys/fs/cgroup
tmpfs 99M 0 99M 0% /run/user/0

Thanks.

奇特的是 df -h 和 df -i 比例不一致。

Hi there,

It's possible that though you haven't run out of disk space, you may be using all of your available inodes. This post on our Community Questions site offers an explanation -- essentially, each file on your Linode has a corresponding inode, and if you have many small files, you can use up all of your available inodes before you use all of your disk space.

To check, run the following command:

df -i

If you find that your IUse% is close to 100% for /dev/sda, you may need to resize your disk.

The issue could also be arising from the way rsync copies files, which is by creating a new copy and then moving it to its destination file. I found this resource on Google that addresses this issue, and might also be helpful in troubleshooting this:

serverfault: rsync : write failed - No space left on device (28)

I hope these resources help point you in the right direction. If you have any further questions, please don't hesitate to ask.

Thanks,
E. Clyne
Linode Support Team

我经过仔细思考,查看了 Linode 和 DigitalOcean 的对象存储,感觉其提供的 API 并不好用,也不太适合我这种拥有上千万小文件的用户,一旦 API 写入了业务代码后对于后期维护来讲,也是个大坑。所以,思来想去,还是决定使用 nanode 联盟撑起来,结果,被坑了两次,第一次我以为是 Linode 的 Bug,删除主机再重新试了一次,还是不行,看来还是使用私有云吧!

来看看我的电脑的一些对比

Mac

$ df -h
Filesystem      Size   Used  Avail Capacity iused               ifree %iused  Mounted on
/dev/disk1s1   466Gi  244Gi  217Gi    54% 1787940 9223372036852987867    0%   /
devfs          197Ki  197Ki    0Bi   100%     687                   0  100%   /dev
/dev/disk1s4   466Gi  4.0Gi  217Gi     2%       4 9223372036854775803    0%   /private/var/vm
map -hosts       0Bi    0Bi    0Bi   100%       0                   0  100%   /net
map auto_home    0Bi    0Bi    0Bi   100%       0                   0  100%   /home

$ df -i
Filesystem    512-blocks      Used Available Capacity iused               ifree %iused  Mounted on
/dev/disk1s1   976490568 512632400 454090816    54% 1787940 9223372036852987867    0%   /
devfs                393       393         0   100%     687                   0  100%   /dev
/dev/disk1s4   976490568   8388648 454090816     2%       4 9223372036854775803    0%   /private/var/vm
map -hosts             0         0         0   100%       0                   0  100%   /net
map auto_home          0         0         0   100%       0                   0  100%   /home

Raspberry 8G

pi@raspberrypi:~ $ df -h
文件系统        容量  已用  可用 已用% 挂载点
/dev/root       117G   60G   53G   54% /
devtmpfs        3.7G     0  3.7G    0% /dev
tmpfs           3.9G     0  3.9G    0% /dev/shm
tmpfs           3.9G  281M  3.6G    8% /run
tmpfs           5.0M  4.0K  5.0M    1% /run/lock
tmpfs           3.9G     0  3.9G    0% /sys/fs/cgroup
/dev/mmcblk0p1  253M   31M  222M   13% /boot
tmpfs           782M  4.0K  782M    1% /run/user/1000
overlay         117G   60G   53G   54% /var/lib/docker/overlay2/1c3a3273beedf93d3269d37f948be5d55394e55f441f0772242a0840ac483957/merged
overlay         117G   60G   53G   54% /var/lib/docker/overlay2/84d00d722c7a7f587a3acaf4b941f48db58701ac3cf348298216299473a11d88/merged
pi@raspberrypi:~ $ df -i
文件系统         Inode 已用(I) 可用(I) 已用(I)% 挂载点
/dev/root      7547136  171306 7375830       3% /
devtmpfs        958633     417  958216       1% /dev
tmpfs          1000065       1 1000064       1% /dev/shm
tmpfs          1000065     650  999415       1% /run
tmpfs          1000065       3 1000062       1% /run/lock
tmpfs          1000065      15 1000050       1% /sys/fs/cgroup
/dev/mmcblk0p1       0       0       0        - /boot
tmpfs          1000065      19 1000046       1% /run/user/1000
overlay        7547136  171306 7375830       3% /var/lib/docker/overlay2/1c3a3273beedf93d3269d37f948be5d55394e55f441f0772242a0840ac483957/merged
overlay        7547136  171306 7375830       3% /var/lib/docker/overlay2/84d00d722c7a7f587a3acaf4b941f48db58701ac3cf348298216299473a11d88/merged

Linode nano

# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            480M     0  480M   0% /dev
tmpfs            99M  7.9M   91M   8% /run
/dev/sda         25G   12G   12G  49% /
tmpfs           494M     0  494M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           494M     0  494M   0% /sys/fs/cgroup
tmpfs            99M     0   99M   0% /run/user/0
# df -i
Filesystem      Inodes   IUsed  IFree IUse% Mounted on
udev            122708     315 122393    1% /dev
tmpfs           126362     459 125903    1% /run
/dev/sda       1505280 1052605 452675   70% /
tmpfs           126362       1 126361    1% /dev/shm
tmpfs           126362       3 126359    1% /run/lock
tmpfs           126362      17 126345    1% /sys/fs/cgroup
tmpfs           126362       4 126358    1% /run/user/0

Linode 2G

# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            984M     0  984M   0% /dev
tmpfs           200M   21M  180M  11% /run
/dev/sda         49G   41G  5.9G  88% /
tmpfs           998M     0  998M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           998M     0  998M   0% /sys/fs/cgroup
tmpfs           200M     0  200M   0% /run/user/0
# df -i
Filesystem      Inodes   IUsed  IFree IUse% Mounted on
udev            251732     313 251419    1% /dev
tmpfs           255386     426 254960    1% /run
/dev/sda       3041280 2758538 282742   91% /
tmpfs           255386       1 255385    1% /dev/shm
tmpfs           255386       3 255383    1% /run/lock
tmpfs           255386      17 255369    1% /sys/fs/cgroup
tmpfs           255386       4 255382    1% /run/user/0

由此可见 Linode 的存储块设置过大,导致 inode 用光了,无法创建文件

2021-10-24 08:41:39 1635036099 0.021412