LinuxQuestions.org
Help answer threads with 0 replies.
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, 06:29 AM   #1
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,674

Rep: Reputation: 47
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, 06:43 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
e2fsck still applies.
 
1 members found this post helpful.
Old 12-14-2012, 06:45 AM   #3
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,674

Original Poster
Rep: Reputation: 47
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, 10:28 AM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 3,143

Rep: Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350
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, 10:29 AM   #5
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,674

Original Poster
Rep: Reputation: 47
Oh! cool, pretty clever how you figured that out too!
 
Old 12-14-2012, 10:40 AM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 3,143

Rep: Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350
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, 10:43 AM   #7
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,674

Original Poster
Rep: Reputation: 47
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, 02:56 PM   #8
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 3,143

Rep: Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350
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, 10:50 AM   #9
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,674

Original Poster
Rep: Reputation: 47
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, 12:29 PM   #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, 01:34 PM   #11
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 3,143

Rep: Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350
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, 01:58 PM   #12
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 981
Blog Entries: 2

Rep: Reputation: 235Reputation: 235Reputation: 235
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, 04:47 PM   #13
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 3,143

Rep: Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350
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, 06:59 PM   #14
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
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, 08:24 PM   #15
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 3,143

Rep: Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350
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


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


All times are GMT -5. The time now is 11:03 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