1.
Identify your disk
Run:
bash
lsblk
Look for the disk with your root (/) partition — often it’s something like /dev/sda
or /dev/nvme0n1.
> Make sure not to select a partition, like /dev/sda1. You want the entire
disk!
2. Create a raw disk image using dd
This clones the entire disk bit-for-bit:
bash
sudo dd if=/dev/sdX of=~/linux-raw.img bs=4M status=progress
Replace /dev/sdX with your real device name
You can save the .img to an external disk if needed
This process may take time depending on disk size
3. Convert the raw image to a VirtualBox-compatible format
If you want to use the image in VirtualBox, convert it to .vdi:
bash
qemu-img convert -f raw -O vdi ~/linux-raw.img linux-disk.vdi
> Want to use VMware or Hyper-V instead? Just change the -O format to vmdk
or vhdx.
4. Create a VM and attach the converted disk
In VirtualBox:
Create a new VM with similar specs (UEFI vs BIOS, CPU cores, RAM, etc.)
When asked about the hard drive, choose “Use an existing virtual
hard disk” and point it to linux-disk.vdi
🛠 After Booting the VM
It may need to repair GRUB or bootloader. You can use a live ISO inside
the VM to fix that.
Some hardware-specific services (like GPU drivers or network interfaces)
may need reconfiguration.
💡 Tips
To shrink the image size before converting, clear out unnecessary files
and run:
bash
sudo zerofree /dev/sdXn
or
bash
sudo dd if=/dev/zero of=zero.fill bs=1M; sudo rm zero.fill
before running dd.
Always test the VM in a sandboxed environment first — it’s a full replica
of your system.