Hard-Drive

Centos 伺服器沒有磁碟空間但 df 說有很多

  • November 9, 2017

我的 Centos 告訴我沒有剩餘磁碟空間:

[root@zff isos]# touch test
touch: cannot touch ‘test’: No space left on device

但是df告訴我我還有很多空間:

[root@zff isos]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  3.6T  1.4T  2.2T  39% /
devtmpfs                  32G     0   32G   0% /dev
tmpfs                     32G     0   32G   0% /dev/shm
tmpfs                     32G   67M   32G   1% /run
tmpfs                     32G     0   32G   0% /sys/fs/cgroup
/dev/sda4                497M  165M  333M  34% /boot
/dev/sda1                496M  9.8M  487M   2% /boot/efi
/dev/mapper/centos-home   75G   33M   75G   1% /home
tmpfs                    6.3G  4.0K  6.3G   1% /run/user/0

我也沒有用完 inode:

[root@zff isos]# df -i
Filesystem                  Inodes IUsed      IFree IUse% Mounted on
/dev/mapper/centos-root 3791101952 82816 3791019136    1% /
devtmpfs                   8209805   563    8209242    1% /dev
tmpfs                      8211404     1    8211403    1% /dev/shm
tmpfs                      8211404  1246    8210158    1% /run
tmpfs                      8211404    13    8211391    1% /sys/fs/cgroup
/dev/sda4                   512000    30     511970    1% /boot
/dev/sda1                        0     0          0     - /boot/efi
/dev/mapper/centos-home   39321600    11   39321589    1% /home
tmpfs                      8211404     3    8211401    1% /run/user/0

我不知道問題是什麼。任何幫助表示讚賞!

以下是一些附加資訊:

[root@zff isos]# pvs
 PV         VG     Fmt  Attr PSize PFree
 /dev/sda5  centos lvm2 a--  3.63t    0

[root@zff isos]# vgs
 VG     #PV #LV #SN Attr   VSize VFree
 centos   1   3   0 wz--n- 3.63t    0

[root@zff isos]# lvs
 LV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
 home centos -wi-ao----  75.00g
 root centos -wi-ao----   3.53t
 swap centos -wi-ao---- <31.45g

[root@zff isos]# sudo find /proc/*/fd -ls 2>/dev/null | grep '(deleted)'
121429799    0 lrwx------   1 root     root           64 Nov  7 15:34 /proc/8762/fd/7 -> /tmp/ffi2lKXH0\ (deleted)
121429814    0 lrwx------   1 root     root           64 Nov  7 15:34 /proc/8939/fd/8 -> /tmp/ffimBw8GN\ (deleted)


[root@zff isos]# fdisk -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/sda: 3999.7 GB, 3999688294400 bytes, 7811891200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt



#         Start          End    Size  Type            Name
1         2048      1026047    500M  EFI System      EFI System Partition
2      1026048      1230847    100M  unknown         Basic data partition
3      1230848      5425151      2G  Microsoft basic Basic data partition
4      5425152      6449151    500M  Microsoft basic
5      6449152   7811889151    3.6T  Linux LVM

Disk /dev/mapper/centos-swap: 33.8 GB, 33764147200 bytes, 65945600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/centos-root: 3882.1 GB, 3882088398848 bytes, 7582203904 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/centos-home: 80.5 GB, 80530636800 bytes, 157286400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes

[root@zff /]# du -sh
du: cannot access ‘./proc/45722/task/45722/fd/4’: No such file or directory
du: cannot access ‘./proc/45722/task/45722/fdinfo/4’: No such file or directory
du: cannot access ‘./proc/45722/fd/4’: No such file or directory
du: cannot access ‘./proc/45722/fdinfo/4’: No such file or directory
1.4T    .

編輯

[root@zff /]# df -T
Filesystem              Type      1K-blocks       Used  Available Use% Mounted on
/dev/mapper/centos-root xfs      3791076352 1440862400 2350213952  39% /
devtmpfs                devtmpfs   32839220          0   32839220   0% /dev
tmpfs                   tmpfs      32845616          0   32845616   0% /dev/shm
tmpfs                   tmpfs      32845616      68484   32777132   1% /run
tmpfs                   tmpfs      32845616          0   32845616   0% /sys/fs/cgroup
/dev/sda4               xfs          508588     168456     340132  34% /boot
/dev/sda1               vfat         507904       9980     497924   2% /boot/efi
/dev/mapper/centos-home xfs        78604800      33000   78571800   1% /home
tmpfs                   tmpfs       6569124          4    6569120   1% /run/user/0

編輯 2

[root@zff /]# xfs_ncheck /dev/mapper/centos-root
ERROR: The filesystem has valuable metadata changes in a log which needs to
be replayed.  Mount the filesystem to replay the log, and unmount it before
re-running xfs_ncheck.  If you are unable to mount the filesystem, then use
the xfs_repair -L option to destroy the log and attempt a repair.
Note that destroying the log may cause corruption -- please attempt a mount
of the filesystem before doing this.
must run blockget -n first

重新啟動伺服器(init 6)解決了我的問題。謝謝您的幫助。

df只知道核心中已送出的文件系統更改。例如,如果您刪除了大量正在使用的數據,df則在保持打開這些文件的程序停止並釋放資源之前,不會反映這一點。這不是導致這種情況的唯一條件,但它很常見。

df重啟後通常會反映現實,但這是一個“大錘”解決方案。您可以通過搜尋由程序打開但也被刪除的文件來查看問題所在。lsof以下形式對此有好處:

lsof -nP +L1

您可能還必須考慮相反的情況,因為您可能分配了df尚未提取的數據。這種情況的解決方案很大程度上取決於您使用的文件系統和核心。如果您讓我知道您正在執行什麼,那將為我在這部分答案上提供一些指導。

引用自:https://serverfault.com/questions/882285