Skip to content

Bolo101/disk2qcow2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

158 Commits
 
 
 
 
 
 
 
 

Repository files navigation

P2V Converter – Turn Physical Machines into Virtual Ones

Transform physical disks into qcow2 virtual machine images ready for any hypervisor. Safety-focused tool with intuitive GUI, preventing accidental imaging of running systems. Build a bootable ISO for safe offline conversion of any physical machine.


Features

Core Conversion

  • Converts physical disks to compressed qcow2 images
  • Real-time progress tracking with cancel capability
  • Blocks conversion of active system disks and mounted partitions
  • Intelligent space analysis based on actual usage
  • Comprehensive logging to /var/log/disk2qcow2.log

Advanced Tools

  • QCOW2 Resizer: Optimize virtual disk size
  • Format Converter: Convert between qcow2, vmdk, vdi, vpc, vhdx, raw
  • LUKS Encryption: Secure VMs with password-protected containers
  • Export Manager: Transfer images via RSYNC
  • File Manager: Workspace cleanup
  • Virt-Manager Integration: Direct VM management
  • External Storage Support: Mount and use external drives

Supported Operating Systems

  • Windows (all versions - XP through 11, Server editions)
  • Linux (all distributions - Ubuntu, Debian, Fedora, CentOS, Arch, etc.)

Quick Start

Download Pre-built ISO (Recommended)

Download P2V Converter ISO

f64933b9c944f753f81999a0eea20a238c808e6cac98ca85db6b8f43a5be5ae6  p2vConverter-v1.0-KDE-32bits.iso
782faa1ce20c52def6bf8dc9fa21217016216b0f0c8a4a2b34349712a719fb66  p2vConverter-v1.0-KDE-64bits.iso
b16b2db810c8dd476891bbd70a109748647b3edf2567c47b931c249b9fea4e6f  p2vConverter-v1.0-XFCE-32bits.iso
ca22d449e7b094e6d5d0e16ead44e7795a125a9a47487b0a6740b180fa63a6cf  p2vConverter-v1.0-XFCE-64bits.iso

Select ISO version you need, 32 bits or 64 bits, XFCE (lighter) or KDE.

Or Build Your Own

cd iso/
make
make xfce32  # 32 bits XFCE environment (lighter)
make kde     # KDE 64 bits environment
make kde32   # KDE 32 bits environment
make all-iso # All 4 ISOs generated
make clean   # Clean build files
make help    # Display helper message

Requirements

ISO Method (Recommended - No Configuration)

  • USB drive (8GB+) or DVD
  • External storage drive for output
  • No additional setup needed

Native Installation

Ubuntu/Debian:

sudo apt install qemu-utils python3-tk gparted rsync cryptsetup virt-manager libvirt-daemon-system

Fedora/CentOS/RHEL:

sudo dnf install qemu-img python3-tkinter gparted rsync cryptsetup virt-manager libvirt

⚠️ Critical for External Storage: Configure libvirt to access external drives:

sudo nano /etc/libvirt/qemu.conf

# Add/modify these lines:
user = "root"
group = "root"

cgroup_device_acl = [
    "/dev/null", "/dev/full", "/dev/zero",
    "/dev/random", "/dev/urandom",
    "/dev/ptmx", "/dev/kvm",
    "/dev/rtc", "/dev/hpet",
    "/dev/sdb", "/dev/sdc", "/dev/sdd",  # Your external drives
    "/dev/disk/by-uuid/*"
]
sudo systemctl restart libvirtd
sudo usermod -a -G libvirt $USER

Usage Workflow

1. Boot from ISO

  • Write ISO to USB: sudo dd if=p2v-converter.iso of=/dev/sdX bs=4M status=progress (or use Ventoy key)
  • Boot target machine from USB

2. Connect External Storage

  • Plug in external USB drive (don't mount manually)

Mount External Storage:

  • Click "Mount Disk" button
  • Select your external drive
  • Click "Mount Selected Disk"
  • Output directory updates automatically

3. Configure Conversion

Select Source:

  • Click "Refresh Disks"
  • Select disk to convert (system disks blocked for safety)

Verify Space:

  • Click "Check Space Requirements"
  • Green indicator = sufficient space

4. Convert

  • Click "Start P2V Conversion"
  • Monitor progress (cancel anytime if needed)
  • Typical time: 30-120 minutes depending on size and system

5. Optional Post-Processing

  • "QCOW2 Resize": Optimize disk size (change filesystem size, reduce virtual size and compress virtual image)
  • "LUKS Encryption": Secure with password
  • "Format Converter": Convert to VMDK/VDI/VHD
  • "Export Image": Transfer via RSYNC
  • "Print Session Log": Generate PDF report

Running Converted VMs

Using virt-manager

# From ISO (auto-configured) or native installation:
virt-manager

# Then in GUI:
# 1. New VM → Import existing disk image
# 2. Browse to .qcow2 file
# 3. Select OS type (Windows or Linux)
# 4. Choose firmware:
#    - UEFI for modern systems (2010+)
#    - BIOS for legacy systems
# 5. DISABLE Secure Boot
# 6. Start VM

Using QEMU CLI

BIOS boot:

qemu-system-x86_64 -m 4096 -drive file=vm.qcow2,format=qcow2 -enable-kvm

UEFI boot:

qemu-system-x86_64 -m 4096 \
  -drive file=vm.qcow2,format=qcow2 \
  -drive if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE.fd \
  -enable-kvm

From external drive:

sudo mount /dev/sdb1 /mnt/external
qemu-system-x86_64 -m 4096 -drive file=/mnt/external/vm.qcow2,format=qcow2 -enable-kvm

Format Conversion

Platform Format Command
VMware vmdk qemu-img convert -f qcow2 -O vmdk src.qcow2 output.vmdk
VirtualBox vdi qemu-img convert -f qcow2 -O vdi src.qcow2 output.vdi
Hyper-V vhdx qemu-img convert -f qcow2 -O vhdx src.qcow2 output.vhdx
Generic raw qemu-img convert -f qcow2 -O raw src.qcow2 output.img

Or use the GUI "Format Converter" tool.


Troubleshooting

Common Issues

"Disk Unavailable"

  • Boot from ISO to convert system disks
  • Unmount partitions: sudo umount /dev/sdX1

"Insufficient Space"

  • Use "Mount Disk" for larger external drive
  • Check available space matches requirement

"Cannot Mount External Drive"

  • Verify detection: lsblk
  • Unmount if already mounted: sudo umount /dev/sdX1

"VM Won't Boot"

  • Try both UEFI and BIOS modes
  • Disable Secure Boot
  • Windows may need reactivation after conversion

"Permission Denied" (native installation)

  • Configure libvirt as shown in Requirements
  • Or run with: sudo python3 code/main.py

"External Drive VM Fails to Start"

  • Native installation: Configure libvirt cgroup_device_acl
  • ISO method: No configuration needed

Windows-Specific Issues

"Windows requires activation"

  • Normal after hardware change
  • Use original product key to reactivate or slmgr /rearm command

"Missing drivers after boot"

  • Install virtio drivers in guest
  • Or use IDE disk mode in VM settings

"BSOD on first boot"

  • Use BIOS mode instead of UEFI
  • Disable virtio, use IDE initially

Logs

Check /var/log/disk2qcow2.log for detailed diagnostics or use "Print Session Log" for PDF reports.


Project Structure

disk2qcow2/
├── code/                          # Application
│   ├── main.py                    # Entry point
│   ├── p2v_dialog.py              # Main GUI
│   ├── vm.py                      # Conversion engine
│   ├── utils.py                   # Disk utilities
│   ├── log_handler.py             # Logging & PDF
│   ├── disk_mount_dialog.py       # Mount manager
│   ├── qcow2_resize_dialog.py     # Resize tool
│   ├── image_format_converter.py  # Format converter
│   ├── ciphering.py               # LUKS encryption
│   ├── export.py                  # RSYNC export
│   └── virt_launcher.py           # VM management
├── iso/                           # ISO builders
│   ├── forgeIsoKde.sh             # KDE ISO 64 bits
│   ├── forgeIsoXfce.sh            # XFCE ISO 64 bits
│   ├── forgeIsoKde32.sh           # KDE ISO 32 bits
│   ├── forgeIsoXfc32e.sh          # XFCE ISO 32 bits
│   └── makefile                   # Build automation
└── README.md

Best Practices

✅ Use ISO method for safe conversions
✅ Use USB 3.0+ external drives for performance
✅ Create a backup before resizing partitions using Backup button ✅ Keep source disk intact until VM validated
✅ Use LUKS encryption for sensitive systems
✅ Generate PDF logs for documentation

Technical Details

  • Format: QCOW2 with zlib compression
  • Source Support: Windows & Linux, any filesystem
  • Log Location: /var/log/disk2qcow2.log
  • GUI: Python 3 + Tkinter
  • Tools: qemu-img, cryptsetup, rsync, libvirt, virt-manager, qemu-utils
  • Target Platforms: QEMU/KVM, VirtualBox, VMware, Hyper-V

Quick Example

# 1. Boot from ISO → Launch P2V Converter
# 2. Click "Refresh Disks" → Select /dev/sda (Windows disk)
# 3. Click "Mount Disk" → Select external /dev/sdb1 → Mount at /mnt/external
# 4. Click "Check Space Requirements" → Verify green indicator
# 5. Click "Start P2V Conversion" → Wait ~45 min for 250GB disk
# 6. Click "Print Session Log" → Save PDF report
# 7. Transfer external drive to host system
# 8. Run: qemu-system-x86_64 -m 4096 -drive file=/mnt/external/sda_vm.qcow2 -enable-kvm

Supported Systems:

  • Windows (XP, Vista, 7, 8, 10, 11, Server 2003-2022)
  • Linux (Ubuntu, Debian, Fedora, CentOS, RHEL, Arch, openSUSE, etc.)

License

Attribution-NonCommercial-ShareAlike 4.0 International. See LICENSE file


Transform any Windows or Linux physical machine into a portable virtual environment.

Download P2V Converter ISO and start virtualizing today!

About

Physical to virtual machine converter

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •