curmudgeon Veteran

Joined: 08 Aug 2003 Posts: 1638
|
Posted: Tue Nov 20, 2018 1:49 am Post subject: How do I clear an inode? |
|
|
I am trying to do something that I thought would be quite simple, but which I now have spent some significant time trying to figure out (and haven't been able to do so yet).
The goal is straightforward - I want to zero out all of the unused inodes on a filesystem.
First, I have looked at sfill. It is unmaintained (the latest version is more than fifteen years old - before ext4 even existed), there are errors during the compilation, and (most important), it doesn't work (even as root):
Code: |
# ./sfill -illz /tmp/
Error: Could not remove temporary file /tmp/oooooooo.ooo!
|
The truly annoying thing is that clri doesn't even clear the inode:
Code: |
# touch /tmp/foo
# stat /tmp/foo
File: /tmp/foo
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 809h/2057d Inode: 620 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-11-20 00:33:46.600196466 +0000
Modify: 2018-11-20 00:33:46.600196466 +0000
Change: 2018-11-20 00:33:46.600196466 +0000
Birth: -
# rm /tmp/foo
# /sbin/debugfs /dev/sda9 -w
debugfs 1.43.9 (8-Feb-2018)
debugfs: stat <620>
Inode: 620 Type: regular Mode: 0644 Flags: 0x0
Generation: 4078927920 Version: 0x00000000:00000001
User: 0 Group: 0 Project: 0 Size: 0
File ACL: 0 Directory ACL: 0
Links: 0 Blockcount: 0
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x5bf356b2:33e918c4 -- Tue Nov 20 00:34:58 2018
atime: 0x5bf3566a:8f1915c8 -- Tue Nov 20 00:33:46 2018
mtime: 0x5bf3566a:8f1915c8 -- Tue Nov 20 00:33:46 2018
crtime: 0x5bf3566a:8f1915c8 -- Tue Nov 20 00:33:46 2018
dtime: 0x5bf356b2:(33e918c4) -- Tue Nov 20 00:34:58 2018
Size of extra inode fields: 32
BLOCKS:
debugfs: clri <620>
debugfs: stat <620>
Inode: 620 Type: bad type Mode: 0000 Flags: 0x0
Generation: 0 Version: 0x00000000:00000000
User: 0 Group: 0 Project: 0 Size: 0
File ACL: 0 Directory ACL: 0
Links: 0 Blockcount: 0
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x00000000:33e918c4 -- Thu Jan 1 00:00:00 1970
atime: 0x00000000:8f1915c8 -- Thu Jan 1 00:00:00 1970
mtime: 0x00000000:8f1915c8 -- Thu Jan 1 00:00:00 1970
crtime: 0x5bf3566a:8f1915c8 -- Tue Nov 20 00:33:46 2018
Size of extra inode fields: 32
BLOCKS:
|
I assume that behavior might come from having accepted the default extra_isize when creating the filesystem (a mistake I will NOT make again).
Surely some tool or method exists to set unused inodes to zero (other than zeroing out the entire filesystem, of course). |
|