# FreeBSD fault tolerance



## jonfr (Oct 11, 2014)

It has happened several times that when I loose power due to thunderstorm that FreeBSD file system does not repair it self after such problems. There is no such thing as 100% stable power, there are always going to be problems. I have tested to add this line into my rc.conf file. That did not change anything when it comes this problem. I always have to manually recover the file system if I suddenly loose the power.


```
fsck_y_enable="YES"
```

Is there any solution to this issue?

Thanks for the answers.


----------



## aupanner (Oct 11, 2014)

I can't answer the 1%, but 99% of your problem is solved by getting a UPS and configuring sysutils/nut to safely shut down your box.  Get as much battery as you can afford.  Depending on your power supply you might need a real sine wave generating UPS rather than a square wave approximation.  Plan on new batteries every 5 years or so.  Test the UPS and shutdown routine every year or so.


----------



## ondra_knezour (Oct 12, 2014)

You didn't mention a filesystem used, but I assume UFS from the fsck utility presence. There may the SUJ (soft updates with journaling) help. Also ZFS is somewhat resistant against filesystem damage during write. However, data will be always lost in case of power failure while being written, so I will consider an UPS a must if living in area with unstable power supply or if working with critical data, as already has been said.


----------



## wblock@ (Oct 12, 2014)

SUJ is mostly for eliminating a long fsck() on reboot.  It does not guarantee that data will not be lost.  Also, some of us have found that avoiding SUJ makes systems more reliable.

We have had people report that they have power outages too long to be covered by a normal UPS.  For that, the important part is that the computer is shut down cleanly before power runs out.  Some UPS systems can be configured to come back on automatically when power is restored, and usually there is a BIOS setting for the computer to do the same.


----------



## drhowarddrfine (Oct 12, 2014)

FWIW, and everything, everywhere is different, I once ran FreeBSD for several years as my workstation with no UPS protection at all through many power outages causing abrupt shut downs and never had any issues whatsoever. I only mention this because, if there is any question about the fault tolerance of FreeBSD, it's some indication that it's pretty good.


----------



## Terry_Kennedy (Oct 13, 2014)

drhowarddrfine said:
			
		

> FWIW, and everything, everywhere is different, I once ran FreeBSD for several years as my workstation with no UPS protection at all through many power outages causing abrupt shut downs and never had any issues whatsoever. I only mention this because, if there is any question about the fault tolerance of FreeBSD, it's some indication that it's pretty good.


I think a lot has to do with the hardware in question. A fancy RAID controller with cache memory (with bad or no battery) means there is potential for more data to be lost, since FreeBSD assumes the data is written when the drive hands it to the controller successfully with the "Please write this now" flag set.

I've found UFS to be quite robust. I don't think I've had any errors that weren't recoverable with fsck(8) in well over a decade. I have not used SUJ, so can't comment on whether that helps or hurts.


----------



## freethread (Oct 13, 2014)

I use UFS SUJ from FreeBSD version 9.0 (now 9.3) on my server (no UPS), never failed to recover files after power loss. Where I live I have about 25-30 power loss per year, concentrated in few short periods, august-september is a good one. An UPS is close to be installed, anyways.


----------



## kpa (Oct 13, 2014)

Unless you have an UPS or battery backed RAID data loss is inevitable if you experience frequent loss of AC power. Even with ZFS there is a small window of time when there can be data in the memory that is to be written to the disk but never makes it there because the loss of power happens at the wrong time. ZIL (or any other journaling method) doesn't help because it too suffers from the same problem, the data going to the log device has to be written to the disk first before it can be used for a replay after a crash.


----------



## jonfr (Oct 20, 2014)

For me this is about the ability to recover once something goes wrong. For instance when the power goes out suddenly, as does happen and it is impossible to trust batteries for long time power outage. This is not a issue in Linux with its EXT3/4 file systems, they do recover most of the time in such cases. So I do not understand why this is an issue with FreeBSD. I did try to move back to Gentoo Linux for my server, only to find out that Minecraft does not run as properly on it as it does on FreeBSD. So I have to move back to FreeBSD to get it running properly again.


----------



## noobster (Oct 20, 2014)

I would encourage the use of ZFS if possible. Several people have already mentioned that you might still lose a little bit of data when a write has not yet been committed to the disk when a power outage happens, but at least you get rid of the fscks. ZFS mounts instantly after a crash and the system will be in a consistent state.


----------



## jonfr (Oct 28, 2014)

For some reason the installer only offers UFS when I install FreeBSD. Too low memory?


----------



## ShelLuser (Oct 28, 2014)

jonfr said:


> For some reason the installer only offers UFS when I install FreeBSD. Too low memory?


Possibly, but the FreeBSD version which you're trying to install can also be of influence here.


----------



## foo_daemon (Oct 30, 2014)

I had a fair amount of FreeBSD crashes when I was running 9-CURRENT on my laptop years ago... it was not entirely STABLE (get it?), and additionally my hard drive slice was not big enough, so I had to put /usr/ports on an NFS mount which would crash often when trying to build a large port (/me glares at OpenOffice), so I quickly learned about the 
	
	



```
fsck_y_enable="YES"
```
 that you mention. I put it on every FreeBSD system I have now and haven't had any regrets. No data loss that I've seen


----------

