Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 14 Nov 2019, 18:45
All times are UTC - 4
 Forum index » House Training » Users ( For the regulars )
How to use fsck and e2fsck?
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [7 Posts]  
Author Message
LNSmith


Joined: 28 Mar 2013
Posts: 64
Location: Lake Macquarie, NSW, Australia

PostPosted: Fri 27 Sep 2019, 17:41    Post subject:  How to use fsck and e2fsck?
Subject description: checking a corrupted file system
 

Tutor wanted for fsck command!

Big picture first - detail below.
I needed to check file-system structure on several "real" (hard) drives and also some thumb drives. But mostly the rotating hard drives.

On my desk-top: sda2 is an ext4 partition on a 15yo HDD.
Due to a h/ware problem I copied everything from "sda2" (at that time Windows drive "D") and "gParted" Windows drive "D" into sda1 and sda2.
Windows is now gone ... Puppy is here. Windows simply wouldn't boot.

I re-installed Tahr Pup to sda2. In the morning (some detail is missing here) I "woke-up" my computer and it became obvious that I needed to check the file systems on EVERYTHING.
I ran the command below from the command-line interpreter (known to the cogniscenti as "bash" (I think)).

o-o-o part 1. o-o-o

After some reports from e2fsck and fsck (and shutting down and booting without a save-file etc) I got results for sda1 and sda2 that make some sense.
I WANT TO CHECK MY UNDERSTANDING OF fsck and e2fsck. <=== my main point here!

(#1) e2fsck on the SECOND partition of 15yo HDD partition follows:
root# e2fsck -n /dev/sda2
e2fsck 1.42.9 (4-Feb-2014)
Files: clean, 9407/2469152 files, 377617/9864192 blocks
(end of result from the command line).

I understand this means that the entire file system (as it stands at the moment of testing) on the second partition is sound.
PLS COMMENT: Am I right? <=== pls comment.

(additional info. sda is a 15yo 76GiB hard drive. After some problem (detail below) I moved everything off "D" drive (i.e. a drive used by Windows) to another drive and "gParted" "D" to become sda as follows:

sda1:= FAT32 (approx 1/2 the drive space)
sda2:= ext4 (approx 1/2 the drive space). sda2 has zdrv_tahr_6.0.6.sfs, puppy_tahr_6.0.6.sfs, the swap-file and the tahrsave file. (I think is a separate directory (or folder if you wish to use Windows-like terminology).
OK all that is context.

o-o-o Q2 o-o-o

#2. sda1 is FAT32 and I tried to test the file-system with e2fsck.
Look at the result below! It says "bad!) However ... when I run fsck the result appears to be "good". I suspect I cannot run e2fsck on a FAT32 file-system!
Is this correct?
I think sda1 was "ok" at the moment of testing, yes? <=== pls comment!

(below: running e2fsck on a FAT32 file system)
root# e2fsck -n /dev/sda1
e2fsck 1.42.9 (4-Feb-2014)
ext2fs_open2: Bad magic number in super-block
e2fsck: Superblock invalid, trying backup blocks...
e2fsck: Bad magic number in super-block while trying to open /dev/sda1
(then more from the command line:)

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem. If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device>
or
e2fsck -b 32768 <device>
(end of the report from bash, the command-line-interpreter.)

o-o-o part #3 o-o-o

Next I ran fsck on sda1. I am new to Puppy Linux.
I understand that the result below shows that the ENTIRE partition - files, file-structure, readability of the h/w (at that moment) are all "A"-ok!
I understand I must use fsck for FAT32 filesystems and e2fsck for other systems.
Am I right?

root# fsck -n /dev/sda1
fsck from util-linux 2.21.2
fsck.fat 3.0.26 (2014-03-07)
/dev/sda1: 1 files, 1/1279687 clusters
(end of the report from cli/fsck.)

o-o-o part #4 o-o-o

Some additional words. Why am I doing all this?
My system crashed. It's an old system - a P4 with a 15yo hard drive.
I could (for a few dollars) replace the drive or simply move a newer (dual-core) system (sitting nearby) under my desk and hook up everything. I would have a reliable system and the world would be good ... BUT ... experience has taught me that IF I WORK thru a few faults and find the EXACT problem that cause my P4 to fail I will learn a lot. I spent about 8 hours doing this and now I know more ...

(1) I ended with a corrupt file-system. Every time I booted the Puppy the system would hang-up, sooner or later. At first the problem appeared after a few days. Then it got worse. Eventually Puppy would freeze during booting. The PC is 15 years old! Why not dump it?

Answer: I have a collection of tube/valve type gear that is 75+ years old and most of it works and certainly most of it CAN BE REPAIRED. WHY SHOULD I DUMP A PC THAT IS ONLY 15 YEARS OLD? It does everything I need!

Things I did.
(0) I ended up with a corrupt file system, but all this started with a hardware problem! I asked a few questions (here - on the Murga-Linux forum.)
(1) I read what Big-pup said about dust-bunnies, bulging caps etc.
(2) Eliminated the above and more. REMOVED & RE-SEATED EVERY CONNECTOR IN THE SYSTEM.
(3) Found I could reliably boot Puppy WITHOUT PUP-SAVE. (Booted from a CD.) The ability to run "Puppy" as a minimum system is great asset and trouble finding tool! I could not do this in Windows!
(4) CONCLUSION #1 - I suspect the original fault was poor memory connector seating.
(5) That resulted in destruction of the file-system on Windows drive "D" (also used as a Puppy drive).
(6) After recovering the files from "D" I gParted (former Windows) "D" drive. "D" drive became now sda, with 2 partitions, approximately equal. As I wrote before, SDA1 is FAT32. SDA2 is ext4.

Everything above is context for the exercise in testing the drives and file-system using fsck. However, the operation of fsck does not appear to be uniformly consistent between versions of Linux. For example: I do not see an error code returned after running the command. Many manuals say fsck does return an error code. (0, 1, 2, 4, 8, 16, ....)

More than that: My book, "The Linux Command Line" by Shotts describes fsck in a single paragraph. It does not mention the error codes found using Dr. Google. (hmmm ...)

At the end of this I have learned a lot about troubleshooting a faulty PC.
I still have to confirm my old P4 is working well - but I'm on the way now ...

Thank you, every-one, and esp those who reply to this posting.

Leslie
(down-under in Australia where it is spring and we have bush-fires already.)
2019-09-28
Gotta go!!
Back to top
View user's profile Send private message 
bigpup


Joined: 11 Oct 2009
Posts: 12831
Location: S.C. USA

PostPosted: Fri 27 Sep 2019, 23:54    Post subject:  

Quote:
(#1) e2fsck on the SECOND partition of 15yo HDD partition follows:
root# e2fsck -n /dev/sda2
e2fsck 1.42.9 (4-Feb-2014)
Files: clean, 9407/2469152 files, 377617/9864192 blocks
(end of result from the command line).

I understand this means that the entire file system (as it stands at the moment of testing) on the second partition is sound

Well maybe. Clean is supposed to be telling you no problems found.

This is what the -n option does in e2fsck.
Quote:
-n (Make no changes to the filesystem)

Better to just run e2fsk like this:
Code:
e2fsck /dev/sda2

That way it tells you if it found a problem, fixed it, or asks if you want to fix it.

If you want to see what the options are for e2fsck
In a terminal
Code:
e2fsck --help

_________________
The things they do not tell you, are usually the clue to solving the problem.
When I was a kid I wanted to be older.... This is not what I expected Shocked
YaPI(any iso installer) http://www.murga-linux.com/puppy/viewtopic.php?t=107601
Back to top
View user's profile Send private message 
bigpup


Joined: 11 Oct 2009
Posts: 12831
Location: S.C. USA

PostPosted: Sat 28 Sep 2019, 00:14    Post subject:  

Quote:
#2. sda1 is FAT32 and I tried to test the file-system with e2fsck.


e2fsck is not made for checking Windows file systems.
Really need to use Windows programs for that.

However, after saying that.

You may have fsck.fat utility.
Code:
fsck.fat /dev/sda1

That will check fat32 file systems.
But it is not as good as the Windows chkdsk program in Windows.

_________________
The things they do not tell you, are usually the clue to solving the problem.
When I was a kid I wanted to be older.... This is not what I expected Shocked
YaPI(any iso installer) http://www.murga-linux.com/puppy/viewtopic.php?t=107601
Back to top
View user's profile Send private message 
bigpup


Joined: 11 Oct 2009
Posts: 12831
Location: S.C. USA

PostPosted: Sat 28 Sep 2019, 00:20    Post subject:  

You can use Gparted program to do all this checking of file systems.

The partition to check has to be unmounted!!

Run Gparted with the hard drive selected as the device to access.
Right click on a listed partition.
Select check.

Gparted runs the needed utility to do the check and gives a complete report on what it found or did.

_________________
The things they do not tell you, are usually the clue to solving the problem.
When I was a kid I wanted to be older.... This is not what I expected Shocked
YaPI(any iso installer) http://www.murga-linux.com/puppy/viewtopic.php?t=107601
Back to top
View user's profile Send private message 
bigpup


Joined: 11 Oct 2009
Posts: 12831
Location: S.C. USA

PostPosted: Sat 28 Sep 2019, 00:28    Post subject:  

If you are dealing with a 15 year old hard drive.
If it is not going bad, it will very soon.

Get a new modern one and be happy using latest hard drive features and designs.
It is going to work much better doing everything.
Just make sure you get one that has the same connections as the old one.
How they connect to the computer have changed over the years. What type connector used.


If you still want to try dealing with this old drive.
If you can find out who made it.
All the hard drive manufactures, have testing programs on their web sites, for doing testing of their drives.
These tests will check for actual internal working of the drive.

_________________
The things they do not tell you, are usually the clue to solving the problem.
When I was a kid I wanted to be older.... This is not what I expected Shocked
YaPI(any iso installer) http://www.murga-linux.com/puppy/viewtopic.php?t=107601

Last edited by bigpup on Sat 28 Sep 2019, 01:16; edited 1 time in total
Back to top
View user's profile Send private message 
bigpup


Joined: 11 Oct 2009
Posts: 12831
Location: S.C. USA

PostPosted: Sat 28 Sep 2019, 01:02    Post subject:  

You can also just use fsck for everything.
Code:
fsck /dev/whatever the drive partition is

fsck will figure out what fsck utility to use based on the file system it finds on the drive partition.

But if you want to use an option designation. You have to use the specific utility command.
Notice the options do not do the same thing in each utility.

Example:
fsck options:
Quote:
Usage:
fsck [options] -- [fs-options] [<filesystem> ...]

Check and repair a Linux filesystem.

Options:
-A check all filesystems
-C [<fd>] display progress bar; file descriptor is for GUIs
-l lock the device to guarantee exclusive access
-M do not check mounted filesystems
-N do not execute, just show what would be done
-P check filesystems in parallel, including root
-R skip root filesystem; useful only with '-A'
-r [<fd>] report statistics for each device checked;
file descriptor is for GUIs
-s serialize the checking operations
-T do not show the title on startup
-t <type> specify filesystem types to be checked;
<type> is allowed to be a comma-separated list
-V explain what is being done


e2fsck options:
Quote:
Usage: e2fsck [-panyrcdfktvDFV] [-b superblock] [-B blocksize]
[-l|-L bad_blocks_file] [-C fd] [-j external_journal]
[-E extended-options] [-z undo_file] device

Emergency help:
-p Automatic repair (no questions)
-n Make no changes to the filesystem
-y Assume "yes" to all questions
-c Check for bad blocks and add them to the badblock list
-f Force checking even if filesystem is marked clean
-v Be verbose
-b superblock Use alternative superblock
-B blocksize Force blocksize when looking for superblock
-j external_journal Set location of the external journal
-l bad_blocks_file Add to badblocks list
-L bad_blocks_file Set badblocks list
-z undo_file Create an undo file

_________________
The things they do not tell you, are usually the clue to solving the problem.
When I was a kid I wanted to be older.... This is not what I expected Shocked
YaPI(any iso installer) http://www.murga-linux.com/puppy/viewtopic.php?t=107601
Back to top
View user's profile Send private message 
Mike Walsh


Joined: 28 Jun 2014
Posts: 5547
Location: King's Lynn, UK.

PostPosted: Sun 29 Sep 2019, 06:46    Post subject:  

Morning, Les.

I think fsck's pretty well covered, y'know? Laughing

Further to bigpup's recommendation to replace the drive, had you considered an SSD? Bearing in mind your equipment is P4-generation, I would hazard a guess that you're probably on IDE/PATA (parallel ATA) connections with that, rather than SATA (serial ATA).

Everybody and his dog (scuse the pun) does SATA drives. There's only a handful of manufacturers who do SSDs with connectors for older systems.....although you can use a newer one with a SATA/PATA convertor adapter type of thing. Never having tried these, I can't comment on their effectiveness.

For a reliable IDE/PATA SSD at a reasonable cost, you could do worse than taking a look at the KingSpec range. These are readily available through eBay and Amazon.

I started with a small, 32GB one to replace the tiny 20 GB Hitachi HDD in ye anciente Dell lappie. It worked extremely well, but I had a hankering for more storage space, so I then bought myself a 64GB version. That is now the main drive in the Dell.

Because my old Compaq tower was built around the time that SATA was emerging as the de-facto 'standard', my motherboard is one of those rare beasts with both the older IDE and the newer SATA connectors. I use the SATA connectors for the main WD 500GB HDD and the optical drive, and the smaller SSD was hooked up to one of the old IDE connectors.....and is now in use as the primary boot drive, running DPup 'Stretch'.

It'll not be as fast as an SSD in a modern machine, but it still gives a very healthy speed increase to running Puppy on older hardware. I can thoroughly recommend them.

Food for thought, perhaps?


Mike. Wink

_________________
MY 'PUPPY' PACKAGES

Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [7 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Users ( For the regulars )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1050s ][ Queries: 11 (0.0094s) ][ GZIP on ]