LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 12-14-2012, 05:29 AM   #1
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Rep: Reputation: 49
file system check for ext4 file systems


I know if you have an ext2 or ext3 file system, you can run e2fsck to have it clean up the file system. But what do you run if your file system is ext4?
 
Old 12-14-2012, 05:43 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
e2fsck still applies.
 
1 members found this post helpful.
Old 12-14-2012, 05:45 AM   #3
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
Awesome, thanks. Wasn't sure if they replaced it with something newer or not. I'm glad they didn't, since e2fsck is one of the few things I think I'm actually good at running in Linux hahaha.
 
Old 12-14-2012, 09:28 AM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Code:
$ ls -li /sbin/fsck.ext* /sbin/e2fsck
4248 -rwxr-xr-x. 5 root root 197288 2012-06-21 19:27 /sbin/e2fsck
4248 -rwxr-xr-x. 5 root root 197288 2012-06-21 19:27 /sbin/fsck.ext2
4248 -rwxr-xr-x. 5 root root 197288 2012-06-21 19:27 /sbin/fsck.ext3
4248 -rwxr-xr-x. 5 root root 197288 2012-06-21 19:27 /sbin/fsck.ext4
4248 -rwxr-xr-x. 5 root root 197288 2012-06-21 19:27 /sbin/fsck.ext4dev
All are the same prog.
 
1 members found this post helpful.
Old 12-14-2012, 09:29 AM   #5
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
Oh! cool, pretty clever how you figured that out too!
 
Old 12-14-2012, 09:40 AM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
That was just to show the result. The way to find that out is:
Code:
$ ls -li /sbin/e2fsck
4248 -rwxr-xr-x. 5 root root 197288 2012-06-21 19:27 /sbin/e2fsck
$ find /sbin -inum 4248
/sbin/fsck.ext3
/sbin/e2fsck
/sbin/fsck.ext2
/sbin/fsck.ext4
/sbin/fsck.ext4dev
 
1 members found this post helpful.
Old 12-14-2012, 09:43 AM   #7
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
Oh ok. I'm not sure I really understand what all that means or how it actually proves it, but I feel better knowing they are all one in the same.
 
Old 12-14-2012, 01:56 PM   #8
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
It shows that all 5 names map to the same inode number, 4528, i.e., there is just one physical file on the disk, and those 5 directory entries map to that same file. The ls command shows the inode number (which I marked in red) for the file I asked it about, and then the find command looks in the /sbin directory for entries that map to that inode number.
 
Old 12-15-2012, 09:50 AM   #9
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
Oh, ok. thanks again for explaining! now i know this is going beyond the original post, but can only one file occupy an inode, so that's why that proves it? and those other ones are more like links/pointers to what's really e2fsck?
 
Old 12-15-2012, 11:29 AM   #10
amani
Senior Member
 
Registered: Jul 2006
Location: Kolkata, India
Distribution: Debian 64-bit GNU/Linux, Kubuntu64, Fedora QA, Slackware,
Posts: 2,766

Rep: Reputation: Disabled
Quote:
Originally Posted by rknichols View Post
That was just to show the result. The way to find that out is:
Code:
$ ls -li /sbin/e2fsck
4248 -rwxr-xr-x. 5 root root 197288 2012-06-21 19:27 /sbin/e2fsck
$ find /sbin -inum 4248
/sbin/fsck.ext3
/sbin/e2fsck
/sbin/fsck.ext2
/sbin/fsck.ext4
/sbin/fsck.ext4dev
find /sbin -samefile /sbin/e2fsck

is easier.
 
Old 12-15-2012, 12:34 PM   #11
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by rjo98 View Post
Oh, ok. thanks again for explaining! now i know this is going beyond the original post, but can only one file occupy an inode, so that's why that proves it? and those other ones are more like links/pointers to what's really e2fsck?
The inode is what defines the file (singular). The inode contains all the metadata (ownership, permissions, timestamps, ...) and the file system block numbers for accessing the file's data.

And, that file isn't "really e2fsck" any more than it is "really" any of those other names. A directory entry is just a pointer to an inode (for convenience, some other information, such as file type (ordinary, directory, device, FIFO, ...) may be kept there as well), and there can be more than one directory entry pointing to a given inode. Those directory entries are called "hard links," and in order to be located by name a file need to have at least one. One of the fields in the inode is the hard link count, and it is when that count goes to zero (and the file is not currently in use by any process) that the inode is marked "free" and the file's data blocks are returned to the free pool.
 
Old 12-15-2012, 12:58 PM   #12
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by rknichols View Post
It shows that all 5 names map to the same inode number, 4528, i.e., there is just one physical file on the disk, and those 5 directory entries map to that same file.
Is the behaviour the same regardless of what name is used?
 
Old 12-15-2012, 03:47 PM   #13
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Without knowing the program, that is uncertain. By convention, the name by which a program is invoked is placed in argv[0] (available as $0 in a shell script). Programs can, and some do, change their behavior depending on the name in argv[0]. An example would be /usr/bin/pgrep and /usr/bin/pkill. I believe that e2fsck actually looks at the filesystem it is asked to check and does not depend on how it was invoked, and just now running fsck.ext4 successfully on an ext3 filesystem seems to confirm that.
 
Old 12-16-2012, 05:59 PM   #14
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Note also that an inode num is only unique per filesystem/partition; this is why hard-links cannot cross partitions (unlike soft links which just contain a dir path+filename)
 
Old 12-16-2012, 07:24 PM   #15
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Several aspects of hard link semantics would break if the link crossed file system boundaries, issues that become more apparent when you consider that one of those file systems might not be currently mounted, or perhaps physically removed and connected to an independent system. Trying to fsck one of those divorced file systems comes to mind.
 
  


Reply



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
[SOLVED] Bash: ext4 filesystem check when a file was CREATED fatalerror0x00 Programming 9 11-03-2012 03:46 PM
Moved file partitions, File system check failed on Fedora, Windows will not boot LinkSlayer64 Linux - Newbie 7 12-17-2009 02:18 AM
LXer: Linux File Systems: Ext4. Btrfs. Do we understand what we need? LXer Syndicated Linux News 0 03-18-2009 01:02 AM
network file system (NFS) and other file systems ufmale Linux - Newbie 4 05-08-2008 02:01 AM
LXer: Cluster File Systems Attains World Leadership Position In High Performance File System LXer Syndicated Linux News 0 07-14-2006 06:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:16 PM.

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
Open Source Consulting | Domain Registration