Linux 内核 - 获取最后写入的内存块
在Linux内核中,是否有任何数据结构可以自动始终保存分区的最后写入的块号?我找不到任何可用于获取此信息的内置内核源代码。任何帮助表示赞赏。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想知道系统曾经写入的分区的最后一个块,您可能找不到它。
如果您想要知道在哪里可以截断分区而不丢失“有用”数据,那么知道最后写入的块是不够的,因为您必须处理文件系统的结构,以便它“知道”分区的大小有变化。
如果您的目的是能够以编程方式调整分区大小而不丢失数据,我建议使用 libparted< /a> 为此。
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.