Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux Kernel - Get last written memory block

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.

like image 783
NTek Avatar asked Apr 06 '10 00:04

NTek


1 Answers

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.

like image 133
goedson Avatar answered Oct 04 '22 05:10

goedson