Accedir disc virtual directament des del servidor proxmox (host)

Relacionat amb Proxmox: restaurant de backup

Hi ha una eina molt interessant que es diu qemu-nbd que permet muntar un disc qcow2 directament des del servidor proxmox (host) i sense associar-ho a cap VPS específic (guest).

En el següent cas d’ús, no sé per quin motiu hi havia un disc que no es podia reparar “des de dins de la màquina”, i en canvi, aquest mètode, sí que va funcionar.

Aquí teniu l’exemple de la reparació, però podria haver muntat /dev/nbd0 com a disc en un punt de muntatge del servidor

  [11:31:02] root@trax7:/etc/pve/qemu-server# modprobe nbd max_part=8
  [11:31:04] root@trax7:/etc/pve/qemu-server# qemu-nbd --connect=/dev/nbd0 /vm_nvme/images/131/vm-131-disk-1.qcow2
  [11:32:15] root@trax7:/etc/pve/qemu-server# lsblk /dev/nbd0
  NAME MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
  nbd0  43:0    0  600G  0 disk
  [11:32:18] root@trax7:/etc/pve/qemu-server# xfs_repair /dev/nbd0
  Phase 1 - find and verify superblock...
  Phase 2 - using internal log
          - zero log...
  ERROR: The filesystem has valuable metadata changes in a log which needs to
  be replayed.  Mount the filesystem to replay the log, and unmount it before
  re-running xfs_repair.  If you are unable to mount the filesystem, then use
  the -L option to destroy the log and attempt a repair.
  Note that destroying the log may cause corruption -- please attempt a mount
  of the filesystem before doing this.
  [11:32:27] root@trax7:/etc/pve/qemu-server# xfs_repair -L /dev/nbd0
  Phase 1 - find and verify superblock...
  Phase 2 - using internal log
          - zero log...
  ALERT: The filesystem has valuable metadata changes in a log which is being
  destroyed because the -L option was used.
          - scan filesystem freespace and inode maps...
          - found root inode chunk
  Phase 3 - for each AG...
          - scan and clear agi unlinked lists...
          - process known inodes and perform inode discovery...
          - agno = 0
          - agno = 1
          - agno = 2
          - agno = 3
          - agno = 4
          - process newly discovered inodes...
  Phase 4 - check for duplicate blocks...
          - setting up duplicate extent list...
          - check for inodes claiming duplicate blocks...
          - agno = 0
          - agno = 1
          - agno = 2
          - agno = 3
          - agno = 4
  Phase 5 - rebuild AG headers and trees...
          - reset superblock...
  Phase 6 - check inode connectivity...
          - resetting contents of realtime bitmap and summary inodes
          - traversing filesystem ...
          - traversal finished ...
          - moving disconnected inodes to lost+found ...
  Phase 7 - verify and correct link counts...
  Maximum metadata LSN (339:12643) is ahead of log (1:2).
  Format log to cycle 342.
  done
  [11:32:40] root@trax7:/etc/pve/qemu-server# xfs_repair -L /dev/nbd0
  Phase 1 - find and verify superblock...
  Phase 2 - using internal log
          - zero log...
          - scan filesystem freespace and inode maps...
          - found root inode chunk
  Phase 3 - for each AG...
          - scan and clear agi unlinked lists...
          - process known inodes and perform inode discovery...
          - agno = 0
          - agno = 1
          - agno = 2
          - agno = 3
          - agno = 4
          - process newly discovered inodes...
  Phase 4 - check for duplicate blocks...
          - setting up duplicate extent list...
          - check for inodes claiming duplicate blocks...
          - agno = 0
          - agno = 3
          - agno = 4
          - agno = 1
          - agno = 2
  Phase 5 - rebuild AG headers and trees...
          - reset superblock...
  Phase 6 - check inode connectivity...
          - resetting contents of realtime bitmap and summary inodes
          - traversing filesystem ...
          - traversal finished ...
          - moving disconnected inodes to lost+found ...
  Phase 7 - verify and correct link counts...
  Maximum metadata LSN (339:12643) is ahead of log (1:2).
  Format log to cycle 342.
  done
  [11:32:45] root@trax7:/etc/pve/qemu-server# xfs_repair /dev/nbd0
  Phase 1 - find and verify superblock...
  Phase 2 - using internal log
          - zero log...
          - scan filesystem freespace and inode maps...
          - found root inode chunk
  Phase 3 - for each AG...
          - scan and clear agi unlinked lists...
          - process known inodes and perform inode discovery...
          - agno = 0
          - agno = 1
          - agno = 2
          - agno = 3
          - agno = 4
          - process newly discovered inodes...
  Phase 4 - check for duplicate blocks...
          - setting up duplicate extent list...
          - check for inodes claiming duplicate blocks...
          - agno = 0
          - agno = 2
          - agno = 3
          - agno = 4
          - agno = 1
  Phase 5 - rebuild AG headers and trees...
          - reset superblock...
  Phase 6 - check inode connectivity...
          - resetting contents of realtime bitmap and summary inodes
          - traversing filesystem ...
          - traversal finished ...
          - moving disconnected inodes to lost+found ...
  Phase 7 - verify and correct link counts...
  done
  [11:32:50] root@trax7:/etc/pve/qemu-server# xfs_repair /dev/nbd0
  Phase 1 - find and verify superblock...
  Phase 2 - using internal log
          - zero log...
          - scan filesystem freespace and inode maps...
          - found root inode chunk
  Phase 3 - for each AG...
          - scan and clear agi unlinked lists...
          - process known inodes and perform inode discovery...
          - agno = 0
          - agno = 1
          - agno = 2
          - agno = 3
          - agno = 4
          - process newly discovered inodes...
  Phase 4 - check for duplicate blocks...
          - setting up duplicate extent list...
          - check for inodes claiming duplicate blocks...
          - agno = 0
          - agno = 3
          - agno = 2
          - agno = 4
          - agno = 1
  Phase 5 - rebuild AG headers and trees...
          - reset superblock...
  Phase 6 - check inode connectivity...
          - resetting contents of realtime bitmap and summary inodes
          - traversing filesystem ...
          - traversal finished ...
          - moving disconnected inodes to lost+found ...
  Phase 7 - verify and correct link counts...
  done
  [11:32:54] root@trax7:/etc/pve/qemu-server# qemu-nbd --disconnect /dev/nbd0
  /dev/nbd0 disconnected

Altres referències