You can repair a damaged filesystem using the fsck program.
It can check the correctness of file placement on disk as well as repair any errors found.
The problem is that the command can only be run on an unmounted disk, and if it's the root filesystem, we can either boot the system from some LiveCD or force fsck to run the next time the system starts.
The second option is much simpler and faster,
we need to:
- log in as root
- go to the root directory: cd /
- create the file forcefsck: touch forcefsck
- restart the system: reboot
...or shutdown -rF now