In the linux kernel, are there any data structures that automatically always hold the last written block number for a partition? I can't find any built-in kernel source that could be used to get this information. Any help is appreciated.
If you want to know the last block of a partition that has ever been writen by the system, you're probably not going to find that.
If what you want is to know where you could truncate a partition without loosing "useful" data, knowing the last writen block is not enough, since you would have to deal with the filesystem's structure so that it "knows" the size of the partition has change.
If your intention is being able to programaticaly resize a partition without data loss, I recommend using libparted for that.
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