# FreeBSD and power failures



## halplus (Apr 9, 2011)

Hi:

I am facing a problem with power failures in a server. Thing is FreeBSD or its default configuration is problematic with power failures. It many times ends up with a corrupt hard drive waiting for console input to perform a manual fsck. I am looking forward whether to change the server filesystem or to perform the task automatically. Thing is I work remotely and remotely I can't do that. Gotta call somebody to get it alive so I can connect to it. We used to have a Linux server there that according to my boss "almost never had that trouble". It was installed several years and the corruption only happened once. As for the windows server same goes. It checks the drive automatically and all fine afterward.

What can i do besides switching back to Linux (I prefer BSD). Or fixing the power failure issues? An entire country needs to be fixed (maybe more than one) before that gets fixed, and backups doesn't last too long. What are my options there?

I remember once that in a remote server I rented I had the same problem as some employee pressed mistakenly the reset button leaving the server all broken. Even running fsck did not fixed it to the point I had to ask for the money back (fortunately I was in the refunding period).

Regards
Waldo


----------



## Gusi (Apr 9, 2011)

There are many options. You could go with UFS+Gjournal (even with that I had to fsck from time to time, but not as frequently as with UFS+softupdates). Another option would be using SUJ.

The third option would be using ZFS. I left gjournal and started running everything with ZFS. Let's cross fingers, but till now everything has been running without a flaw so far. Pay attention to amd64 and more than 4Gb of memory, running ZFS with 386 will give you a lot of headaches (it did for me).


----------



## Beeblebrox (Apr 9, 2011)

Power failures, spiking voltage and all similar electrical issues will cost you no matter what O/S you use.  In the end it will burn out your HDD, and maybe some other components.

Invest in a UPS (power supply); small units are cheap (definitely cheaper than HDD + data). Prefer one with signaling capability over ethernet or com port.  You can then monitor the signal from the UPS to execute an instant or delayed shutdown script for the computer.


----------



## drhowarddrfine (Apr 9, 2011)

Beeblebrox said:
			
		

> Power failures, spiking voltage and all similar electrical issues will cost you no matter what O/S you use.



Absolutely true. Power failures affect hardware, not software, and an operating system is software. 

fwiw, the area I live in was prone to a lot of power outages till a few years ago but I've never lost data on my FreeBSD boxes.


----------



## gkontos (Apr 9, 2011)

@halplus,

if you have physical access to the server then a UPS with smart capabilities should solve your issues. It can power down your server and restore it after the power failure. Of course if the power outages are very frequent then eventually the UPS battery will die soon.
Another solution would be to relocate the server to an area where power is controlled.
Ext3 is more forgiving when it comes to dirty disks but eventually you will loose your data either way.


----------



## aragon (Apr 10, 2011)

Like the others said, your real problem is your supply of power, not the OS.  However, having to manually fsck a UFS+softupdates system should be a very rare event.  How is your existing file system setup?


----------



## Galactic_Dominator (Apr 15, 2011)

/etc/rc.conf


```
fsck_y_enable="YES"
background_fsck="NO"
```


----------



## AndyUKG (Apr 15, 2011)

aragon said:
			
		

> Like the others said, your real problem is your supply of power, not the OS.



I think the OP was getting at the fact that Linux has a journalled file system by default, which FreeBSD doesn't, which will make a considerable difference to a system that is being hard powered off regularly. Full journalled support is coming in FreeBSD 9.0 from what I understand. Others have already mentioned using GJournalling, although I've read that this has some issues (was it when mirroring with GEOM?). Best solution may be upgrade to 9 as soon as possible, i.e. use CURRENT if that is suitable or wait for RELEASE.

thanks Andy.


----------



## halplus (Jan 18, 2012)

Hi folks for what is worth I did the:


```
fsck_y_enable="YES"
background_fsck="NO"
```

and that server has being working great for almost a year now. I am also turning soft updates in all of the servers I deploy as is easy and likely will save me from some corrupt filesystem at the expense of some performance. I took this path as reinstalling and changing the filesystem was likely going to be too problematic. I am happy that 9.0 is coming (I heard is out as for now) with journaling. Is a really nice feature.



> Absolutely true. Power failures affect hardware, not software, and an operating system is software.



I must say that both because software relies on hardware. In a perfect world you would not suffer from power outages as you should have some sort of electrical backup but then this world is not perfect. I think an OS that is made for this world must deal with it's imperfections as much as possible.

I was also wondering how I could make a FreeBSD box move into sort of hibernation or cleanly shutdown in case of power failure detecting a signal from the backup. Would that be possible? Should be a very nice feature. Right now i have a backup for that server but eventually the backup drians the battery and  the shutwdown happens.


----------



## throAU (Jan 18, 2012)

You can probably get FreeBSD to shut down by monitoring your UPS, if the UPS is supported by the UPS monitoring daemon you end up selecting.

see
/usr/ports/sysutils/upsd
/usr/ports/sysutils/upsdaemon


----------



## halplus (Jan 19, 2012)

Wow great! Thanks for sharing! I will be checking the compatibility in case someday I need to buy a new backup and if current one is supported I will be running that daemon for sure!


----------



## halplus (Jan 19, 2012)

> Power failures, spiking voltage and all similar electrical issues will cost you no matter what O/S you use. In the end it will burn out your HDD, and maybe some other components.



Yes I know. I have like 4 power supplies burnt around even using backup. I purchased a good one recently for my personal computer at home. Very expensive, OCZ 700W ModTream Pro 80+. And the backup. I am going to get a power regulator too eventually.



> Invest in a UPS (power supply); small units are cheap(definitely cheaper than HDD + data).



Yes I know what you mean. Data losses can be a chaos. I keep backups around just in case. Well ok sometimes I forget to update them. Eventually have to come up with an option to remember it to me (calendar or something) or in the future if I get a high bandwidth link to store them automatically encrypted in a cloud or something. Unfortunately at my workplace I am not the one taking that decision and they are always short in money to invest . So I try to fix that problem the best way I can. Something is better than nothing!



> Prefer one with signaling capability over ethernet



Wow interesting, had no idea ther were devices like this. This should be supported by any OS out of the box! I like that idea in favor of com port (they are even going away because of USB).

This thread is so old!  I remember i tried to comment back once but the forums were offline and I wasn't around for a while because of the workload. All of this time servers working like a charm 24/7. I love this OS! So reliable when properly configured!


----------



## throAU (Jan 19, 2012)

The bigger APC UPS gear (rack mount) all has ethernet monitoring capability - I believe they've started offering it in their smaller floor mounted UPS gear now as well.

If you're running in a VM environment (eg, vSphere cluster) serial port monitoring is pretty useless as your VM won't necessarily be running on the host the serial port is connected to.

Yes, you can get ethernet-serial boxes, but the better solution is to connect to the UPS via IP over ethernet


----------



## wblock@ (Jan 19, 2012)

If you have multiple computers running off one large APC UPS, sysutils/apcupsd can act as a network server.  So one computer is physically monitoring the UPS by serial or USB, but the other computers are monitoring it through the network.  No expensive APC network card needed in the UPS.


----------

