Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

强制关机,虚拟机内容恢复到几天前

Featured Replies

今天凌晨发现 unraid 突然未知原因无法访问了.只好强制关机重启了.

但是启动后发现虚拟机里的内容变成几天前的了,因为我虚拟机里每天会下载文件,最新的文件就是 12 号的.近期改的代码也丢失了.

存放虚拟机的磁盘是 btrfs 格式的,虚拟机镜像是 qcow2格式的.也没有快照

什么原理会导致虚拟机回滚了呢?难道这么多天的修改都没有存到虚拟机磁盘镜像是在内存中吗?

 

Solved by JackieWu

  • Solution
4 hours ago, il0z0li said:

什么原理会导致虚拟机回滚了呢?难道这么多天的修改都没有存到虚拟机磁盘镜像是在内存中吗?

 

在 Unraid 上面,默认情况下,当虚拟机的程序往虚拟硬盘里面写入数据的时候(也就是往物理硬盘写入数据时),Unraid 的内存会提供一个缓存加速的作用,所以理论上会出现内存里面的缓存数据还没有来得及写入到物理硬盘,但此时 Unraid 因某些原因被关闭(例如断电,强制重启),从而导致内存里面的数据被清空,数据没有被写入到物理硬盘,从而导致数据丢失。

 

这个特性体现在虚拟机 XML 模板中关于虚拟硬盘的参数中:

Snipaste_2024-04-19_21-13-52.png

 

    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writeback'/>
      <source file='/mnt/cache/vdisk/alpine/alpine-vdisk-1.img'/>
      <target dev='hdc' bus='virtio'/>
      <serial>vdisk1</serial>
      <boot order='1'/>
      <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
    </disk>

 

你可以将值由“writeback”修改为“writethrough”或者“directsync”,参考资料:opensuse - Disk cache modesKVM虚拟化中不同缓存模式的速度测试

Edited by JackieWu

  • Author
3 hours ago, JackieWu said:

 

默认情况下,当你往虚拟硬盘里面写入数据的时候,Unraid 的内存会提供一个缓存的作用,所以理论上会出现内存里面的数据还没有来得及写入到虚拟硬盘但此时虚拟机因某些原因被关闭从而导致数据丢失的情况。

 

这个特性体现在虚拟机 XML 模板中关于虚拟硬盘的参数中:

Snipaste_2024-04-19_21-13-52.png

 

    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writeback'/>
      <source file='/mnt/cache/vdisk/alpine/alpine-vdisk-1.img'/>
      <target dev='hdc' bus='virtio'/>
      <serial>vdisk1</serial>
      <boot order='1'/>
      <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
    </disk>

 

你可以将值由“writeback”修改为“writethrough”或者“directsync”,参考资料:opensuse - Disk cache modesKVM虚拟化中不同缓存模式的速度测试

厉害了,还有这种高级特性.

43 minutes ago, il0z0li said:

厉害了,还有这种高级特性.

 

但是如果是丢失了几天前的文件,那可能不是这个特性导致的。

  • Author
17 hours ago, JackieWu said:

 

但是如果是丢失了几天前的文件,那可能不是这个特性导致的。

用了几年了,也不少次突然断电或强制关机的.没发现过这种情况.我内存有 72G是不是就缓存的久一些了.这个只能再观察了.再定时快照下保险点.

倒是最近 docker 的镜像文件总是损坏,导致需要删除然后重新下载所有应用

  • 1 year later...

虚拟机的快照怎么恢复?找了一圈也没看到这个选项……

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.