I have a file a.txt
.
If I delete the file and create an empty file with a.txt
at the same location, will that influence the inode details of old file? or will a new inode will get created?
It depends on your filesystem...
On ext4 I see the following: (inode reuse)
$ touch a.txt
$ stat -c%i a.txt
1316644
$ rm a.txt
$ touch a.txt
$ stat -c%i a.txt
1316644
On ZFS I see the following: (new inode assigned)
$ touch a.txt
$ stat -c%i a.txt
15585
$ rm a.txt
$ touch a.txt
$ stat -c%i a.txt
15586
stat -c%i ${FILENAME}
will show the inode for the given file.
Note that inodes are not typically created/destroyed, but rather exist in perpetuity and are used to either record file information or are marked as "unused".
Note also, that on an active system you cannot place any guarantee on the same inode being reused, as it may be used by another file between your deletion and creation. i.e: the delete/create operation is not atomic.
On ext4:
$ touch a.txt
$ stat -c%i a.txt
1316644
$ rm a.txt
$ touch b.txt
$ stat -c%i b.txt
1316644
$ touch a.txt
$ stat -c%i a.txt
1316645
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With