LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   When and how to use e2fsck and badblocks (https://www.linuxquestions.org/questions/linux-newbie-8/when-and-how-to-use-e2fsck-and-badblocks-21998/)

Silly22 05-28-2002 10:08 AM

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.

jglen490 05-28-2002 11:09 AM

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.

vfs 05-28-2002 12:50 PM

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

jglen490 05-28-2002 03:04 PM

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.

Silly22 05-28-2002 03:58 PM

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!

vfs 05-29-2002 03:28 PM

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 :D

hth,

vfs


All times are GMT -5. The time now is 02:22 AM.