How to restore a text file from UFS??

Polytropon freebsd at
Fri Aug 20 05:16:51 UTC 2010

On Thu, 19 Aug 2010 21:07:51 +0300, EforeZZ <eforezz at> wrote:
> I edited my 50Kb /etc/rc.conf, loaded a driver and.... got a kernel panic!!
> After reboot my /etc/rc.conf is 0 bytes (after automatic background fsck).

I don't trust background fsck. Better wait 30 minutes for system to
come up cleanly, instead of racing at full spead into data loss...

You have already gotten good advices in how to recover data: /lost+found
in best case, TSK in worst case. In my "recovery career", I made
good experiences with The Sleuth Kit. If you have installed it, have
a look at /usr/local/share/doc/sleuthkit/ref_fs.txt which gives some
insight on how to recover lost files; it is very interesting and

> Which tool should I try now to restore any version of my rc.conf?..

Personally, I use cvs (comes with base system) to keep track of
changes in my config files. In case I accidentally delete a file,
I can simply check it out of the repository, in its current version
as well as in previous versions. CVS is similar to RCS.

I also make a copy of current files of /etc in root's home directory,
which is /root (usually on /).

> I think data should still be somewhere on the disk....

As long as it hasn't been overwritten, it will be there, and usually
will be accessible by simple or complicated means.

If everything fails, maybe you can use a rc.conf of another system
of yours to re-create the original file's contents? Or use the
defaults at /etc/defaults/rc.conf as a template.

Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...

More information about the freebsd-questions mailing list