Date: Tue, 16 Apr 2013 21:47:03 +0200 From: Polytropon <freebsd@edvax.de> To: Tak Tak <tak.official@gmail.com> Cc: freebsd-questions@freebsd.org Subject: Re: pwd.db/spwd.db file corupption when having unsafe system poweroff Message-ID: <20130416214703.028f78dc.freebsd@edvax.de> In-Reply-To: <CAHHq%2BVwcazbVXDDsZqH1AXxVOu0mfGjT_5Tcj3OoHJroe8Kgdg@mail.gmail.com> References: <CAHHq%2BVwcazbVXDDsZqH1AXxVOu0mfGjT_5Tcj3OoHJroe8Kgdg@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 16 Apr 2013 13:36:42 +0430, Tak Tak wrote: > hi everyone, > > i wanna know what exactly happens for freebsd files and processes, > when we shutdown system via pressing hardware power key for 3 seconds? Actually no shutdown happens in this situation. The normal programming for the power button is: press for short time: send ACPI signal to OS to perform action action: usually shutdown -p now press for 4 seconds: forced power off, no signal sent to OS equivalent: pull power plug Check the BIOS settings if this is actually the programming in your case. (This has been discussed recently on this list, check the archives to find the corresponding thread.) There are only very few occassions where you _need_ to press the power button for 4 seconds, i. e. if the OS is hanging in a totally dysfunctional state (usually massive hardware errors cause this). Whenever possible, perform a clean shutdown controlled by the OS. > here's what has happened to me, recently: > i've faced a strange problem.. on one of my bsd servers, one of my > coworkers had defined and edited some system users, and then, instead > of safe shutdown, he kept pressing power-button for 3 seconds!.. > after next startup, we couldn't login anymore! we had to replace > pwd.db and spwd.db files, via bootable-freebsd Fixit mode, and then, > everything was fine! If the plain text files /etc/passwd and /etc/master.passwd, it could have been possible to construct the binary databases with the pwd_mkdb program (see "man pwd_mkdb" for details). > we know that we are, for sure, better to use safe shutdown, but i > can't guarantee it always happens. You should. :-) > what if sudden power off makes same > problem??so i can't leave my servers in such situations.. Suddenly and _unintendedly_ powering off a computer (or better: a server) should be somthing worth thinking about. It's definitely not a good idea. However, you can apply some file system tweaks to _hope_ to make the impact less severe -- for example, you can use journaling for the filesystem so it should be in a good condition. > My questins are: > what has happened exactly? You probably disconnected the _essential_ power during a write operation (performed by the disk). > just in-used corrupted files ?? That's quite possible. > is there any way to prevent this situation? (instead of having a > read-only FS.. i can't apply it on this server for now..). As I said, make sure power is provided constantly. Maybe add a UPS to the mix. Use a safe shutdown, prevent accidental "forced power off", maybe by disabling the power button (or putting a protector on it). If possible, use a software command (shutdown, reboot, halt). Add journaling to the file system. Make sure to perform a fsck _prior_ to "going live" (i. e., put the setting background_fsck="NO" in /etc/rc.conf because you NEVER know). > i'm sorry if my question seems dummish! No, it doesn't. It's just important that you recognize what you are actually doing, and what it implies for the OS and the tasks it performs. > i'm trying to increase my bsd > knowledge, but i'm just on my way.. This is to be considered basic hardware knowledge. :-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130416214703.028f78dc.freebsd>