No space left on device?

I did not post for a long time. I am sorry for that. I was busy with my work and life. And, in most time, I think the issue I met is not worth to post.

However, I have to post this one. I have a server that has a lot of free space. But I cannot write any file to it. It always says “No space left on device”. I was confused. I checked the disk space by df -h and found that the disk is not full. I checked the inode by df -i and found that the inode is full. I have searched the internet and asked ChatGPT. No one can give me a solution.

After I read the dmesg output by dmesg | tail, I found the issue.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
[18648018.540378] EXT4-fs warning: 182 callbacks suppressed
[18648018.540384] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2548: Directory (ino: 122265118) index full, reach max htree level :2
[18648018.540390] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2552: Large directory feature is not enabled on this filesystem
[18648018.540419] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2548: Directory (ino: 122265118) index full, reach max htree level :2
[18648018.540420] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2552: Large directory feature is not enabled on this filesystem
[18648018.540426] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2548: Directory (ino: 122265118) index full, reach max htree level :2
[18648018.540427] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2552: Large directory feature is not enabled on this filesystem
[18648018.540434] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2548: Directory (ino: 122265118) index full, reach max htree level :2
[18648018.540435] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2552: Large directory feature is not enabled on this filesystem
[18648018.540632] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2548: Directory (ino: 122265118) index full, reach max htree level :2
[18648018.540634] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2552: Large directory feature is not enabled on this filesystem
[18648035.570025] EXT4-fs warning: 14 callbacks suppressed
[18648035.570029] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2548: Directory (ino: 122265118) index full, reach max htree level :2
[18648035.570034] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2552: Large directory feature is not enabled on this filesystem
[18648035.570086] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2548: Directory (ino: 122265118) index full, reach max htree level :2
[18648035.570088] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2552: Large directory feature is not enabled on this filesystem
[18648035.570098] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2548: Directory (ino: 122265118) index full, reach max htree level :2
[18648035.570099] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2552: Large directory feature is not enabled on this filesystem
[18648035.570110] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2548: Directory (ino: 122265118) index full, reach max htree level :2
[18648035.570111] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2552: Large directory feature is not enabled on this filesystem
[18648374.679676] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2548: Directory (ino: 122265118) index full, reach max htree level :2
[18648374.679683] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2552: Large directory feature is not enabled on this filesystem
[18648374.679702] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2548: Directory (ino: 122265118) index full, reach max htree level :2
[18648374.679704] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2552: Large directory feature is not enabled on this filesystem
[18648374.679712] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2548: Directory (ino: 122265118) index full, reach max htree level :2
[18648374.679713] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2552: Large directory feature is not enabled on this filesystem
[18648374.679719] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2548: Directory (ino: 122265118) index full, reach max htree level :2
[18648374.679720] EXT4-fs warning (device nvme1n1p1): ext4_dx_add_entry:2552: Large directory feature is not enabled on this filesystem

The issue is that the directory index is full. Then I found the solution from [a corner of the internet(https://lowendtalk.com/discussion/181368/dedicated-server-error-ext4-fs-warning-index-full-reach-max-htree-level-2).

I have to enable the large directory feature on the filesystem. I have to run the following command to enable it.

1
sudo tune2fs -O large_dir /dev/mydevice

Then the issue is disappeared. I can write files to the disk again.