【问题标题】:Changing qcow2 st_ctime改变 qcow2 st_ctime
【发布时间】:2018-05-06 12:59:20
【问题描述】:

有没有办法修改 qcow2 图像的 st_ctime_sec 属性?

我正在尝试构建一个可重现的 qcow2 版本,最终目标是我可以重新创建 qcow2 文件,并且仍然具有字节对字节相同的内容。

我很沮丧,因为我的原始版本和复制版本之间的 ctime 不同。

使用 virt-diff -a orig.qcow2 -A rebuild.qcow2 --atime --dir-times --times 我只得到如下区别:

更改:st_ctime_sec

  • d 0755 4096 2017-11-21 22:35:00 2017-11-21 22:35:00 2017-11-22 02:34:36 /boot/efi/EFI
  • d 0755 4096 2017-11-21 22:35:00 2017-11-21 22:35:00 2017-11-22 11:10:48 /boot/efi/EFI

我找到了一个可以作为 root 运行的解决方案,但我正在寻找可以作为普通用户运行的解决方案。

来自mount qcow as device

 modprobe nbd max_part=8
 qemu-nbd -c /dev/nbd0 guest.img
 mount /dev/nbd0p1 /mnt/guest

然后来自change ctime

debugfs -w  /dev/sda1 < changes

其中更改包含类似的行

set_inode_field /grub2/locale/ast.mo ctime 201001010101
set_inode_field /grub2/locale/ca.mo ctime 201001010101
set_inode_field /grub2/locale/da.mo ctime 201001010101
set_inode_field /grub2/locale/de.mo ctime 201001010101

【问题讨论】:

    标签: qemu guest-executable


    【解决方案1】:

    您可以使用 libguestfs API guestfs_utimens 执行 atime 和 mtime。但是 ctime 不能用 libguestfs 设置,主要是因为it appears there is not a "good" way to do it in Linux。您可以将 debugfs 方法编码为新的 libguestfs API(或使用调试后门)。或者,如果您的图像是原始文件系统(不是 qcow2),您可以直接在其上运行 debugfs,然后使用 guestfs 上传 API(与 this 相反)将原始文件系统复制到最终图像中。

    【讨论】:

      猜你喜欢
      • 2012-09-11
      • 2022-06-12
      • 1970-01-01
      • 1970-01-01
      • 2012-01-14
      • 1970-01-01
      • 2023-03-07
      • 2014-07-26
      • 1970-01-01
      相关资源
      最近更新 更多