{"id":70,"date":"2009-06-02T15:37:49","date_gmt":"2009-06-02T19:37:49","guid":{"rendered":"http:\/\/bitc.bme.emory.edu\/~lzhou\/blogs\/?p=70"},"modified":"2009-06-02T15:37:49","modified_gmt":"2009-06-02T19:37:49","slug":"fsck-couldnt-fix-parent-of-inode-couldnt-find-parent-directory-entry","status":"publish","type":"post","link":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/?p=70","title":{"rendered":"fsck: Couldn&#8217;t fix parent of inode : Couldn&#8217;t find parent directory entry"},"content":{"rendered":"<p>In linux file system, when file system error happens, the first choice is to do an fsck of the unmounted file system.<\/p>\n<p>Usually,<\/p>\n<p>fsck -y \/dev\/sdxx<\/p>\n<p>at boot time should be able to fix everything, if the FS has not been severely damaged.<\/p>\n<p>Occasionally, as reported as<\/p>\n<p>Debian bug list #478546 at<\/p>\n<p>http:\/\/groups.google.com\/group\/linux.debian.bugs.dist\/browse_thread\/thread\/dc48335d2ca42b66<\/p>\n<p>fsck returns error like:<br \/>\n<code><br \/>\nfsck 1.40.8 (13-Mar-2008)<br \/>\ne2fsck 1.40.8 (13-Mar-2008)<br \/>\nBackup contains a file system with errors, check forced.<br \/>\nPass 1: Checking inodes, blocks, and sizes<br \/>\nPass 2: Checking directory structure<br \/>\nPass 3: Checking directory connectivity<br \/>\n'..' in \/lost+found\/#122068977 (122068977) is &lt;The NULL inode&gt; (0),<br \/>\nshould be \/lost+found (11).<br \/>\nFix? yes<\/code><br \/>\n<code><br \/>\nCouldn't fix parent of inode 122068977: Couldn't find parent directory entry<\/code><br \/>\n<code><br \/>\nPass 4: Checking reference counts<br \/>\nPass 5: Checking group summary information<\/code><br \/>\n<code><br \/>\nBackup: ********** WARNING: Filesystem still has errors **********<\/code><br \/>\n<code><br \/>\nBackup: 14398872\/122077184 files (1.4% non-contiguous),<br \/>\n188901088\/244137600 blocks<\/code><\/p>\n<p>And, what ever you repeat fsck, or use e2fsprogs won&#8217;t help about this.<\/p>\n<p>Here I explain the cause of this and prresent a solution as following:<\/p>\n<p>[REASON]<\/p>\n<p>In the messed up FS, an orphaned inode with ZERO data length was labelled as a directory, and was restored into lost+found\/ on the alleged file system.<\/p>\n<p>However, for a valid directory entry, it cannot be ZERO length.\u00a0 It has to have at least two entries namely &#8216;.&#8217; linking to itself and &#8216;..&#8217; linking to its parent directory.\u00a0 However, since this directory entry has zero length, fsck failed creating &#8216;..&#8217; thus resulted the error<\/p>\n<p>&#8220;<code>Couldn't fix parent of inode 122068977: Couldn't find parent directory entry\"<\/code><\/p>\n<p>and resulted a fail of the fsck.<\/p>\n<p>[SOLUTION]<\/p>\n<p>When fsck is done, mount the FS.\u00a0 Then cd the lost+found\/ directory:<\/p>\n<p><code>mount #&lt;your mount point&gt;<br \/>\ncd #&lt;your mount point&gt;<br \/>\ncd lost+found<\/code><\/p>\n<p>If you do &#8216;ls -al&#8217;, you will see a directory with zero length named #&lt;the affected inode&gt;, like here #122068977.<\/p>\n<p>It usually has a weird owner and group number.<\/p>\n<p>You then do the following:<br \/>\n<code><br \/>\nchown root:root #&lt;the affected inode&gt;<br \/>\nchmod 755 #&lt;the affected inode&gt;<\/code><\/p>\n<p>This will make it look normal.<\/p>\n<p>Then<br \/>\n<code><br \/>\ncd #&lt;the affected inode&gt;<br \/>\ntouch test<br \/>\nrm test<br \/>\ncd #&lt;your mount point&gt;<\/code><\/p>\n<p>Note you cannot do<\/p>\n<p><code>cd ..<\/code><\/p>\n<p>still here since &#8216;..&#8217; does not exist yet.<\/p>\n<p>Then if you do<br \/>\n<code>ls -al<\/code><\/p>\n<p>again, the length of the directory #<code>&lt;the affected inode&gt; is no longer 0, but the default minimum length of your file system, say 4096, 8192, or 16384, etc.<\/code><\/p>\n<p>At this point, you can cd off the mounted filesystem, and umount it:<\/p>\n<p><code>cd ~<br \/>\numount #&lt;your mount point&gt;<\/code><\/p>\n<p>and fsck it:<br \/>\n<code>fsck -y \/dev\/&lt;your device&gt;<\/code><\/p>\n<p>It then will result:<br \/>\n<code><br \/>\nfsck 1.40.2 (12-Jul-2007)<br \/>\ne2fsck 1.40.2 (12-Jul-2007)<br \/>\n&lt;your FS&gt; was not cleanly unmounted, check forced.<br \/>\nPass 1: Checking inodes, blocks, and sizes<br \/>\nPass 2: Checking directory structure<br \/>\nMissing '.' in directory inode &lt;bad inode number&gt;.<br \/>\nFix? yes<\/code><br \/>\n<code><br \/>\nSetting filetype for entry '.' in ... (&lt;bad inode number&gt;) to 2.<br \/>\nMissing '..' in directory inode &lt;bad inode number&gt;.<br \/>\nFix? yes<\/code><br \/>\n<code><br \/>\nSetting filetype for entry '..' in ... (&lt;bad inode number&gt;) to 2.<br \/>\nPass 3: Checking directory connectivity<br \/>\n'..' in \/lost+found\/&lt;bad inode number&gt; (&lt;bad inode number&gt;) is<br \/>\n(0), should be \/lost+found (11).<br \/>\nFix? yes<\/code><br \/>\n<code><br \/>\nPass 4: Checking reference counts<br \/>\nInode 2 ref count is 6, should be 7.  Fix? yes<\/code><br \/>\n<code><br \/>\nInode 11 ref count is 4, should be 3.  Fix? yes<\/code><br \/>\n<code><br \/>\nInode &lt;bad inode number&gt; ref count is 1, should be 2.  Fix? yes<\/code><br \/>\n<code><br \/>\nPass 5: Checking group summary information<\/code><br \/>\n<code><br \/>\n&lt;your FS&gt;: ***** FILE SYSTEM WAS MODIFIED *****<br \/>\n&lt;your FS&gt;: 1882918\/91193344 files (0.3% non-contiguous), 111803861\/182339584 blocks<\/code><\/p>\n<p>This will save you from the risk of running a FS with errors or fully copy the file system elsewhere to recreate it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In linux file system, when file system error happens, the first choice is to do an fsck of the unmounted file system. Usually, fsck -y \/dev\/sdxx at boot time should be able to fix everything, if the FS has not been severely damaged. Occasionally, as reported as Debian bug list #478546 at http:\/\/groups.google.com\/group\/linux.debian.bugs.dist\/browse_thread\/thread\/dc48335d2ca42b66 fsck returns [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21,3],"tags":[],"class_list":["post-70","post","type-post","status-publish","format-standard","hentry","category-computer-tips","category-mri-technical-support","post-blog"],"_links":{"self":[{"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=\/wp\/v2\/posts\/70","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=70"}],"version-history":[{"count":0,"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=\/wp\/v2\/posts\/70\/revisions"}],"wp:attachment":[{"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=70"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=70"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=70"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}