# vi recovery



## Seeker (Dec 4, 2009)

Ok, so my system just crashed.
In folder I see vi.core file.
Root has received mail that can use:

```
# vi -r cool_text
```
to recover a file.

Now, when I hit:

```
# vi -r
```
I get a list of files to recover:

```
Mon Nov  9 21:15:02 2009: foo
Mon Nov 23 00:58:52 2009: bar
Tue Nov 24 04:46:11 2009: cool_text
Thu Dec  3 13:48:29 2009: cool_text
Fri Dec  4 16:13:47 2009: cool_text
```

If I do:

```
# vi -r cool_text
```
I get:


> There are older versions of this file for you to recover; There are other files for you to recover;


and wana save it with

```
:w cool_text_C
```



> Error: cool_text_C: Bad address; cool_text_C: WARNING: FILE TRUNCATED.


What now?

Also, when I go forward(CTRL-F) to the end of that file, I get "expeled" in cmd.(like in "more" command).
In _vi_ it should not happen but _beep_


----------



## Beastie (Dec 4, 2009)

It's not your system that's crashing. It's vi that is, for some reason. Try to see if the file is really truncated with cat or ee.
I suspect something funny is happening with the filesystem. Do a fsck.

EDIT: you know what? Check the disk for bad blocks too (e.g. dd if=/dev/<disk> of=/dev/null bs=1m).


----------



## Seeker (Dec 5, 2009)

Beastie said:
			
		

> It's not your system that's crashing. It's vi that is, for some reason. Try to see if the file is really truncated with cat or ee.
> I suspect something funny is happening with the filesystem. Do a fsck...



I do not know, how to refer to any of those files.
Where are they?


----------



## Beastie (Dec 5, 2009)

I don't remember for sure, but I think you should be looking in /var/tmp/vi.recover.


----------



## FBSDin20Steps (Dec 5, 2009)

Beastie said:
			
		

> I don't remember for sure, but I think you should be looking in /var/tmp/vi.recover.



Yes, remove /vi.recover.


----------



## Seeker (Dec 5, 2009)

Yes guys, those files are in /var/tmp/vi.recover
Thanks.

Now when it works:

```
# vi -r cool_text
```
And get recovered file(truncated). Then I have chance to save it or if I:

```
:q!
```
it is lost forever.


----------



## Seeker (Dec 5, 2009)

Whoa!
This is unbelievable!
Just now, when I came across third file for recovery and have seeking through it, it's size started to increase at crazy rate, while open in editor!!!

From ie: 42kb, It skyroceted to 1.7 GB!
And caused this:

```
/dev/ad4s3d    1.9G    1.9G   -149M   108%    /var
```

xterm freezed and I had to delete it and open another one, to get rid of that file.

Now what was that?!


----------



## Beastie (Dec 5, 2009)

Did you check the filesystem and disk as I mentioned in my first post?


----------

