# Bad sector on the HDD disk.



## valsorym (Dec 10, 2011)

Hi all, 
Tried to set up WiFi, but broke my computer.

I run OpenBox. All is well. I run gmrun. Also doing well. I run lowriter, or gnome-terminal, or geany, or other software - computer reboot.

I cleaned for him. When I set up WiFi, I used ndisgen. But all that I have done I have recovered.

Why auto reboot my computer?

I have logfiles in /var/log - but which file to look at?
I can not understand what happened.


----------



## valsorym (Dec 10, 2011)

May be defective in gmrun? Try to reinstall!

*Add after few minutes.
Tried to remove gmrun.

```
cd / usr/ports/x11/gmrun
make & & make deinstall clean

....
...
panic: ufs_dirbad: / var: bad dir ino 189 444 at offset 512: mangled entry
cpuid = 2
KDB: stack backtrace:
# 0 0xc0a4b137 at kdb_backtrace +0 x47
...
# 16 0xc0d32ad1 at Xinit0x80_syscall +0 x21
```


**Add after few minutes.
I think that my computer auto restarted due to bad sectors on the HDD.

When it rebooted the first time - I restored the system from Single User.

```
# fsck -y /
# fsck -y /var
# fsck -y /tmp
# fsck -y /usr
# fsck -y /usr/home
# reboot now
```
Hard drive I had formatted so
`# newfs -j MY-HARD-SLICE`
I have a magazine.

How do I fix this?


----------



## valsorym (Dec 10, 2011)

In live USB FreeBSD I installed port sysutils/dd_rescue. 
Run from Live USB FreeBSD and run next script.

```
# mkdir -p /root/dd_rescue_report/
# cd /root/dd_rescue_report/
# vim dd_rescue.sh

#!/bin/sh

fullname=`realpath $0`
whereami=`dirname $fullname`
cd $whereami

dd_rescue -v -l ./err-f9root.log -o ./bad-f9root.log /dev/gpt/f9root /dev/null
dd_rescue -v -l ./err-f9var.log -o ./bad-f9var.log /dev/gpt/f9var /dev/null
dd_rescue -v -l ./err-f9usr.log -o ./bad-f9root.log /dev/gpt/f9usr /dev/null

exit 0
:wq!

# sh dd_rescue.sh
```
A few minutes later I find out if bad sectors.


----------



## wblock@ (Dec 10, 2011)

Given that you've had multiple hard drive failures, the failure point might not be the drives themselves.  Could be power supply, for example.

fsck(8) can be simplified:
`# fsck -y -t ufs`


----------



## valsorym (Dec 10, 2011)

wblock@ said:
			
		

> Given that you've had multiple hard drive failures, the failure point might not be the drives themselves.  Could be power supply, for example.



No it's different HDD drives. The first external hard drivewas - he had his unit power supply.
And this is my laptop. And its hard drive. I'm shocked. I want to swear.

Maybe it's me - loser. x(


----------



## valsorym (Dec 10, 2011)

Result of dd_rescue. 
There are no bad-*. log files.  So, no bad sectors on these slices. 

file err-f9root.log

```
dd_rescue: (info): about to transfer 0.0 kBytes from /dev/gpt/f9root to /dev/null
dd_rescue: (info): blocksizes: soft 65536, hard 512
dd_rescue: (info): starting positions: in 0.0k, out 0.0k
dd_rescue: (info): Logfile: ./err-f9root.log, Maxerr: 0
dd_rescue: (info): Reverse: no , Trunc: no , interactive: no 
dd_rescue: (info): abort on Write errs: no , spArse write: never
dd_rescue: (info): about to transfer 0.0 kBytes from /dev/gpt/f9root to /dev/null
dd_rescue: (info): about to transfer 0.0 kBytes from /dev/gpt/f9root to /dev/null
dd_rescue: (info): blocksizes: soft 65536, hard 512
dd_rescue: (info): blocksizes: soft 65536, hard 512
dd_rescue: (info): starting positions: in 0.0k, out 0.0k
dd_rescue: (info): starting positions: in 0.0k, out 0.0k
dd_rescue: (info): Logfile: ./err-f9root.log, Maxerr: 0
dd_rescue: (info): Logfile: ./err-f9root.log, Maxerr: 0
dd_rescue: (info): Reverse: no , Trunc: no , interactive: no 
dd_rescue: (info): Reverse: no , Trunc: no , interactive: no 
dd_rescue: (info): abort on Write errs: no , spArse write: never
dd_rescue: (info): abort on Write errs: no , spArse write: never
dd_rescue: (info): read /dev/gpt/f9root (2097152.0k): EOF
dd_rescue: (info): Summary for /dev/gpt/f9root -> /dev/null:
dd_rescue: (info): ipos:   2097152.0k, opos:   2097152.0k, xferd:   2097152.0k
                   errs:      0, errxfer:         0.0k, succxfer:   2097152.0k
             +curr.rate:        0kB/s, avg.rate:    97643kB/s, avg.load:  3.3%
```

file err-f9var.log

```
dd_rescue: (info): about to transfer 0.0 kBytes from /dev/gpt/f9var to /dev/null
dd_rescue: (info): blocksizes: soft 65536, hard 512
dd_rescue: (info): starting positions: in 0.0k, out 0.0k
dd_rescue: (info): Logfile: ./err-f9var.log, Maxerr: 0
dd_rescue: (info): Reverse: no , Trunc: no , interactive: no 
dd_rescue: (info): abort on Write errs: no , spArse write: never
dd_rescue: (info): about to transfer 0.0 kBytes from /dev/gpt/f9var to /dev/null
dd_rescue: (info): about to transfer 0.0 kBytes from /dev/gpt/f9var to /dev/null
dd_rescue: (info): blocksizes: soft 65536, hard 512
dd_rescue: (info): blocksizes: soft 65536, hard 512
dd_rescue: (info): starting positions: in 0.0k, out 0.0k
dd_rescue: (info): starting positions: in 0.0k, out 0.0k
dd_rescue: (info): Logfile: ./err-f9var.log, Maxerr: 0
dd_rescue: (info): Logfile: ./err-f9var.log, Maxerr: 0
dd_rescue: (info): Reverse: no , Trunc: no , interactive: no 
dd_rescue: (info): Reverse: no , Trunc: no , interactive: no 
dd_rescue: (info): abort on Write errs: no , spArse write: never
dd_rescue: (info): abort on Write errs: no , spArse write: never
dd_rescue: (info): read /dev/gpt/f9var (4194304.0k): EOF
dd_rescue: (info): Summary for /dev/gpt/f9var -> /dev/null:
dd_rescue: (info): ipos:   4194304.0k, opos:   4194304.0k, xferd:   4194304.0k
                   errs:      0, errxfer:         0.0k, succxfer:   4194304.0k
             +curr.rate:        0kB/s, avg.rate:    98997kB/s, avg.load:  3.4%
```

file err-f9usr.log

```
dd_rescue: (info): about to transfer 0.0 kBytes from /dev/gpt/f9usr to /dev/null
dd_rescue: (info): blocksizes: soft 65536, hard 512
dd_rescue: (info): starting positions: in 0.0k, out 0.0k
dd_rescue: (info): Logfile: ./err-f9usr.log, Maxerr: 0
dd_rescue: (info): Reverse: no , Trunc: no , interactive: no 
dd_rescue: (info): abort on Write errs: no , spArse write: never
dd_rescue: (info): about to transfer 0.0 kBytes from /dev/gpt/f9usr to /dev/null
dd_rescue: (info): about to transfer 0.0 kBytes from /dev/gpt/f9usr to /dev/null
dd_rescue: (info): blocksizes: soft 65536, hard 512
dd_rescue: (info): blocksizes: soft 65536, hard 512
dd_rescue: (info): starting positions: in 0.0k, out 0.0k
dd_rescue: (info): starting positions: in 0.0k, out 0.0k
dd_rescue: (info): Logfile: ./err-f9usr.log, Maxerr: 0
dd_rescue: (info): Logfile: ./err-f9usr.log, Maxerr: 0
dd_rescue: (info): Reverse: no , Trunc: no , interactive: no 
dd_rescue: (info): Reverse: no , Trunc: no , interactive: no 
dd_rescue: (info): abort on Write errs: no , spArse write: never
dd_rescue: (info): abort on Write errs: no , spArse write: never
dd_rescue: (info): read /dev/gpt/f9usr (33554432.0k): EOF
dd_rescue: (info): Summary for /dev/gpt/f9usr -> /dev/null:
dd_rescue: (info): ipos:  33554432.0k, opos:  33554432.0k, xferd:  33554432.0k
                   errs:      0, errxfer:         0.0k, succxfer:  33554432.0k
             +curr.rate:        0kB/s, avg.rate:    96341kB/s, avg.load:  3.3%
```


Then what's the problem?


----------



## valsorym (Dec 10, 2011)

wblock@ said:
			
		

> fsck(8) can be simplified:
> `# fsck -y -t ufs`



Maybe you're right. Maybe I don't right use the fsck(8) utility!?


----------



## wblock@ (Dec 10, 2011)

No, the shorter form of fsck(8) just checks all filesystems of the type given with -t.  Just a little easier.

sysutils/smartmontools can help show disk errors.  Remapped bad blocks would not show in dd_rescue.

It could be a driver or firmware problem.  Could be a power problem, like with unstable AC power.  Even on a laptop, a UPS can be useful.


----------



## _martin (Dec 10, 2011)

Try this phaq's howto.


----------



## valsorym (Dec 11, 2011)

matoatlantis said:
			
		

> Try this phaq's howto.


Good article. I did everything as it says (several times). But sorry, it did not help me.



			
				wblock@ said:
			
		

> sysutils/smartmontools can help show disk errors.  Remapped bad blocks would not show in dd_rescue.



Thanks for the clarification. I installed the sysutils/smartmontools, and will use it. An interesting program.

I checked the disk for bad sectors. I used HDD Regenerator all this night. 

```
Result: Bad block 0. Posted 0.
```

I'm confused. 

Now I want to just delete the partitions. Perform a complete formatting. And re-install the system.

But I do not know how to do a Full Formating. I opened a new one topic. Excuse me.


----------



## valsorym (Dec 12, 2011)

The solution was at a standstill. Was changed tactics. This topic is solved.


----------

