# Random reboot overnight



## baot (Feb 22, 2012)

Hi. My FreeBSD 9.0-RELEASE server has had perfect uptime and stability since the day I installed it (about one month ago) but randomly rebooted itself this morning. I've never had to troubleshoot this before so I'm not sure how to find the cause. This was all I found in dmesg.


```
Fatal trap 12: page fault while in kernel mode
cpuid = 0; apic id = 00
fault virtual address   = 0x260
fault code              = supervisor read, page not present
instruction pointer     = 0x20:0xc12a62f0
(da1:stack pointer              = 0x28:0xc520ac68
umass-sim1:1:0:frame pointer            = 0x28:0xc520ac84
0): removing device entry
code segment            = base 0x0, limit 0xfffff, type 0x1b
                        = DPL 0, pres 1, def32 1, gran 1
processor eflags        = interrupt enabled, resume, IOPL = 0
current process         = 13 (g_down)
trap number             = 12
panic: page fault
cpuid = 0
KDB: stack backtrace:
#0 0xc0a4b157 at kdb_backtrace+0x47
#1 0xc0a186b7 at panic+0x117
#2 0xc0d48cf3 at trap_fatal+0x323
#3 0xc0d48dad at trap_pfault+0xad
#4 0xc0d49b35 at trap+0x465
#5 0xc0d32a8c at calltrap+0x6
#6 0xc09aecd9 at g_io_schedule_down+0x269
#7 0xc09af012 at g_down_procbody+0x72
#8 0xc09ea997 at fork_exit+0x97
```

Thanks for any help, I'm really puzzled as to what happened. It was under very light load at the time if it matters.


----------



## idownes (Feb 23, 2012)

Do you know what time the reboot happened? 

A lot of periodic scripts start shortly after 3 am and can reveal issues.

Also, g_down is part of GEOM; have you checked all of your disks using sysutils/smartctl?


----------



## baot (Feb 23, 2012)

Thanks for your reply. It happened at around 13:46 on Feb. 22nd. I also thought it could be an automated monthly script, but I was told they are run on the first of the month only.

The system has two drives, one SATA for the OS and one USB for storage. Here is the smartctl output:

(USB, 1 month old)

```
smartctl 5.42 2011-10-20 r3458 [FreeBSD 9.0-RELEASE i386] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF INFORMATION SECTION ===
Model Family:     Seagate Barracuda Green (Adv. Format)
Device Model:     ST2000DL003-9VT166
Serial Number:    5YD5RJQZ
LU WWN Device Id: 5 000c50 045afdde0
Firmware Version: CC3C
User Capacity:    2,000,398,934,016 bytes [2.00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   8
ATA Standard is:  ATA-8-ACS revision 4
Local Time is:    Wed Feb 22 22:09:06 2012 EST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x82)	Offline data collection activity
					was completed without error.
					Auto Offline Data Collection: Enabled.
Self-test execution status:      (   0)	The previous self-test routine completed
					without error or no self-test has ever 
					been run.
Total time to complete Offline 
data collection: 		(  612) seconds.
Offline data collection
capabilities: 			 (0x7b) SMART execute Offline immediate.
					Auto Offline data collection on/off support.
					Suspend Offline collection upon new
					command.
					Offline surface scan supported.
					Self-test supported.
					Conveyance Self-test supported.
					Selective Self-test supported.
SMART capabilities:            (0x0003)	Saves SMART data before entering
					power-saving mode.
					Supports SMART auto save timer.
Error logging capability:        (0x01)	Error logging supported.
					General Purpose Logging supported.
Short self-test routine 
recommended polling time: 	 (   1) minutes.
Extended self-test routine
recommended polling time: 	 ( 255) minutes.
Conveyance self-test routine
recommended polling time: 	 (   2) minutes.
SCT capabilities: 	       (0x30b7)	SCT Status supported.
					SCT Feature Control supported.
					SCT Data Table supported.

SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000f   118   100   006    Pre-fail  Always       -       201156144
  3 Spin_Up_Time            0x0003   093   092   000    Pre-fail  Always       -       0
  4 Start_Stop_Count        0x0032   100   100   020    Old_age   Always       -       197
  5 Reallocated_Sector_Ct   0x0033   100   100   036    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000f   064   060   030    Pre-fail  Always       -       3077321
  9 Power_On_Hours          0x0032   099   099   000    Old_age   Always       -       987
 10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   020    Old_age   Always       -       10
183 Runtime_Bad_Block       0x0032   100   100   000    Old_age   Always       -       0
184 End-to-End_Error        0x0032   100   100   099    Old_age   Always       -       0
187 Reported_Uncorrect      0x0032   100   100   000    Old_age   Always       -       0
188 Command_Timeout         0x0032   100   099   000    Old_age   Always       -       4295032833
189 High_Fly_Writes         0x003a   100   100   000    Old_age   Always       -       0
190 Airflow_Temperature_Cel 0x0022   066   059   045    Old_age   Always       -       34 (Min/Max 23/41)
191 G-Sense_Error_Rate      0x0032   100   100   000    Old_age   Always       -       0
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       6
193 Load_Cycle_Count        0x0032   100   100   000    Old_age   Always       -       211
194 Temperature_Celsius     0x0022   034   041   000    Old_age   Always       -       34 (0 20 0 0 0)
195 Hardware_ECC_Recovered  0x001a   027   019   000    Old_age   Always       -       201156144
197 Current_Pending_Sector  0x0012   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0010   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x003e   200   200   000    Old_age   Always       -       0
240 Head_Flying_Hours       0x0000   100   253   000    Old_age   Offline      -       260627205456219
241 Total_LBAs_Written      0x0000   100   253   000    Old_age   Offline      -       1630588336
242 Total_LBAs_Read         0x0000   100   253   000    Old_age   Offline      -       408575169

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
No self-tests have been logged.  [To run self-tests, use: smartctl -t]


SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.
```

I have to include the other drive in another post since I've passed the character limit for the forum.


----------



## baot (Feb 23, 2012)

(SATA, couple of years old)

```
smartctl 5.42 2011-10-20 r3458 [FreeBSD 9.0-RELEASE i386] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF INFORMATION SECTION ===
Model Family:     Seagate Barracuda 7200.10
Device Model:     ST380815AS
Serial Number:    9QZBCLPR
Firmware Version: 4.AAB
User Capacity:    80,026,361,856 bytes [80.0 GB]
Sector Size:      512 bytes logical/physical
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   7
ATA Standard is:  Exact ATA specification draft version not indicated
Local Time is:    Wed Feb 22 22:17:26 2012 EST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x82)	Offline data collection activity
					was completed without error.
					Auto Offline Data Collection: Enabled.
Self-test execution status:      (   0)	The previous self-test routine completed
					without error or no self-test has ever 
					been run.
Total time to complete Offline 
data collection: 		(  430) seconds.
Offline data collection
capabilities: 			 (0x5b) SMART execute Offline immediate.
					Auto Offline data collection on/off support.
					Suspend Offline collection upon new
					command.
					Offline surface scan supported.
					Self-test supported.
					No Conveyance Self-test supported.
					Selective Self-test supported.
SMART capabilities:            (0x0003)	Saves SMART data before entering
					power-saving mode.
					Supports SMART auto save timer.
Error logging capability:        (0x01)	Error logging supported.
					General Purpose Logging supported.
Short self-test routine 
recommended polling time: 	 (   1) minutes.
Extended self-test routine
recommended polling time: 	 (  27) minutes.

SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000f   100   253   006    Pre-fail  Always       -       0
  3 Spin_Up_Time            0x0003   097   097   000    Pre-fail  Always       -       0
  4 Start_Stop_Count        0x0032   100   100   020    Old_age   Always       -       718
  5 Reallocated_Sector_Ct   0x0033   100   100   036    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000f   083   060   030    Pre-fail  Always       -       219737356
  9 Power_On_Hours          0x0032   077   077   000    Old_age   Always       -       20302
 10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   020    Old_age   Always       -       719
187 Reported_Uncorrect      0x0032   100   100   000    Old_age   Always       -       0
189 High_Fly_Writes         0x003a   100   100   000    Old_age   Always       -       0
190 Airflow_Temperature_Cel 0x0022   060   055   045    Old_age   Always       -       40 (Min/Max 37/42)
194 Temperature_Celsius     0x0022   040   045   000    Old_age   Always       -       40 (0 20 0 0 0)
195 Hardware_ECC_Recovered  0x001a   064   056   000    Old_age   Always       -       198033796
197 Current_Pending_Sector  0x0012   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0010   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x003e   200   200   000    Old_age   Always       -       0
200 Multi_Zone_Error_Rate   0x0000   100   253   000    Old_age   Offline      -       0
202 Data_Address_Mark_Errs  0x0032   100   253   000    Old_age   Always       -       0

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline       Completed without error       00%         0         -

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.
```


----------



## DutchDaemon (Feb 23, 2012)

baot said:
			
		

> I have to include the other drive in another post since I've passed the character limit for the forum.



From Posting and Editing in the FreeBSD Forums I: proper formatting:



> Note: if you need to post a lot of system output, we prefer you use http://pastie.org or http://pastebin.com. Paste your output in the box on the website, submit it, wait for the URL to appear, and post that URL on the forum.


----------



## fleon (Feb 27, 2012)

I had a machine just recently that reset itself randomly, usually over-night and days or weeks apart (at first). I and various colleagues wasted a great deal of time trying to fix a software problem that just wasn't there - it was just flaky hardware. It was just flaky in a way that meant it was rock-solid of hours and would then suddenly reset. It did tend to reset slightly more often under certain load conditions, which did happen overnight. So, before chasing ghosts, might I suggest you boot it from a CD (preferably a soak-test one) and rule the hardware out? Save yourself the pain I went through!


----------



## baot (Mar 3, 2012)

It just happened again, at a completely different time. Someone told me to add 
	
	



```
dumpdev="AUTO"
dumpdir="/var/crash"
```
 to my /etc/rc.conf for better debugging of the issue. I did that, but all I can see is a file called /var/crash/minfree which only says 2048. dmesg also says 
	
	



```
Mar  3 16:36:06 solidbox root: /etc/rc: WARNING: Dump device does not exist.  Savecore not run.
```
 so something must be misconfigured. Now it's crashed again and I'm lost as to where to look for info on why this happened.


----------



## freethread (Mar 3, 2012)

You can write a simple script like


```
if [ -f "/somedir/somefile.txt" ] ; then
    cp /somedir/somefile.txt /somedir/somefile.bak
fi
sysctl -a -h > /somedir/somefile.txt
```

and run it every 5 or 10 min in a cron job, then check if there is something bad with hardware: memory, temperatures, etc.

The *if* block backups last generated file to have the time to preserve at least sysctl data when reboot, but perhaps if you boot in single user mode cron is not executed. Adjust it as your need.


----------

