Skip to content

Instantly share code, notes, and snippets.

@poespas
Last active March 24, 2026 08:37
Show Gist options
  • Select an option

  • Save poespas/3596bac5e43177f31cbf47fc40b33412 to your computer and use it in GitHub Desktop.

Select an option

Save poespas/3596bac5e43177f31cbf47fc40b33412 to your computer and use it in GitHub Desktop.
Transform an physical disk into a VM

Transform an physical disk into a VM

Commands are ran from a liveUSB

Transfer raw image to external host

Use compression over the network, but extract on target

sudo dd if=/dev/nvme0n1 bs=256M status=progress | pigz -c -p 4 | ssh [user]@[host] "gunzip -c > /mnt/disks/dev-nvme0n1.img"

Transfer compressed image (.gz) to external host

sudo dd if=/dev/nvme0n1 bs=256M status=progress | pigz -c -p 4 | ssh [user]@[host] "cat > /mnt/disks/dev-nvme0n1.img.gz"

Convert disk to qcow2 format

$ qemu-img convert -f raw -O qcow2 /mnt/disks/dev-nvme0n1.img /mnt/disks/dev-nvme0n1.qcow2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment