Create Virtualbox image of a physical partition












13















I've a drive with Fedora and Windows 7 on different partitions with dual boot.



Now, while running Fedora, I'd like to suck up the Windows partition and create an image I can run in VirtualBox - how can I do this ?










share|improve this question


















  • 2





    With some tricks, you can boot the partition directly.

    – shellholic
    Feb 26 '11 at 18:09











  • @shellholic: How is that done? can you answer it here: superuser.com/q/463591/74616

    – Tamer Shlash
    Aug 19 '12 at 14:23
















13















I've a drive with Fedora and Windows 7 on different partitions with dual boot.



Now, while running Fedora, I'd like to suck up the Windows partition and create an image I can run in VirtualBox - how can I do this ?










share|improve this question


















  • 2





    With some tricks, you can boot the partition directly.

    – shellholic
    Feb 26 '11 at 18:09











  • @shellholic: How is that done? can you answer it here: superuser.com/q/463591/74616

    – Tamer Shlash
    Aug 19 '12 at 14:23














13












13








13


9






I've a drive with Fedora and Windows 7 on different partitions with dual boot.



Now, while running Fedora, I'd like to suck up the Windows partition and create an image I can run in VirtualBox - how can I do this ?










share|improve this question














I've a drive with Fedora and Windows 7 on different partitions with dual boot.



Now, while running Fedora, I'd like to suck up the Windows partition and create an image I can run in VirtualBox - how can I do this ?







windows linux virtualbox






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 26 '11 at 14:49









nosnos

2,20072332




2,20072332








  • 2





    With some tricks, you can boot the partition directly.

    – shellholic
    Feb 26 '11 at 18:09











  • @shellholic: How is that done? can you answer it here: superuser.com/q/463591/74616

    – Tamer Shlash
    Aug 19 '12 at 14:23














  • 2





    With some tricks, you can boot the partition directly.

    – shellholic
    Feb 26 '11 at 18:09











  • @shellholic: How is that done? can you answer it here: superuser.com/q/463591/74616

    – Tamer Shlash
    Aug 19 '12 at 14:23








2




2





With some tricks, you can boot the partition directly.

– shellholic
Feb 26 '11 at 18:09





With some tricks, you can boot the partition directly.

– shellholic
Feb 26 '11 at 18:09













@shellholic: How is that done? can you answer it here: superuser.com/q/463591/74616

– Tamer Shlash
Aug 19 '12 at 14:23





@shellholic: How is that done? can you answer it here: superuser.com/q/463591/74616

– Tamer Shlash
Aug 19 '12 at 14:23










4 Answers
4






active

oldest

votes


















10














There's a documented "internal" function that you might be interested in. You can create a "raw disk" image which basically passes all commands to the partition on your hard drive. That way, you can keep your Windows partition and attempt to boot it from VirtualBox as well.



You can create a raw image as follows:



VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk
-rawdisk /dev/sda -partitions 1,5



where 1,5 means partitions 1 and 5 on /dev/sda



Mind you, the chances of this working flawlessly are pretty slim. Windows is not exactly known for being adaptive to extreme changes in hardware.



You can read more about raw disks here: 10.8.1. Using a Raw Host Hard Disk From a Guest






share|improve this answer


























  • Ive done this before, but the other way around. Using a mint raw disk for a VM in windows. It worked perfectly, except a minor issue with video.

    – Keltari
    Feb 14 '16 at 20:26



















5














As Matt said, you use the VBoxManage command, and that Windows might not like it. However, there's a faster way that doesn't use up as much disk space. You can use stdin as the input for the convertraw command (which, if you read Matt's answer, is the same as the convertdd command:



# dd if=$WinDevice | VBoxManage convertfromraw stdin windows.vdi $Bytes


Where $WinDevice is the device of the windows partition (such as /dev/sda2), and $Bytes is the exact number of bytes (for example, 1488581554176; you can determine this from within Windows by right-clicking on the C: drive in My Computer and hitting "Properties", it's the Capacity: line underneath the Used and Free space lines and above the pie chart).



Note that I have not tried this myself, and that I believe you might need to use /dev/sda instead of /dev/sda2, assuming you won't be writing to the drive that Windows is on. That way, you capture the partition table and bootloader.






share|improve this answer


























  • As of now (currently Feb. 22, 2014), the number of bytes goes after the output filename.

    – echristopherson
    Feb 22 '14 at 21:05











  • Huh, you're right. Fixed. Do you know if that's always been the case and nobody's noticed until now, or if they changed the order some time within the last three years? I'd guess they wouldn't change the order, but I'd have also have expected somebody to notice by now.

    – Daniel H
    Feb 22 '14 at 22:34











  • I'm not sure if it was ever different... That's part of why I didn't just edit the answer.

    – echristopherson
    Feb 23 '14 at 4:06



















1














I was just trying to do nearly the exact same thing, albeit from Ubuntu. I didn't want to create an image of the entire hard drive, and it didn't seem like a good idea to me to use the physical disk with the VM. I finally found the solution:




  1. (Recommended) If you don't have a Windows disc or ISO, download an ISO. I used X17-59465.iso


  2. If desired, shrink the windows partition so the image size will be smaller. I prefer to do this from Linux using GParted (to avoid "umovable" files that are in use), then reboot to Windows, let it do a chkdsk, and reboot back into Linux.



  3. If mounted, unmount the windows partition just to make sure it doesn't change while imaging it



    sudo umount /windows



  4. Install the MBR package. On Ubuntu:



    sudo apt-get -y install mbr 



  5. Create an image of the MBR (change the device as necessary)



    sudo dd if=/dev/sda of=mbr.img bs=512 count=1



  6. Install a fresh MBR on the image, to get rid of GRUB



    sudo install-mbr mbr.img



  7. Create a raw VMDK image that will mirror the existing partition layout (change the device and partition as necessary)



    sudo vboxmanage internalcommands createrawvmdk -filename windows.vmdk -rawdisk /dev/sda -partitions 2 -mbr mbr.img



  8. Create a VDI image that will copy the data from the partitions selected in the previous step



    sudo vboxmanage clonehd windows.vmdk windows.vdi --format VDI



  9. Change the ownership of the new image file



    sudo chown $USER. windows.vdi



  10. Cleanup



    sudo rm mbr.img windows.vmdk windows-pt.vmdk



  11. (Optional) Compact the new disk image



    vboxmanage modifyhd windows.vdi --compact


  12. Create a new Windows 7 VM, using the image you just created for the hard drive


  13. You can try to boot the VM, but it might fail. If it does, boot the VM to the Windows disc/ISO → Repair your computer, and if given the option click Repair and restart



Sources:




  • https://unix.stackexchange.com/a/64496/14436

  • http://philatwarrimoo.blogspot.com.au/2014/01/virtualize-old-windows-xp-disk.html






share|improve this answer


























  • I'm afraid 8. won't do what you expect it to do. clonehd will create vdi that points to raw disk. That is it clones the "pointer" not actual data. It looks like dd is a must for partition.

    – mlt
    Feb 4 '15 at 11:01











  • One might think that, but it made a clone of the actual data. Step 7 created a ~1 KB image (that merely pointed to the raw disk), but the size of the image created in Step 8 was the size of all of the included partitions, in this case 40 GB. I also know it was a copy because when I boot to my Windows partition, it's different from the VM I created based on it, which I've made changes to. -rw------- 1 root root 40G Feb 4 09:28 windows.vdi -rw------- 1 root root 722 Feb 4 09:11 windows.vmdk

    – bmaupin
    Feb 4 '15 at 14:42





















0














I had a hard disk with Windows 10 and I put it in a VirtualBox machine. To achieve it, I followed these steps:




  • Create a VirtualBox machine for a Windows 10.


  • Important: When creating the hard disk, choose VHD type.

  • With the Windows partition manager, it is possible to mount a VHD like a drive. Mount it.

  • Download AOMEI Partition Assistant Standard (http://www.disk-partition.com/)

  • Use AOEMI to make a hard disk copy from the hard disk with Windows 10 to the new mounted VHD.


That's all, launch your new VirtualBox machine.






share|improve this answer

























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f250663%2fcreate-virtualbox-image-of-a-physical-partition%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    4 Answers
    4






    active

    oldest

    votes








    4 Answers
    4






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    10














    There's a documented "internal" function that you might be interested in. You can create a "raw disk" image which basically passes all commands to the partition on your hard drive. That way, you can keep your Windows partition and attempt to boot it from VirtualBox as well.



    You can create a raw image as follows:



    VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk
    -rawdisk /dev/sda -partitions 1,5



    where 1,5 means partitions 1 and 5 on /dev/sda



    Mind you, the chances of this working flawlessly are pretty slim. Windows is not exactly known for being adaptive to extreme changes in hardware.



    You can read more about raw disks here: 10.8.1. Using a Raw Host Hard Disk From a Guest






    share|improve this answer


























    • Ive done this before, but the other way around. Using a mint raw disk for a VM in windows. It worked perfectly, except a minor issue with video.

      – Keltari
      Feb 14 '16 at 20:26
















    10














    There's a documented "internal" function that you might be interested in. You can create a "raw disk" image which basically passes all commands to the partition on your hard drive. That way, you can keep your Windows partition and attempt to boot it from VirtualBox as well.



    You can create a raw image as follows:



    VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk
    -rawdisk /dev/sda -partitions 1,5



    where 1,5 means partitions 1 and 5 on /dev/sda



    Mind you, the chances of this working flawlessly are pretty slim. Windows is not exactly known for being adaptive to extreme changes in hardware.



    You can read more about raw disks here: 10.8.1. Using a Raw Host Hard Disk From a Guest






    share|improve this answer


























    • Ive done this before, but the other way around. Using a mint raw disk for a VM in windows. It worked perfectly, except a minor issue with video.

      – Keltari
      Feb 14 '16 at 20:26














    10












    10








    10







    There's a documented "internal" function that you might be interested in. You can create a "raw disk" image which basically passes all commands to the partition on your hard drive. That way, you can keep your Windows partition and attempt to boot it from VirtualBox as well.



    You can create a raw image as follows:



    VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk
    -rawdisk /dev/sda -partitions 1,5



    where 1,5 means partitions 1 and 5 on /dev/sda



    Mind you, the chances of this working flawlessly are pretty slim. Windows is not exactly known for being adaptive to extreme changes in hardware.



    You can read more about raw disks here: 10.8.1. Using a Raw Host Hard Disk From a Guest






    share|improve this answer















    There's a documented "internal" function that you might be interested in. You can create a "raw disk" image which basically passes all commands to the partition on your hard drive. That way, you can keep your Windows partition and attempt to boot it from VirtualBox as well.



    You can create a raw image as follows:



    VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk
    -rawdisk /dev/sda -partitions 1,5



    where 1,5 means partitions 1 and 5 on /dev/sda



    Mind you, the chances of this working flawlessly are pretty slim. Windows is not exactly known for being adaptive to extreme changes in hardware.



    You can read more about raw disks here: 10.8.1. Using a Raw Host Hard Disk From a Guest







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jan 2 at 16:35









    Doopy

    183




    183










    answered Mar 2 '11 at 22:35









    DelyanDelyan

    29817




    29817













    • Ive done this before, but the other way around. Using a mint raw disk for a VM in windows. It worked perfectly, except a minor issue with video.

      – Keltari
      Feb 14 '16 at 20:26



















    • Ive done this before, but the other way around. Using a mint raw disk for a VM in windows. It worked perfectly, except a minor issue with video.

      – Keltari
      Feb 14 '16 at 20:26

















    Ive done this before, but the other way around. Using a mint raw disk for a VM in windows. It worked perfectly, except a minor issue with video.

    – Keltari
    Feb 14 '16 at 20:26





    Ive done this before, but the other way around. Using a mint raw disk for a VM in windows. It worked perfectly, except a minor issue with video.

    – Keltari
    Feb 14 '16 at 20:26













    5














    As Matt said, you use the VBoxManage command, and that Windows might not like it. However, there's a faster way that doesn't use up as much disk space. You can use stdin as the input for the convertraw command (which, if you read Matt's answer, is the same as the convertdd command:



    # dd if=$WinDevice | VBoxManage convertfromraw stdin windows.vdi $Bytes


    Where $WinDevice is the device of the windows partition (such as /dev/sda2), and $Bytes is the exact number of bytes (for example, 1488581554176; you can determine this from within Windows by right-clicking on the C: drive in My Computer and hitting "Properties", it's the Capacity: line underneath the Used and Free space lines and above the pie chart).



    Note that I have not tried this myself, and that I believe you might need to use /dev/sda instead of /dev/sda2, assuming you won't be writing to the drive that Windows is on. That way, you capture the partition table and bootloader.






    share|improve this answer


























    • As of now (currently Feb. 22, 2014), the number of bytes goes after the output filename.

      – echristopherson
      Feb 22 '14 at 21:05











    • Huh, you're right. Fixed. Do you know if that's always been the case and nobody's noticed until now, or if they changed the order some time within the last three years? I'd guess they wouldn't change the order, but I'd have also have expected somebody to notice by now.

      – Daniel H
      Feb 22 '14 at 22:34











    • I'm not sure if it was ever different... That's part of why I didn't just edit the answer.

      – echristopherson
      Feb 23 '14 at 4:06
















    5














    As Matt said, you use the VBoxManage command, and that Windows might not like it. However, there's a faster way that doesn't use up as much disk space. You can use stdin as the input for the convertraw command (which, if you read Matt's answer, is the same as the convertdd command:



    # dd if=$WinDevice | VBoxManage convertfromraw stdin windows.vdi $Bytes


    Where $WinDevice is the device of the windows partition (such as /dev/sda2), and $Bytes is the exact number of bytes (for example, 1488581554176; you can determine this from within Windows by right-clicking on the C: drive in My Computer and hitting "Properties", it's the Capacity: line underneath the Used and Free space lines and above the pie chart).



    Note that I have not tried this myself, and that I believe you might need to use /dev/sda instead of /dev/sda2, assuming you won't be writing to the drive that Windows is on. That way, you capture the partition table and bootloader.






    share|improve this answer


























    • As of now (currently Feb. 22, 2014), the number of bytes goes after the output filename.

      – echristopherson
      Feb 22 '14 at 21:05











    • Huh, you're right. Fixed. Do you know if that's always been the case and nobody's noticed until now, or if they changed the order some time within the last three years? I'd guess they wouldn't change the order, but I'd have also have expected somebody to notice by now.

      – Daniel H
      Feb 22 '14 at 22:34











    • I'm not sure if it was ever different... That's part of why I didn't just edit the answer.

      – echristopherson
      Feb 23 '14 at 4:06














    5












    5








    5







    As Matt said, you use the VBoxManage command, and that Windows might not like it. However, there's a faster way that doesn't use up as much disk space. You can use stdin as the input for the convertraw command (which, if you read Matt's answer, is the same as the convertdd command:



    # dd if=$WinDevice | VBoxManage convertfromraw stdin windows.vdi $Bytes


    Where $WinDevice is the device of the windows partition (such as /dev/sda2), and $Bytes is the exact number of bytes (for example, 1488581554176; you can determine this from within Windows by right-clicking on the C: drive in My Computer and hitting "Properties", it's the Capacity: line underneath the Used and Free space lines and above the pie chart).



    Note that I have not tried this myself, and that I believe you might need to use /dev/sda instead of /dev/sda2, assuming you won't be writing to the drive that Windows is on. That way, you capture the partition table and bootloader.






    share|improve this answer















    As Matt said, you use the VBoxManage command, and that Windows might not like it. However, there's a faster way that doesn't use up as much disk space. You can use stdin as the input for the convertraw command (which, if you read Matt's answer, is the same as the convertdd command:



    # dd if=$WinDevice | VBoxManage convertfromraw stdin windows.vdi $Bytes


    Where $WinDevice is the device of the windows partition (such as /dev/sda2), and $Bytes is the exact number of bytes (for example, 1488581554176; you can determine this from within Windows by right-clicking on the C: drive in My Computer and hitting "Properties", it's the Capacity: line underneath the Used and Free space lines and above the pie chart).



    Note that I have not tried this myself, and that I believe you might need to use /dev/sda instead of /dev/sda2, assuming you won't be writing to the drive that Windows is on. That way, you capture the partition table and bootloader.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 20 '17 at 10:16









    Community

    1




    1










    answered Feb 26 '11 at 18:30









    Daniel HDaniel H

    1,3561922




    1,3561922













    • As of now (currently Feb. 22, 2014), the number of bytes goes after the output filename.

      – echristopherson
      Feb 22 '14 at 21:05











    • Huh, you're right. Fixed. Do you know if that's always been the case and nobody's noticed until now, or if they changed the order some time within the last three years? I'd guess they wouldn't change the order, but I'd have also have expected somebody to notice by now.

      – Daniel H
      Feb 22 '14 at 22:34











    • I'm not sure if it was ever different... That's part of why I didn't just edit the answer.

      – echristopherson
      Feb 23 '14 at 4:06



















    • As of now (currently Feb. 22, 2014), the number of bytes goes after the output filename.

      – echristopherson
      Feb 22 '14 at 21:05











    • Huh, you're right. Fixed. Do you know if that's always been the case and nobody's noticed until now, or if they changed the order some time within the last three years? I'd guess they wouldn't change the order, but I'd have also have expected somebody to notice by now.

      – Daniel H
      Feb 22 '14 at 22:34











    • I'm not sure if it was ever different... That's part of why I didn't just edit the answer.

      – echristopherson
      Feb 23 '14 at 4:06

















    As of now (currently Feb. 22, 2014), the number of bytes goes after the output filename.

    – echristopherson
    Feb 22 '14 at 21:05





    As of now (currently Feb. 22, 2014), the number of bytes goes after the output filename.

    – echristopherson
    Feb 22 '14 at 21:05













    Huh, you're right. Fixed. Do you know if that's always been the case and nobody's noticed until now, or if they changed the order some time within the last three years? I'd guess they wouldn't change the order, but I'd have also have expected somebody to notice by now.

    – Daniel H
    Feb 22 '14 at 22:34





    Huh, you're right. Fixed. Do you know if that's always been the case and nobody's noticed until now, or if they changed the order some time within the last three years? I'd guess they wouldn't change the order, but I'd have also have expected somebody to notice by now.

    – Daniel H
    Feb 22 '14 at 22:34













    I'm not sure if it was ever different... That's part of why I didn't just edit the answer.

    – echristopherson
    Feb 23 '14 at 4:06





    I'm not sure if it was ever different... That's part of why I didn't just edit the answer.

    – echristopherson
    Feb 23 '14 at 4:06











    1














    I was just trying to do nearly the exact same thing, albeit from Ubuntu. I didn't want to create an image of the entire hard drive, and it didn't seem like a good idea to me to use the physical disk with the VM. I finally found the solution:




    1. (Recommended) If you don't have a Windows disc or ISO, download an ISO. I used X17-59465.iso


    2. If desired, shrink the windows partition so the image size will be smaller. I prefer to do this from Linux using GParted (to avoid "umovable" files that are in use), then reboot to Windows, let it do a chkdsk, and reboot back into Linux.



    3. If mounted, unmount the windows partition just to make sure it doesn't change while imaging it



      sudo umount /windows



    4. Install the MBR package. On Ubuntu:



      sudo apt-get -y install mbr 



    5. Create an image of the MBR (change the device as necessary)



      sudo dd if=/dev/sda of=mbr.img bs=512 count=1



    6. Install a fresh MBR on the image, to get rid of GRUB



      sudo install-mbr mbr.img



    7. Create a raw VMDK image that will mirror the existing partition layout (change the device and partition as necessary)



      sudo vboxmanage internalcommands createrawvmdk -filename windows.vmdk -rawdisk /dev/sda -partitions 2 -mbr mbr.img



    8. Create a VDI image that will copy the data from the partitions selected in the previous step



      sudo vboxmanage clonehd windows.vmdk windows.vdi --format VDI



    9. Change the ownership of the new image file



      sudo chown $USER. windows.vdi



    10. Cleanup



      sudo rm mbr.img windows.vmdk windows-pt.vmdk



    11. (Optional) Compact the new disk image



      vboxmanage modifyhd windows.vdi --compact


    12. Create a new Windows 7 VM, using the image you just created for the hard drive


    13. You can try to boot the VM, but it might fail. If it does, boot the VM to the Windows disc/ISO → Repair your computer, and if given the option click Repair and restart



    Sources:




    • https://unix.stackexchange.com/a/64496/14436

    • http://philatwarrimoo.blogspot.com.au/2014/01/virtualize-old-windows-xp-disk.html






    share|improve this answer


























    • I'm afraid 8. won't do what you expect it to do. clonehd will create vdi that points to raw disk. That is it clones the "pointer" not actual data. It looks like dd is a must for partition.

      – mlt
      Feb 4 '15 at 11:01











    • One might think that, but it made a clone of the actual data. Step 7 created a ~1 KB image (that merely pointed to the raw disk), but the size of the image created in Step 8 was the size of all of the included partitions, in this case 40 GB. I also know it was a copy because when I boot to my Windows partition, it's different from the VM I created based on it, which I've made changes to. -rw------- 1 root root 40G Feb 4 09:28 windows.vdi -rw------- 1 root root 722 Feb 4 09:11 windows.vmdk

      – bmaupin
      Feb 4 '15 at 14:42


















    1














    I was just trying to do nearly the exact same thing, albeit from Ubuntu. I didn't want to create an image of the entire hard drive, and it didn't seem like a good idea to me to use the physical disk with the VM. I finally found the solution:




    1. (Recommended) If you don't have a Windows disc or ISO, download an ISO. I used X17-59465.iso


    2. If desired, shrink the windows partition so the image size will be smaller. I prefer to do this from Linux using GParted (to avoid "umovable" files that are in use), then reboot to Windows, let it do a chkdsk, and reboot back into Linux.



    3. If mounted, unmount the windows partition just to make sure it doesn't change while imaging it



      sudo umount /windows



    4. Install the MBR package. On Ubuntu:



      sudo apt-get -y install mbr 



    5. Create an image of the MBR (change the device as necessary)



      sudo dd if=/dev/sda of=mbr.img bs=512 count=1



    6. Install a fresh MBR on the image, to get rid of GRUB



      sudo install-mbr mbr.img



    7. Create a raw VMDK image that will mirror the existing partition layout (change the device and partition as necessary)



      sudo vboxmanage internalcommands createrawvmdk -filename windows.vmdk -rawdisk /dev/sda -partitions 2 -mbr mbr.img



    8. Create a VDI image that will copy the data from the partitions selected in the previous step



      sudo vboxmanage clonehd windows.vmdk windows.vdi --format VDI



    9. Change the ownership of the new image file



      sudo chown $USER. windows.vdi



    10. Cleanup



      sudo rm mbr.img windows.vmdk windows-pt.vmdk



    11. (Optional) Compact the new disk image



      vboxmanage modifyhd windows.vdi --compact


    12. Create a new Windows 7 VM, using the image you just created for the hard drive


    13. You can try to boot the VM, but it might fail. If it does, boot the VM to the Windows disc/ISO → Repair your computer, and if given the option click Repair and restart



    Sources:




    • https://unix.stackexchange.com/a/64496/14436

    • http://philatwarrimoo.blogspot.com.au/2014/01/virtualize-old-windows-xp-disk.html






    share|improve this answer


























    • I'm afraid 8. won't do what you expect it to do. clonehd will create vdi that points to raw disk. That is it clones the "pointer" not actual data. It looks like dd is a must for partition.

      – mlt
      Feb 4 '15 at 11:01











    • One might think that, but it made a clone of the actual data. Step 7 created a ~1 KB image (that merely pointed to the raw disk), but the size of the image created in Step 8 was the size of all of the included partitions, in this case 40 GB. I also know it was a copy because when I boot to my Windows partition, it's different from the VM I created based on it, which I've made changes to. -rw------- 1 root root 40G Feb 4 09:28 windows.vdi -rw------- 1 root root 722 Feb 4 09:11 windows.vmdk

      – bmaupin
      Feb 4 '15 at 14:42
















    1












    1








    1







    I was just trying to do nearly the exact same thing, albeit from Ubuntu. I didn't want to create an image of the entire hard drive, and it didn't seem like a good idea to me to use the physical disk with the VM. I finally found the solution:




    1. (Recommended) If you don't have a Windows disc or ISO, download an ISO. I used X17-59465.iso


    2. If desired, shrink the windows partition so the image size will be smaller. I prefer to do this from Linux using GParted (to avoid "umovable" files that are in use), then reboot to Windows, let it do a chkdsk, and reboot back into Linux.



    3. If mounted, unmount the windows partition just to make sure it doesn't change while imaging it



      sudo umount /windows



    4. Install the MBR package. On Ubuntu:



      sudo apt-get -y install mbr 



    5. Create an image of the MBR (change the device as necessary)



      sudo dd if=/dev/sda of=mbr.img bs=512 count=1



    6. Install a fresh MBR on the image, to get rid of GRUB



      sudo install-mbr mbr.img



    7. Create a raw VMDK image that will mirror the existing partition layout (change the device and partition as necessary)



      sudo vboxmanage internalcommands createrawvmdk -filename windows.vmdk -rawdisk /dev/sda -partitions 2 -mbr mbr.img



    8. Create a VDI image that will copy the data from the partitions selected in the previous step



      sudo vboxmanage clonehd windows.vmdk windows.vdi --format VDI



    9. Change the ownership of the new image file



      sudo chown $USER. windows.vdi



    10. Cleanup



      sudo rm mbr.img windows.vmdk windows-pt.vmdk



    11. (Optional) Compact the new disk image



      vboxmanage modifyhd windows.vdi --compact


    12. Create a new Windows 7 VM, using the image you just created for the hard drive


    13. You can try to boot the VM, but it might fail. If it does, boot the VM to the Windows disc/ISO → Repair your computer, and if given the option click Repair and restart



    Sources:




    • https://unix.stackexchange.com/a/64496/14436

    • http://philatwarrimoo.blogspot.com.au/2014/01/virtualize-old-windows-xp-disk.html






    share|improve this answer















    I was just trying to do nearly the exact same thing, albeit from Ubuntu. I didn't want to create an image of the entire hard drive, and it didn't seem like a good idea to me to use the physical disk with the VM. I finally found the solution:




    1. (Recommended) If you don't have a Windows disc or ISO, download an ISO. I used X17-59465.iso


    2. If desired, shrink the windows partition so the image size will be smaller. I prefer to do this from Linux using GParted (to avoid "umovable" files that are in use), then reboot to Windows, let it do a chkdsk, and reboot back into Linux.



    3. If mounted, unmount the windows partition just to make sure it doesn't change while imaging it



      sudo umount /windows



    4. Install the MBR package. On Ubuntu:



      sudo apt-get -y install mbr 



    5. Create an image of the MBR (change the device as necessary)



      sudo dd if=/dev/sda of=mbr.img bs=512 count=1



    6. Install a fresh MBR on the image, to get rid of GRUB



      sudo install-mbr mbr.img



    7. Create a raw VMDK image that will mirror the existing partition layout (change the device and partition as necessary)



      sudo vboxmanage internalcommands createrawvmdk -filename windows.vmdk -rawdisk /dev/sda -partitions 2 -mbr mbr.img



    8. Create a VDI image that will copy the data from the partitions selected in the previous step



      sudo vboxmanage clonehd windows.vmdk windows.vdi --format VDI



    9. Change the ownership of the new image file



      sudo chown $USER. windows.vdi



    10. Cleanup



      sudo rm mbr.img windows.vmdk windows-pt.vmdk



    11. (Optional) Compact the new disk image



      vboxmanage modifyhd windows.vdi --compact


    12. Create a new Windows 7 VM, using the image you just created for the hard drive


    13. You can try to boot the VM, but it might fail. If it does, boot the VM to the Windows disc/ISO → Repair your computer, and if given the option click Repair and restart



    Sources:




    • https://unix.stackexchange.com/a/64496/14436

    • http://philatwarrimoo.blogspot.com.au/2014/01/virtualize-old-windows-xp-disk.html







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Apr 13 '17 at 12:37









    Community

    1




    1










    answered Aug 28 '14 at 19:16









    bmaupinbmaupin

    208211




    208211













    • I'm afraid 8. won't do what you expect it to do. clonehd will create vdi that points to raw disk. That is it clones the "pointer" not actual data. It looks like dd is a must for partition.

      – mlt
      Feb 4 '15 at 11:01











    • One might think that, but it made a clone of the actual data. Step 7 created a ~1 KB image (that merely pointed to the raw disk), but the size of the image created in Step 8 was the size of all of the included partitions, in this case 40 GB. I also know it was a copy because when I boot to my Windows partition, it's different from the VM I created based on it, which I've made changes to. -rw------- 1 root root 40G Feb 4 09:28 windows.vdi -rw------- 1 root root 722 Feb 4 09:11 windows.vmdk

      – bmaupin
      Feb 4 '15 at 14:42





















    • I'm afraid 8. won't do what you expect it to do. clonehd will create vdi that points to raw disk. That is it clones the "pointer" not actual data. It looks like dd is a must for partition.

      – mlt
      Feb 4 '15 at 11:01











    • One might think that, but it made a clone of the actual data. Step 7 created a ~1 KB image (that merely pointed to the raw disk), but the size of the image created in Step 8 was the size of all of the included partitions, in this case 40 GB. I also know it was a copy because when I boot to my Windows partition, it's different from the VM I created based on it, which I've made changes to. -rw------- 1 root root 40G Feb 4 09:28 windows.vdi -rw------- 1 root root 722 Feb 4 09:11 windows.vmdk

      – bmaupin
      Feb 4 '15 at 14:42



















    I'm afraid 8. won't do what you expect it to do. clonehd will create vdi that points to raw disk. That is it clones the "pointer" not actual data. It looks like dd is a must for partition.

    – mlt
    Feb 4 '15 at 11:01





    I'm afraid 8. won't do what you expect it to do. clonehd will create vdi that points to raw disk. That is it clones the "pointer" not actual data. It looks like dd is a must for partition.

    – mlt
    Feb 4 '15 at 11:01













    One might think that, but it made a clone of the actual data. Step 7 created a ~1 KB image (that merely pointed to the raw disk), but the size of the image created in Step 8 was the size of all of the included partitions, in this case 40 GB. I also know it was a copy because when I boot to my Windows partition, it's different from the VM I created based on it, which I've made changes to. -rw------- 1 root root 40G Feb 4 09:28 windows.vdi -rw------- 1 root root 722 Feb 4 09:11 windows.vmdk

    – bmaupin
    Feb 4 '15 at 14:42







    One might think that, but it made a clone of the actual data. Step 7 created a ~1 KB image (that merely pointed to the raw disk), but the size of the image created in Step 8 was the size of all of the included partitions, in this case 40 GB. I also know it was a copy because when I boot to my Windows partition, it's different from the VM I created based on it, which I've made changes to. -rw------- 1 root root 40G Feb 4 09:28 windows.vdi -rw------- 1 root root 722 Feb 4 09:11 windows.vmdk

    – bmaupin
    Feb 4 '15 at 14:42













    0














    I had a hard disk with Windows 10 and I put it in a VirtualBox machine. To achieve it, I followed these steps:




    • Create a VirtualBox machine for a Windows 10.


    • Important: When creating the hard disk, choose VHD type.

    • With the Windows partition manager, it is possible to mount a VHD like a drive. Mount it.

    • Download AOMEI Partition Assistant Standard (http://www.disk-partition.com/)

    • Use AOEMI to make a hard disk copy from the hard disk with Windows 10 to the new mounted VHD.


    That's all, launch your new VirtualBox machine.






    share|improve this answer






























      0














      I had a hard disk with Windows 10 and I put it in a VirtualBox machine. To achieve it, I followed these steps:




      • Create a VirtualBox machine for a Windows 10.


      • Important: When creating the hard disk, choose VHD type.

      • With the Windows partition manager, it is possible to mount a VHD like a drive. Mount it.

      • Download AOMEI Partition Assistant Standard (http://www.disk-partition.com/)

      • Use AOEMI to make a hard disk copy from the hard disk with Windows 10 to the new mounted VHD.


      That's all, launch your new VirtualBox machine.






      share|improve this answer




























        0












        0








        0







        I had a hard disk with Windows 10 and I put it in a VirtualBox machine. To achieve it, I followed these steps:




        • Create a VirtualBox machine for a Windows 10.


        • Important: When creating the hard disk, choose VHD type.

        • With the Windows partition manager, it is possible to mount a VHD like a drive. Mount it.

        • Download AOMEI Partition Assistant Standard (http://www.disk-partition.com/)

        • Use AOEMI to make a hard disk copy from the hard disk with Windows 10 to the new mounted VHD.


        That's all, launch your new VirtualBox machine.






        share|improve this answer















        I had a hard disk with Windows 10 and I put it in a VirtualBox machine. To achieve it, I followed these steps:




        • Create a VirtualBox machine for a Windows 10.


        • Important: When creating the hard disk, choose VHD type.

        • With the Windows partition manager, it is possible to mount a VHD like a drive. Mount it.

        • Download AOMEI Partition Assistant Standard (http://www.disk-partition.com/)

        • Use AOEMI to make a hard disk copy from the hard disk with Windows 10 to the new mounted VHD.


        That's all, launch your new VirtualBox machine.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Oct 4 '16 at 16:44









        Moses

        9,1062158106




        9,1062158106










        answered Sep 18 '16 at 19:46









        nemonem appnemonem app

        1




        1






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f250663%2fcreate-virtualbox-image-of-a-physical-partition%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Список кардиналов, возведённых папой римским Каликстом III

            Deduzione

            Mysql.sock missing - “Can't connect to local MySQL server through socket”