Unable to export physical Linux system to VirtualBox VM

0

1

I would like to save my Linux system (including packages, files, and configuration) and export it to another laptop in the form of a virtual machine with VirtualBox.

I have been able to create a file of the correct format (.vdi) with these commands:

sudo dd if=/dev/sdb of=/media/HDD/disk.img
VBoxManage convertdd disk.img disk.vdi --format VDI

I was also able to achieve this through this line:

sudo dd if=DRIVE | VBoxManage convertfromraw stdin FILENAME.vdi BYTES

However, when I open the generated VDI file as an existing hard disk in VirtualBox, the same error is displayed each time I try to boot: no bootable medium found.

I also tried another solution with the CloneZilla tool running on a live USB key; I was able to generate an image of my system and to store it on an external hard drive.

That image is not recognized when I proceed to the restoration on my virtual machine. The USB device containing the image does not appear inside the list of the partitions.

Here my /dev/sdb output:

WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.

Disk /dev/sdb: 24.0 GB, 24015495168 bytes
255 heads, 63 sectors/track, 2919 cylinders, total 46905264 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x7ef857ad

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1    46905263    23452631+  ee  GPT

And UUID here /boot/grub/grub.cfg matches with /etc/fstab in /dev/sdb1.

Dalkio

Posted 2015-10-27T11:17:49.977

Reputation: 9

what distro does the linux system run? – Journeyman Geek – 2015-10-27T12:11:35.400

Just Ubuntu 14.04 LTS – Dalkio – 2015-10-27T12:18:22.667

Are you sure the original system boots from /dev/sdb? Can you describe the full boot chain that leaves the Linux system running? – golimar – 2015-10-27T14:21:17.170

Yeah, I'm sure : /dev/sdb represents my 24 GB SDD disk with contains my entire linux system, /dev/sda is actually used as dual booting for windows system. – Dalkio – 2015-10-27T14:36:44.977

So the system boot starts in sda? If so, how does it boot the Linux system in sdb? – golimar – 2015-10-27T16:52:58.543

Can you post the output of fdisk -l /dev/sdb? – MariusMatutiae – 2015-10-28T07:20:10.513

I added my /dev/sdb output – Dalkio – 2015-10-28T09:46:54.453

Pls see my updated answer. – MariusMatutiae – 2015-10-29T12:44:36.230

Answers

0

The easiest thing to install (or re-install, or repair) GRUB2 on your image is to use another VM running Linux. The alternative, the answer by toh, is rather complicated. If you boot a Linux VM, having plugged into it also your new disk image (besides the VM's own disk), it will be treated not as a file but as a real disk, bypassing the need for the device mapper (see link above).

So, boot another Linux VM, mount your new vdi disk,

       mount /dev/sdb1 /mnt

and chroot into it:

   mount -o bind /proc /mnt/proc
   mount -o bind /sys  /mnt/sys
   mount -o bind /dev  /mnt/dev
   cd /mnt; chroot . 

Now you can install grub as follows

   grub-install /dev/sdb
   update-grub /dev/sdb

then leave the chroot environment (by means of `exit' or Ctrl+D, and

  umount /mnt/dev
  umount /mnt/proc
  umount /mnt/sys
  umount /mnt

Your new vdi disk is now bootable, and can be used as the disk of a new Linux VM.

MariusMatutiae

Posted 2015-10-27T11:17:49.977

Reputation: 41 321