LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-28-2002, 11:08 AM   #1
Silly22
LQ Newbie
 
Registered: Mar 2002
Location: Edmonton, AB
Distribution: Mandrake 10.2, Ubuntu 6.10
Posts: 26

Rep: Reputation: 15
When and how to use e2fsck and badblocks


I'm a total newbie and need some help on checking for badblocks on my hard drive.

First, I know I have bad sectors on my drive because when I had Windows installed on it, I could run chkdsk and saw 96 KB of bad sectors.

Now, when I installed Mandrake Linux, I used the installer to create my ext2 and linux swap partitions. But it never offered the option of checking for bad blocks (using mke2fs with the -c option). So I'm not sure if it checked for bad blocks.

All I want to do is run "e2fsck -cf" on the entire hard drive (all partitions including swap). But I thought I read that fsck should not be run on mounted devices, so when exactly should I run e2fsck? Should I boot up using a boot disk like tomsrtbt and then run e2fsck on the unmounted devices? What happens if I press ESC at the start (when the Mandrake splash screen comes up and gives me 3 secs) resulting in a prompt that says "boot:", can I run e2fsck at that prompt?

I also want to try running "badblocks -n". But I read that badblocks should not be run on mounted partitions. Should this be done from boot disk?

I know that Mandrake runs e2fsck at boot everytime, the problem is, I'm not certain it checks for bad blocks since the hard drive is flagged sucessfully unmounted because I shutdown properly.
 
Old 05-28-2002, 12:09 PM   #2
jglen490
Member
 
Registered: Apr 2002
Location: The next brick house on the right.
Distribution: Kubuntu 8.04
Posts: 668

Rep: Reputation: 31
Yes, these utilities should not be run while the device is mounted. Using something like Tom's root boot disk is a great idea for times like this. If your drive is mounted, use the "umount" command (man umount) to unmount the drive, then run badblocks or e2fsk. After running your can reboot, or you can mount the drive.
 
Old 05-28-2002, 01:50 PM   #3
vfs
Member
 
Registered: Apr 2002
Location: Brazil
Distribution: Slackware
Posts: 184

Rep: Reputation: 30
You may think I'm a liar, but I have a disk where scandisk found about 200k of bad blocks. After formatting with ext2 and fat32 and ext2 again, the bad blocks went away (at least weren't no more listed) and I never had problems filling up the disk.

A good test for bad blocks is dd. It'll hand if it encounters a bad block:

dd if=/dev/zero of=/directory/in/the/partition_to_examine/file bs=1k

Let it fill the disk, then erase the file.

HTH,

vfs
 
Old 05-28-2002, 04:04 PM   #4
jglen490
Member
 
Registered: Apr 2002
Location: The next brick house on the right.
Distribution: Kubuntu 8.04
Posts: 668

Rep: Reputation: 31
Quote:
You may think I'm a liar ...
No way, my friend, because you are right. Bad sectors, or bad blocks, are pretty much probabilistic -- not absolute. Just like data can be retrieved from an "erased" hard drive, in most cases, the actual magnetic domains (or bits) on the hard drive that may be registering as bad might be ignored just by the simple act of working with a different file system. Those domains are a lot smaller than a sector or block and really only make a difference if there are a whole bunch of bad ones right next to each other.
 
Old 05-28-2002, 04:58 PM   #5
Silly22
LQ Newbie
 
Registered: Mar 2002
Location: Edmonton, AB
Distribution: Mandrake 10.2, Ubuntu 6.10
Posts: 26

Original Poster
Rep: Reputation: 15
check swap partition

Does e2fsck work for the swap partition too? Or should I use fsck? Or does it make no sense to run a filesystem check on the swap? Should I just run "badblocks" on the swap partition and would it be used the same way as on the ext2 partition?

Thanks guys for the replies!
 
Old 05-29-2002, 04:28 PM   #6
vfs
Member
 
Registered: Apr 2002
Location: Brazil
Distribution: Slackware
Posts: 184

Rep: Reputation: 30
To jglen:

Well, as I usually say here, I'm just a Law student, not a hacker... I don't know or understand a lot about this hardware stuff, but I do 'grep' in my partitions, to find files I accidentally deleted.

To Silly22:

do:

swapoff /partition

then:

mkswap -c /partition

(i'm not sure about the option, but 'man mkswap' is there for it... )

And why don't you use a nick less Silly, like Silly21 or Silly20

hth,

vfs
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
badblocks time linuxhippy Slackware 20 07-16-2005 11:48 PM
reiser fs and badblocks munkie_poo Slackware 3 11-19-2004 05:48 PM
Badblocks odd Linux - Software 1 06-03-2004 02:54 PM
badblocks check... wrongman Linux - Hardware 3 05-20-2004 11:38 AM
Badblocks and using dd? sthemage Linux - General 1 12-26-2003 03:52 PM


All times are GMT -5. The time now is 05:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration