Convert VDI to Physical Harddisk

Part 1: Copy VM to Physical Harddisk:
Option 1:

  • Shutdown your (i.e) source.vdi completely
  • Use USB-HDD adaptor, plug in the target harddisk
  • Get GParted LiveCD ISO
  • From root user, create new VM using wizard and directly mount the detected USB-HDD adaptor
  • Add GParted LiveCD ISO and source.vdi to the VM, and set it to boot from CD
  • Start the VM, GParted launched
  • Copy the whole partition from source to target & resize the copied partition if necessary.
  • Shutdown the VM

Option 2:

  • Shutdown your (i.e) source.vdi completely
  • From root user, create (i.e) target.vmdk from (i.e) /dev/sdb using this command: VBoxManage internalcommands createrawvmdk -filename target.vmdk -rawdisk /dev/sdb
  • Get GParted LiveCD ISO
  • From root user, create new VM using wizard and directly mount target.vmdk (theoritically it can be mounted after the VM wizard complete but I always got un-explainable error)
  • Add GParted LiveCD ISO and source.vdi to the VM, and set it to boot from CD
    Start the VM, GParted launched
  • Copy the whole partition from source to target & resize the copied partition if necessary.
  • Shutdown the VM

Part 2: Fix GRUB from physical hardware:

  • Plug in the harddisk (i.e) /dev/sda
  • Boot to CD or USB (NEVER FROM RUNNING OS!!!)
  • sudo su
  • mkdir /media/target
  • mount /dev/sda1 /media/target
  • mount –bind /dev /media/target/dev
  • mount –bind /proc /media/target/proc
  • mount –bind /sys /media/target/sys
  • chroot /media/target
  • grub-install /dev/sda
  • exit
  • reboot