Best way to check and fix corrupt disk?

General questions about the FreeBSD operating system. Ask here if your question does not fit elsewhere.

Best way to check and fix corrupt disk?

Postby bsdme2 » 29 Jan 2009, 03:04

Hi folksss,

What is the best way to check for corrupt sector and fix it on
FreeBSD? I check FSCK to see if there is any option but I can
not find one ... maybe I'm wrong. You know like windows
have scandisk with fix option. My little baby press the reset button on the computer a couple of time and now the system found
an "incorrect block count I=32 ..." I would like to know if there
are any other way to check and fix this beside FSCK.

Thanks folks.
bsdme2
Junior Member
 
Posts: 23
Joined: 04 Jan 2009, 08:32

Postby cajunman4life » 29 Jan 2009, 04:05

FSCK should fix those errors. Boot into single user and run just bare "fsck" and wait. Depending on the size of your drive and how you partitioned it, it may take a long time.
cajunman4life
Member
 
Posts: 119
Joined: 17 Nov 2008, 04:47
Location: Arizona, USA

Postby bsdme2 » 29 Jan 2009, 04:27

cajunman4life ... you are everywhere huh :)

anyway I just google on how to fix corrupt sector in FreeBSD and I got this in more detail. I just want to share with all the newbie or anyone how need this info.

Boot into Single-user mode
Reboot your machine:
# reboot
When you see the initial boot menu, select "Boot FreeBSD in single user mode" (option 4). The kernel will boot up as
usual, but instead of starting all the system processes, only a single root shell will be provided. Hit Enter when you see
this message:
Enter full pathname of shell or RETURN for /bin/sh:
Now check what filesystems are mounted:
# mount
/dev/ad0s1a on / (ufs, local, read-only)
devfs on /dev (devfs, local)
You should see that only "/" (the root filesystem) and the devices under /dev are mounted, and furthermore the root
filesystem is mounted read-only. There are also no virtual consoles and no daemons running. This is the simplest and
safest possible state for the system to be in.
Filesystem repairs
Since the filesystems are not mounted, you can run the filesystem repair tool "fsck" on them (fsck = File System Check).
Its job is to make corrupted filesystems functional again. If individual files have been damaged then they may not be
recoverable, but at least the filesystem will be working again and the other files on it can be accessed.
Firstly, have a look at which partitions are normally mounted; this information is kept in the fie "/etc/fstab"
# cat /etc/fstab
Pick one of these partitions, and run fsck on it. For example, if you decide to check the partition /dev/ad0s1d, then you
would type
# fsck -y /dev/ad0s1d
(The -y flag gives fsck permission to carry out any repairs it suggests). If your filesystem is "clean", that is, it was
unmounted properly at system shutdown, fsck may not do anything. In that case almost certainly it’s not needed, but you
can force it to check the filesystem like this:
# fsck -f -y /dev/ad0s1d
There’s no need to run fsck in single-user mode like this unless during bootup FreeBSD tells you that there’s a filesystem
error which it can’t handle. Make a note of which partition is at fault, reboot into single user mode, and run fsck on that partition only.
bsdme2
Junior Member
 
Posts: 23
Joined: 04 Jan 2009, 08:32

Postby SirDice » 29 Jan 2009, 08:18

Filesystem errors are fixed by using fsck. A real bad sector however isn't. If you have an IDE or S-ATA disk and it's showing bad sectors replace the disk as soon as possible.
User avatar
SirDice
Old Fart
 
Posts: 16153
Joined: 17 Nov 2008, 16:50
Location: Rotterdam, Netherlands

Postby Maxim » 15 Sep 2010, 13:37

After a unsafe shutdown causes by bad electricity stuff, I get a lot of output similar to this in phase 4 of checking:
Code: Select all
UNREF FILE  I=47379  OWNER=nagios MODE=100666
SIZE=1626 MTIME=Sep 15 17:24 2010
RECONNECT? no


And in phase 5:
Code: Select all
** Phase 5 - Check Cyl groups
FREE BLK COUNT(S) WRONG IN SUPERBLK
SALVAGE? no

SUMMARY INFORMATION BAD
SALVAGE? no

BLK(S) MISSING IN BIT MAPS
SALVAGE? no


I rebooted in single-user mode and have done everything suggested above, then reboot into multiuser mode and run fsck again without parameters and get this messages again. Is there any way to fix this?

Thanks in advance!
Standing for Truth. Standing for Justice. Standing around.
Maxim
Junior Member
 
Posts: 9
Joined: 17 Nov 2008, 05:09

Postby User23 » 15 Sep 2010, 13:46

Seems like you didnt make a fsck -y on every filesystem.

If you are in single user mode and you want to check and fix every filesystem

Code: Select all
fsck -y


should just work.

If not, and every time the errors are changing, then your harddisk might dying soon.
User avatar
User23
Member
 
Posts: 336
Joined: 17 Nov 2008, 14:25
Location: Germany near Berlin

Postby Maxim » 16 Sep 2010, 05:40

I definitely used the "-y" option and yes, the errors are changing; I also thought that hdd is dying, but when I checked it with MHDD it identified "no errors".. So I'm puzzled now..
Standing for Truth. Standing for Justice. Standing around.
Maxim
Junior Member
 
Posts: 9
Joined: 17 Nov 2008, 05:09

Postby Maxim » 16 Sep 2010, 05:45

Here is fsck before a ran into single-user mode: http://www.mediafire.com/?tyr1e5cy1darsh1
This one is after: http://www.mediafire.com/?clj7783jur07i1m
Standing for Truth. Standing for Justice. Standing around.
Maxim
Junior Member
 
Posts: 9
Joined: 17 Nov 2008, 05:09

Postby User23 » 16 Sep 2010, 05:51

But the output says "(NO WRITE)" on every filesystem you check. This means fsck will check but wont repair anything.
User avatar
User23
Member
 
Posts: 336
Joined: 17 Nov 2008, 14:25
Location: Germany near Berlin

Postby Maxim » 16 Sep 2010, 06:01

It's when I run just "fsck" in multi-user mode, after I supposedly fixed the errors in single-user mode with instructions provided by bsdme2 above.
Standing for Truth. Standing for Justice. Standing around.
Maxim
Junior Member
 
Posts: 9
Joined: 17 Nov 2008, 05:09

Postby danbi » 16 Sep 2010, 07:53

Just reboot in single user mode and run

[CMD="#"]fsck -y[/CMD]

Repeat it, until it does not find any errors.

Running fsck on mounted filesystems can result in many 'errors' that are reflection of the fact that the filesystem is not static at that time.

Usually, FreeBSD will run fsck in background on all but the root filesystems 60 seconds after going multiuser, unless you disable this with the following in /etc/rc.conf.

Code: Select all
background_fsck="NO"
danbi
Member
 
Posts: 227
Joined: 25 Apr 2010, 09:32
Location: Varna, Bulgaria

Postby Maxim » 16 Sep 2010, 09:09

In single-user mode "fsck -y" doesn't find any errors, they appear when I run "fsck" in multi-user mode.. Something strange is going on..
Standing for Truth. Standing for Justice. Standing around.
Maxim
Junior Member
 
Posts: 9
Joined: 17 Nov 2008, 05:09

Postby danbi » 16 Sep 2010, 10:40

There is no point to run fsck on a live file system (that is, while multi-user).
Your file system is ok.
danbi
Member
 
Posts: 227
Joined: 25 Apr 2010, 09:32
Location: Varna, Bulgaria


Return to General

Who is online

Users browsing this forum: No registered users and 0 guests

cron