# [UFS] file is missing but it's actually there



## tekjau (Sep 4, 2013)

Whenever we use du or ls, the file is not found or not there, but after touch, the file will appear again with the right content*.*


```
[CMD=%>]du -s .[/CMD]
du: ./apr/17/M__2390030.tmp: No such file or directory
du: ./jul/15/M__2563608.tmp: No such file or directory
du: ./jun/04/M__2485747.tmp: No such file or directory
du: ./jun/10/M__2496103.tmp: No such file or directory
du: ./jun/20/M__2514010.tmp: No such file or directory
du: ./aug/03/M__2606248.tmp: No such file or directory
du: ./feb/07/M__2181108.tmp: No such file or directory
du: ./feb/14/M__2198844.tmp: No such file or directory
du: ./feb/14/M__2200945.tmp: No such file or directory
du: ./feb/18/M__2209258.tmp: No such file or directory
212     .
result: 1
[CMD=%>]ls -l ./apr/17/M__2390030.tmp[/CMD]
ls: ./apr/17/M__2390030.tmp: No such file or directory
result: 1       
[CMD=%>]touch ./apr/17/M__2390030.tmp[/CMD]
result: 0
[CMD=%>]ls -l ./apr/17/M__2390030.tmp[/CMD]
-rw-r--r--  1 user  group  400 Apr 17 21:27 ./apr/17/M__2390030.tmp
result: 0
```

_A_ny hint on this mysterious file system issue? I have rsynced these file to another HDD and there is no missing file issue on the backup HDD.


----------



## SirDice (Sep 4, 2013)

On what version of FreeBSD?


----------



## tekjau (Sep 5, 2013)

SirDice said:
			
		

> On what version of FreeBSD?



Hi @SirDice,

It is on FreeBSD 8.2-RELEASE-p2.


----------



## SirDice (Sep 5, 2013)

Please note that FreeBSD 8.2 has been end-of-life since July 2012.

[thread=40469]Topics about unsupported FreeBSD versions[/thread]


----------



## kpa (Sep 5, 2013)

Boot into single user mode or boot from rescue media and run a full fsck(8) on the filesystem.


----------



## tekjau (Sep 5, 2013)

kpa said:
			
		

> Boot into single user mode or boot from rescue media and run a full fsck(8) on the filesystem.



Hi @kpa, so you think it might be due to hardware or file system issue?


----------



## SirDice (Sep 5, 2013)

I think it's file system related. It doesn't make sense when the file only appears after you touched it. That very much sounds like some housekeeping of the file system is severely messed up. So I'd definitely have a look with fsck(8) (assuming it's an UFS file system).


----------



## kpa (Sep 5, 2013)

tekjau said:
			
		

> Hi @kpa, so you think it might be due to hardware or file system issue?



Not enough information but running fsck(8) should return the filesystem into a clean state and restore the disappearing file.


----------



## tekjau (Sep 5, 2013)

Hi @SirDice & @kpa,

I think you're right. I have run fsck(8) without unmounting the device from the system (so it's a NO WRITE action)

```
** /dev/da0s3d (NO WRITE)
** Last Mounted on /export
** Phase 1 - Check Blocks and Sizes
INCORRECT BLOCK COUNT I=21697194 (4 should be 0)
CORRECT? no

INCORRECT BLOCK COUNT I=21719274 (4 should be 0)
CORRECT? no

INCORRECT BLOCK COUNT I=22070447 (4 should be 0)
CORRECT? no

INCORRECT BLOCK COUNT I=22070625 (4 should be 0)
CORRECT? no

** Phase 2 - Check Pathnames
UNALLOCATED  I=29982534  OWNER=user MODE=100644
SIZE=158 MTIME=Sep  5 22:23 2013
FILE=/path/sep/05/M__2665710.tmp

UNEXPECTED SOFT UPDATE INCONSISTENCY

REMOVE? no

UNALLOCATED  I=30594830  OWNER=user MODE=100644
SIZE=132 MTIME=Sep  5 22:23 2013
FILE=/path/sep/05/F__2665711.tmp

UNEXPECTED SOFT UPDATE INCONSISTENCY

REMOVE? no

UNALLOCATED  I=30736341  OWNER=user MODE=100644
SIZE=320 MTIME=Sep  5 22:24 2013
FILE=/path/sep/05/M__2665712.tmp

UNEXPECTED SOFT UPDATE INCONSISTENCY

REMOVE? no

** Phase 3 - Check Connectivity
** Phase 4 - Check Reference Counts
LINK COUNT FILE I=21598878  OWNER=user MODE=0
SIZE=0 MTIME=Sep  5 22:23 2013  COUNT 0 SHOULD BE -1
ADJUST? no

** Phase 5 - Check Cyl groups
FREE BLK COUNT(S) WRONG IN SUPERBLK
SALVAGE? no

SUMMARY INFORMATION BAD
SALVAGE? no

BLK(S) MISSING IN BIT MAPS
SALVAGE? no

ALLOCATED FRAG 88868247 MARKED FREE
ALLOCATED FRAG 88873423 MARKED FREE
ALLOCATED FRAG 88875956 MARKED FREE
ALLOCATED FRAG 88876127 MARKED FREE
ALLOCATED FRAG 88876223 MARKED FREE
ALLOCATED FRAG 94051852 MARKED FREE
ALLOCATED FRAG 94052677 MARKED FREE
ALLOCATED FRAG 94053014 MARKED FREE
ALLOCATED FRAG 94053173 MARKED FREE

578674 files, 118794816 used, 78492974 free (62630 frags, 9803793 blocks, 0.0% fragmentation)
```

I store many small size of temporary files to record connectivity status, but how come a file system could get messed-up easily?


----------



## tekjau (Sep 5, 2013)

*[SOLVED] file is missing but it's actually there*

Thanks a lot for your help @SirDice and @kpa, I think we can close this thread.


----------



## SirDice (Sep 5, 2013)

tekjau said:
			
		

> I store many small size of temporary files to record connectivity status, but how come a file system could get messed-up easily?


It normally doesn't. But it can get corrupted when the server is switched off instantly instead of correctly shutting it down. Perhaps a power-outage? Panics maybe?


----------

