0

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.

8
  • what distro does the linux system run?
    – Journeyman Geek
    Oct 27, 2015 at 12:11
  • Just Ubuntu 14.04 LTS
    – Dalkio
    Oct 27, 2015 at 12:18
  • Are you sure the original system boots from /dev/sdb? Can you describe the full boot chain that leaves the Linux system running?
    – golimar
    Oct 27, 2015 at 14:21
  • 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
    Oct 27, 2015 at 14:36
  • So the system boot starts in sda? If so, how does it boot the Linux system in sdb?
    – golimar
    Oct 27, 2015 at 16:52

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .