How to perform full check of ext4 file system structure?












20















I have 2TB ext4 partition with half million files on it.

I want to check whether this partition contains any errors or not.

I don't want to search for bad blocks, only logical structure should be checked.



I have unmounted the partition and run fsck /dev/sda2, but fsck returns immediately with exit code 0 without actually checking whole file system.

I'm expecting full partition check would take hours to complete.

I have read man fsck but did not find an option for "thorough testing".



I'm afraid my partition may have some sectors accidentally overwritten by garbage data.

My HDD was previously connected to another OS, and ext4 partition may get harmed by wrong behavior of that OS.

That's why I want to be sure the whole tree structure is completely correct.



In other words, I want to perform a check similar to what utility chkdsk.exe does on Windows.

What should I use on Debian to completely check ext4 file system?










share|improve this question


















  • 1





    @SatoKatsura - Thanks! I just wonder why e2fsck -f check is so fast - it takes only several seconds? It's amazing compared to Windows behavior (it takes hours).

    – Egor Skriptunoff
    Feb 24 '17 at 10:30


















20















I have 2TB ext4 partition with half million files on it.

I want to check whether this partition contains any errors or not.

I don't want to search for bad blocks, only logical structure should be checked.



I have unmounted the partition and run fsck /dev/sda2, but fsck returns immediately with exit code 0 without actually checking whole file system.

I'm expecting full partition check would take hours to complete.

I have read man fsck but did not find an option for "thorough testing".



I'm afraid my partition may have some sectors accidentally overwritten by garbage data.

My HDD was previously connected to another OS, and ext4 partition may get harmed by wrong behavior of that OS.

That's why I want to be sure the whole tree structure is completely correct.



In other words, I want to perform a check similar to what utility chkdsk.exe does on Windows.

What should I use on Debian to completely check ext4 file system?










share|improve this question


















  • 1





    @SatoKatsura - Thanks! I just wonder why e2fsck -f check is so fast - it takes only several seconds? It's amazing compared to Windows behavior (it takes hours).

    – Egor Skriptunoff
    Feb 24 '17 at 10:30
















20












20








20


5






I have 2TB ext4 partition with half million files on it.

I want to check whether this partition contains any errors or not.

I don't want to search for bad blocks, only logical structure should be checked.



I have unmounted the partition and run fsck /dev/sda2, but fsck returns immediately with exit code 0 without actually checking whole file system.

I'm expecting full partition check would take hours to complete.

I have read man fsck but did not find an option for "thorough testing".



I'm afraid my partition may have some sectors accidentally overwritten by garbage data.

My HDD was previously connected to another OS, and ext4 partition may get harmed by wrong behavior of that OS.

That's why I want to be sure the whole tree structure is completely correct.



In other words, I want to perform a check similar to what utility chkdsk.exe does on Windows.

What should I use on Debian to completely check ext4 file system?










share|improve this question














I have 2TB ext4 partition with half million files on it.

I want to check whether this partition contains any errors or not.

I don't want to search for bad blocks, only logical structure should be checked.



I have unmounted the partition and run fsck /dev/sda2, but fsck returns immediately with exit code 0 without actually checking whole file system.

I'm expecting full partition check would take hours to complete.

I have read man fsck but did not find an option for "thorough testing".



I'm afraid my partition may have some sectors accidentally overwritten by garbage data.

My HDD was previously connected to another OS, and ext4 partition may get harmed by wrong behavior of that OS.

That's why I want to be sure the whole tree structure is completely correct.



In other words, I want to perform a check similar to what utility chkdsk.exe does on Windows.

What should I use on Debian to completely check ext4 file system?







debian partition fsck






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 24 '17 at 9:49









Egor SkriptunoffEgor Skriptunoff

1611318




1611318








  • 1





    @SatoKatsura - Thanks! I just wonder why e2fsck -f check is so fast - it takes only several seconds? It's amazing compared to Windows behavior (it takes hours).

    – Egor Skriptunoff
    Feb 24 '17 at 10:30
















  • 1





    @SatoKatsura - Thanks! I just wonder why e2fsck -f check is so fast - it takes only several seconds? It's amazing compared to Windows behavior (it takes hours).

    – Egor Skriptunoff
    Feb 24 '17 at 10:30










1




1





@SatoKatsura - Thanks! I just wonder why e2fsck -f check is so fast - it takes only several seconds? It's amazing compared to Windows behavior (it takes hours).

– Egor Skriptunoff
Feb 24 '17 at 10:30







@SatoKatsura - Thanks! I just wonder why e2fsck -f check is so fast - it takes only several seconds? It's amazing compared to Windows behavior (it takes hours).

– Egor Skriptunoff
Feb 24 '17 at 10:30












3 Answers
3






active

oldest

votes


















24














As mentioned by Satō Katsura, run e2fsck in "force" mode:



e2fsck -f /dev/sda2


This will force a check even if the system thinks the file system is clean. The "verbose" option is helpful too:



e2fsck -vf /dev/sda2


As a side-note, and not applicable in your case, but if you use LVM for your storage you can use the neat little lvcheck tool to run an "offline" file system check on a mounted file system (it uses an LVM snapshot and updates the file system metadata if the check doesn't find any errors).






share|improve this answer

































    5














    Also, you could add the -y flag to avoid answering questions.



    From the manual:




    -y assume an answer of yes to all questions; allows e2fsck to be used non-interactively.




    So extending the answer (since I cannot comment yet) from @Sato - you could run:



    e2fsck -vfy /dev/sda2





    share|improve this answer





















    • 5





      That can be risky though, because you don't know in advance what you may get asked, and forcing a yes answer to everything could in the worst case lead to loss of otherwise recoverable data.

      – Alex
      Feb 24 '17 at 13:10



















    0














    You can also check live file systems in read-only mode with this:



    e2fsck -vfn /dev/sda2





    share|improve this answer























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "106"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f347280%2fhow-to-perform-full-check-of-ext4-file-system-structure%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      24














      As mentioned by Satō Katsura, run e2fsck in "force" mode:



      e2fsck -f /dev/sda2


      This will force a check even if the system thinks the file system is clean. The "verbose" option is helpful too:



      e2fsck -vf /dev/sda2


      As a side-note, and not applicable in your case, but if you use LVM for your storage you can use the neat little lvcheck tool to run an "offline" file system check on a mounted file system (it uses an LVM snapshot and updates the file system metadata if the check doesn't find any errors).






      share|improve this answer






























        24














        As mentioned by Satō Katsura, run e2fsck in "force" mode:



        e2fsck -f /dev/sda2


        This will force a check even if the system thinks the file system is clean. The "verbose" option is helpful too:



        e2fsck -vf /dev/sda2


        As a side-note, and not applicable in your case, but if you use LVM for your storage you can use the neat little lvcheck tool to run an "offline" file system check on a mounted file system (it uses an LVM snapshot and updates the file system metadata if the check doesn't find any errors).






        share|improve this answer




























          24












          24








          24







          As mentioned by Satō Katsura, run e2fsck in "force" mode:



          e2fsck -f /dev/sda2


          This will force a check even if the system thinks the file system is clean. The "verbose" option is helpful too:



          e2fsck -vf /dev/sda2


          As a side-note, and not applicable in your case, but if you use LVM for your storage you can use the neat little lvcheck tool to run an "offline" file system check on a mounted file system (it uses an LVM snapshot and updates the file system metadata if the check doesn't find any errors).






          share|improve this answer















          As mentioned by Satō Katsura, run e2fsck in "force" mode:



          e2fsck -f /dev/sda2


          This will force a check even if the system thinks the file system is clean. The "verbose" option is helpful too:



          e2fsck -vf /dev/sda2


          As a side-note, and not applicable in your case, but if you use LVM for your storage you can use the neat little lvcheck tool to run an "offline" file system check on a mounted file system (it uses an LVM snapshot and updates the file system metadata if the check doesn't find any errors).







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Oct 4 '18 at 9:44

























          answered Feb 24 '17 at 9:55









          Stephen KittStephen Kitt

          174k24399475




          174k24399475

























              5














              Also, you could add the -y flag to avoid answering questions.



              From the manual:




              -y assume an answer of yes to all questions; allows e2fsck to be used non-interactively.




              So extending the answer (since I cannot comment yet) from @Sato - you could run:



              e2fsck -vfy /dev/sda2





              share|improve this answer





















              • 5





                That can be risky though, because you don't know in advance what you may get asked, and forcing a yes answer to everything could in the worst case lead to loss of otherwise recoverable data.

                – Alex
                Feb 24 '17 at 13:10
















              5














              Also, you could add the -y flag to avoid answering questions.



              From the manual:




              -y assume an answer of yes to all questions; allows e2fsck to be used non-interactively.




              So extending the answer (since I cannot comment yet) from @Sato - you could run:



              e2fsck -vfy /dev/sda2





              share|improve this answer





















              • 5





                That can be risky though, because you don't know in advance what you may get asked, and forcing a yes answer to everything could in the worst case lead to loss of otherwise recoverable data.

                – Alex
                Feb 24 '17 at 13:10














              5












              5








              5







              Also, you could add the -y flag to avoid answering questions.



              From the manual:




              -y assume an answer of yes to all questions; allows e2fsck to be used non-interactively.




              So extending the answer (since I cannot comment yet) from @Sato - you could run:



              e2fsck -vfy /dev/sda2





              share|improve this answer















              Also, you could add the -y flag to avoid answering questions.



              From the manual:




              -y assume an answer of yes to all questions; allows e2fsck to be used non-interactively.




              So extending the answer (since I cannot comment yet) from @Sato - you could run:



              e2fsck -vfy /dev/sda2






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Feb 24 '17 at 11:22









              GAD3R

              26.9k1757112




              26.9k1757112










              answered Feb 24 '17 at 10:13









              impalleimpalle

              964




              964








              • 5





                That can be risky though, because you don't know in advance what you may get asked, and forcing a yes answer to everything could in the worst case lead to loss of otherwise recoverable data.

                – Alex
                Feb 24 '17 at 13:10














              • 5





                That can be risky though, because you don't know in advance what you may get asked, and forcing a yes answer to everything could in the worst case lead to loss of otherwise recoverable data.

                – Alex
                Feb 24 '17 at 13:10








              5




              5





              That can be risky though, because you don't know in advance what you may get asked, and forcing a yes answer to everything could in the worst case lead to loss of otherwise recoverable data.

              – Alex
              Feb 24 '17 at 13:10





              That can be risky though, because you don't know in advance what you may get asked, and forcing a yes answer to everything could in the worst case lead to loss of otherwise recoverable data.

              – Alex
              Feb 24 '17 at 13:10











              0














              You can also check live file systems in read-only mode with this:



              e2fsck -vfn /dev/sda2





              share|improve this answer




























                0














                You can also check live file systems in read-only mode with this:



                e2fsck -vfn /dev/sda2





                share|improve this answer


























                  0












                  0








                  0







                  You can also check live file systems in read-only mode with this:



                  e2fsck -vfn /dev/sda2





                  share|improve this answer













                  You can also check live file systems in read-only mode with this:



                  e2fsck -vfn /dev/sda2






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Feb 17 at 17:27









                  AttilaAttila

                  1




                  1






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f347280%2fhow-to-perform-full-check-of-ext4-file-system-structure%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

                      is 'sed' thread safe

                      How to make a Squid Proxy server?