boot - Clone a virtual bootable HDD in a USB flash drive

11
2013-09
  • antonio

    There are many tools for converting a physical HDD in a virtual one. I have the opposite need. I am creating a bootable disk, for recovering and setup purpose, and after I would like to convert it in a physical USB disk to actually use. I would like to work with VMware Player or Virtualbox.

    I think the following strategies are possible.

    • I could start the VM with Clonezilla (or the likes), attach physically the USB drive to the VM and then clone.

    • Using a filesystem driver to read the VMDK disk in the host OS and then like in the previous point.

    • Manually copy the the virtual HDD files and then use a tool like dd, inside the virtual machine, to dump the boot sector of the virtual HDD to be moved after onto the USB disk.

    With dd I think I should use something dd if=/dev/sda of=MBR_boot.img bs=446 count=1.

    There is the problem of possible different boot sectors between virtual and physical disks, say incompatible geometry. In this case I should copy files and then manually recreate the USB boot sector invoking GRUB, BOOTMGR, Syslinux (or whatever the bootloader is), using e.g. grub-install, bootsect.exe.

    Do you know any free tool that can facilitate my task?

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    boot - Booting ubuntu from usb hdd: GRUB menu not shown
  • Questioner

    could anyone help me to boot ubuntu-9.04 from usb hard disk?

    This disk contains /boot primary partition. During ubuntu installation I used "Advanced" button and asked to install GRUB to the /boot partition. Later I checked whether GRUB files are really present in this partition. They are.

    However, I get stuck while trying to boot. The boot menu ("ubuntu generic version", "ubuntu recovery mode", etc...) is not shown. Instead I am thrown to GRUB minimal bash-like version.

    I feel at a loss and have no idea why I am pointed to this minimal version. Can anybody prompt me what to do?


  • Related Answers
  • Gregor

    Assuming you have the valid menu.list, I think the commands you want are:

    root (hdX,Y)
    setup (hdX)
    

    where hdX is probably hd0 or hd1 and Y is the partition number, starting from 0. Note that grub numbers primary partitions (0,1,2,3) and logical partitions (4,5,6,7).

    The 'root' command will check for the right partition type. The 'setup' command will check for the right files in /grub or /boot/grub (on that partition).

    For example, if your internal hd contains non-linux windoz stuff and the first partition on your USB drive is /boot, then try:

    root (hd0,0)
    

    and if that works:

    setup (hd0)
    

    OR

    root (hd1,0)
    

    and if that works:

    setup (hd1)
    

    Then reboot and select the USB drive at the bios boot menu.

  • sakkaku

    This happens when the grub binary is executed and it can't find the directory containing its configuration. Usually you end up with the disk number being off (ie. hd1 vs hd0, etc when installing grub. Note that this is separate from the grub.config ).