How to fix a corrupt ext3 directory? (Solved)

Issues and / or general discussion relating to Puppy

Moderator: Forum moderators

Post Reply
Clif McIrvin
Posts: 13
Joined: Sat Jan 02, 2021 2:13 am
Has thanked: 5 times

How to fix a corrupt ext3 directory? (Solved)

Post by Clif McIrvin »

(I hope this is the right place for this question.)
I have managed to create a corrupt Directory on an ext3 partition. Corrupt in the sense that pathnames get too long, and I am unable to rmdir the offending directory; not corrupt in the sense that inodes are broken - at least not that I have seen evidence of. When I try to delete the directory using ROX-Filer I get

Code: Select all

...
ERROR: Directory not empty
ERROR: Directory not empty
ERROR: Directory not empty

Done
There were 382 errors.

which suggests to me this directory tree is somewhat more than 382 layers deep -- not counting the layers traversed before the first error.

What happened is that I somehow managed to launch a malformed mkdir -p script I was working on in Geany. I'm pretty certain I know when it happened, but not at all certain how I did it. That's not the point - I at least know to be more careful about what I'm doing with the mouse!

Long time windoze user- fairly accomplished DOS BAT scripter; just not well versed with Linux scripting and filesystems. I'm thinking that if I could force the release of the inode at the top of the corruption and then recover all the 'missing' inodes below that my problem would go away.

My problem is a) I don't know how to do that and b) is this even a valid, or reasonable, idea?

Advice appreciated!
Clif

williams2
Posts: 1062
Joined: Sat Jul 25, 2020 5:45 pm
Been thanked: 305 times

Re: Can I fix a corrupt Directory?

Post by williams2 »

You can debug a file system. that is NOT mounted, not in use.

Code: Select all

debugfs /dev/sda4

Use the correct partition device name, of course.

Type help

clri root/.thumbnails

would remove the /root/.thumbnails directory, and sub directories, effectively deleting the dir.
Use the path of the dir that you want to delete, of course.

Type q to quit debugfs.

fsck the file system to regain the lost space.

User avatar
bigpup
Moderator
Posts: 6997
Joined: Tue Jul 14, 2020 11:19 pm
Location: Earth, South Eastern U.S.
Has thanked: 913 times
Been thanked: 1528 times

Re: Can I fix a corrupt Directory?

Post by bigpup »

Not sure if this will help.
Could try a e2fsck on the partition the directory is on.
Will have to have the partition unmounted.
If it is the partition Puppy is on and booting from.
Will have to boot a Puppy version on some other partition or drive, so this one is not mounted.
To do the whole partition:
Need to boot from a live Puppy or a Puppy on a different partition to do a partition check.
(the partition must be unmounted)
Example:
partition sda1
In a terminal/console:
e2fsck /dev/sda1

The things you do not tell us, are usually the clue to fixing the problem.
When I was a kid, I wanted to be older.
This is not what I expected :o

williams2
Posts: 1062
Joined: Sat Jul 25, 2020 5:45 pm
Been thanked: 305 times

Re: Can I fix a corrupt Directory?

Post by williams2 »

You do know that rmdir works on empty dirs?

To delete a dir that is not empty, do this:

rm -r /path/of/the/dir

Be very careful to get the path right, for example, be careful of spaces in dir names.

It's safer to:

ls /path/of/the/dir

then change the ls to rm -r /path/of/the/dir

But Rox should do it properly.

Clif McIrvin
Posts: 13
Joined: Sat Jan 02, 2021 2:13 am
Has thanked: 5 times

Re: Can I fix a corrupt Directory?

Post by Clif McIrvin »

@williams2 No I did not realize that rmdir was restricted to empty dirs. I thought that's what --ignore-fail-on-non-empty was for. Now that you point it out I see my misunderstanding.

If I had ever come across rm I'd forgotten about it. rm -r -d dirname worked just fine - perhaps the -d wasn't necessary but it seemed worth adding. I used the ~ ROX-Filer hotkey to open a terminal console to set the pwd so ls dirname (and rm dirname) were pointing to the directory in question.

debugfs ... I'll want to remember that!

Perhaps if I'd searched for "remove directory" I'd have saved the question - so a big THANK YOU for the tutorial.

@bigpup e2fsck looks like another tool I need to remember.

Hopefully my subject makes this thread useful to someone in the future!

Thanks to both of you.
Clif

Post Reply

Return to “Users”