Notebook

これは日々の作業を通して学んだことや毎日の生活で気づいたことをを記録しておく備忘録である。

HTML ファイル生成日時: 2024/09/11 17:53:24.921 (台灣標準時)

不意にクラッシュしても仮想機械のファイルが失われないようにする対策

せっかく仮想機械をインストールして、よく使うソフトウェアをコンパイルし たのでござるが、ホストの機械がクラッシュしてしまい、それに伴い仮想機械 の中の一部のファイルが失われてしまったでござる。今回は、 NetBSD で NVMM と QEMU を使って動かしていた仮想機械でファイルが失われるという問 題が起きたのでござるが、以前に Debian GNU/Linux で KVM と QEMU を使っ て動かしていた仮想機械でも同様の問題が起きていたように思うでござる。何 をどうすればよかったのか調べてみたでござる。

キャッシュの問題だったような気がしたので、 QEMU のマニュアルを読んでみ たでござる。以下のような記述を見つけたでござる。

fig_202408/man_qemu_00.png
fig_202408/man_qemu_01.png
fig_202408/man_qemu_02.png

QEMU を実行するときに、 "-drive" オプションに "cache=directsync" 或いは "cache=writethrough" を 与えるのがよさそうでござる。以下のようにしてみたでござる。


/usr/pkg/bin/qemu-system-x86_64 \
  -accel nvmm \
  -cpu max -smp cpus=6 -m 8G \
  -display none \
  -drive file=/vm/netbsd_01/netbsd_01.qcow2,if=none,id=hd0,cache=directsync \
  -device virtio-blk-pci,drive=hd0 \
  -object rng-random,filename=/dev/urandom,id=viornd0 \
  -device virtio-rng-pci,rng=viornd0 \
  -netdev tap,id=tap0,ifname=tap0,script=no -device virtio-net-pci,netdev=tap0,mac=0a:12:34:56:78:90 \
  -spice addr=localhost,port=5999,ipv4=on,disable-ticketing=on,seamless-migration=on \
  -daemonize

参考文献



Frequently accessed files

  1. Computer___Python/20220518_0.html
  2. Computer___Network/20230726_00.html
  3. Computer___Network/20230516_00.html
  4. Computer___FreeBSD/20220621_0.html
  5. Misc___Taiwan/20240207_00.html
  6. Computer___Python/20220715_0.html
  7. Food___Taiwan/20220429_0.html
  8. Computer___Network/20230508_00.html
  9. Computer___NetBSD/20220817_3.html
  10. Computer___Python/20220410_0.html
  11. Computer___Debian/20210223_1.html
  12. Computer___Python/20210124_0.html
  13. Computer___NetBSD/20220818_1.html
  14. Computer___NetBSD/20220428_0.html
  15. Computer___Python/20221013_0.html
  16. Science___Math/20220420_0.html
  17. Computer___NetBSD/20230119_00.html
  18. Computer___Network/20240416_00.html
  19. Computer___Network/20240130_00.html
  20. Science___Astronomy/20220503_0.html
  21. Computer___TeX/20230503_00.html
  22. Computer___NetBSD/20220808_0.html
  23. Computer___NetBSD/20230515_00.html
  24. Computer___NetBSD/20240101_02.html
  25. Computer___NetBSD/20210204_0.html
  26. Travel___Taiwan/20220809_2.html
  27. Computer___Python/20220816_1.html
  28. Science___Astronomy/20220420_1.html
  29. Food___Taiwan/20230526_00.html
  30. Computer___Python/20240101_00.html


HTML file generated by Kinoshita Daisuke.