Find the answer to your Linux question:
Results 1 to 7 of 7
Hi , In this case what is the return value of mount . I want to run e2fsck only when either mount fails or mount succeeded but with errors . ...
  1. #1
    Just Joined!
    Join Date
    Nov 2010
    Posts
    3

    e2fsck reports no problems, but mount warns of errors

    Hi , In this case what is the return value of mount . I want to run e2fsck only when
    either mount fails or mount succeeded but with errors . Is there some way to detect
    this situatin "mounting fs with errors" in code/script . Thanx

  2. #2
    Super Moderator MikeTbob's Avatar
    Join Date
    Apr 2006
    Location
    Texas
    Posts
    7,144
    Hello and Welcome.
    I moved your thread here because we generally lock threads older than 6 months. Feel free to continue here.
    I do not respond to private messages asking for Linux help, Please keep it on the forums only.
    All new users please read this.** Forum FAQS. ** Adopt an unanswered post.

  3. #3
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Quote Originally Posted by himanshu1 View Post
    Hi , In this case what is the return value of mount . I want to run e2fsck only when
    either mount fails or mount succeeded but with errors . Is there some way to detect
    this situatin "mounting fs with errors" in code/script . Thanx
    From the mount man page:
    Code:
    RETURN CODES
           mount has the following return codes (the bits can be ORed):
    
           0      success
    
           1      incorrect invocation or permissions
    
           2      system error (out of memory, cannot fork, no more loop devices)
    
           4      internal mount bug or missing nfs support in mount
    
           8      user interrupt
    
           16     problems writing or locking /etc/mtab
    
           32     mount failure
    
           64     some mount succeeded
    So, you can test the return code from mount in the system initialization scripts. Usually that would be /etc/rc.d/rc.sysinit, though it depends on the distribution+version of Linux that you are using. That is the case for Red Hat and RH derived systems such as CentOS. One thing however, is that this may not be simple to do. I just finished reviewing the file and am concerned that it would be very easy for you to fubar the system if you did it wrong - caveat administrator!
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  4. #4
    Just Joined!
    Join Date
    Nov 2010
    Posts
    3
    Thanx for replying . I checked the return value of mount in script , it returning success independent of whether it mounting with errors or without errors . Is there
    any option available with mount so that i can diffrentiate between two .

  5. #5
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Need more information about what is going on - what errors you are seeing and where/when. What happens if you manually remount the device. Etc.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  6. #6
    Just Joined!
    Join Date
    Nov 2010
    Posts
    3
    Message i am getting is
    EXT2-fs warning: mounting fs with errors, running e2fsck is recommended .

    Its not an error so device get mounted . I want to run e2fsck here , when i get this situation automatically . As for now i m running e2fsck every time before mounting device which in turn increases the boot time .

  7. #7
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Do you see anything regarding the errors that are occuring in the system logs (/var/log/messages, etc)?
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...