How to use a real partition with Windows 7 installed, in a virtualbox vm?
My Ubuntu 12.04 is installed on /dev/sda5
and Windows 7 on /dev/sda1
. When I am running Ubuntu, I would like to use Virtualbox to run Windows 7 in a VM. The Windows 7 partition is 1 TB and is half full, i.e. large, so I don't want to copy it into a virtual hard disk.
I have read that it is possible to use a real hard disk for a Virtualbox VM, but the various instructions I have found differ from each other, and I can't seem to get it to work. Does anyone know a way to make it work in Ubuntu 12.04 and Virtualbox 2.1.12_Ubuntu r77245 (the latest Ubuntu installed the repos)?
Please post how it works for you as I want to retry any method that might work.
12.04 virtualbox windows-7
add a comment |
My Ubuntu 12.04 is installed on /dev/sda5
and Windows 7 on /dev/sda1
. When I am running Ubuntu, I would like to use Virtualbox to run Windows 7 in a VM. The Windows 7 partition is 1 TB and is half full, i.e. large, so I don't want to copy it into a virtual hard disk.
I have read that it is possible to use a real hard disk for a Virtualbox VM, but the various instructions I have found differ from each other, and I can't seem to get it to work. Does anyone know a way to make it work in Ubuntu 12.04 and Virtualbox 2.1.12_Ubuntu r77245 (the latest Ubuntu installed the repos)?
Please post how it works for you as I want to retry any method that might work.
12.04 virtualbox windows-7
Why is your MSWIN partition 1TiB? Although, not a complete solution: If possible, move everything that doesn't need to be on there (data...media files?) and then re-size the partition which will make any approach easier. If you wanted to go the image route, clearing then shrinking that partition will leave you with enough space to make a full image of the smaller, new partition. :-)
– Alastair
Jan 6 '14 at 14:58
Related: Use physical harddisk in Virtual Box
– kenorb
Dec 10 '18 at 22:59
add a comment |
My Ubuntu 12.04 is installed on /dev/sda5
and Windows 7 on /dev/sda1
. When I am running Ubuntu, I would like to use Virtualbox to run Windows 7 in a VM. The Windows 7 partition is 1 TB and is half full, i.e. large, so I don't want to copy it into a virtual hard disk.
I have read that it is possible to use a real hard disk for a Virtualbox VM, but the various instructions I have found differ from each other, and I can't seem to get it to work. Does anyone know a way to make it work in Ubuntu 12.04 and Virtualbox 2.1.12_Ubuntu r77245 (the latest Ubuntu installed the repos)?
Please post how it works for you as I want to retry any method that might work.
12.04 virtualbox windows-7
My Ubuntu 12.04 is installed on /dev/sda5
and Windows 7 on /dev/sda1
. When I am running Ubuntu, I would like to use Virtualbox to run Windows 7 in a VM. The Windows 7 partition is 1 TB and is half full, i.e. large, so I don't want to copy it into a virtual hard disk.
I have read that it is possible to use a real hard disk for a Virtualbox VM, but the various instructions I have found differ from each other, and I can't seem to get it to work. Does anyone know a way to make it work in Ubuntu 12.04 and Virtualbox 2.1.12_Ubuntu r77245 (the latest Ubuntu installed the repos)?
Please post how it works for you as I want to retry any method that might work.
12.04 virtualbox windows-7
12.04 virtualbox windows-7
edited Dec 29 '15 at 10:45
muru
1
1
asked Jul 25 '12 at 22:25
JazzJazz
1,78631934
1,78631934
Why is your MSWIN partition 1TiB? Although, not a complete solution: If possible, move everything that doesn't need to be on there (data...media files?) and then re-size the partition which will make any approach easier. If you wanted to go the image route, clearing then shrinking that partition will leave you with enough space to make a full image of the smaller, new partition. :-)
– Alastair
Jan 6 '14 at 14:58
Related: Use physical harddisk in Virtual Box
– kenorb
Dec 10 '18 at 22:59
add a comment |
Why is your MSWIN partition 1TiB? Although, not a complete solution: If possible, move everything that doesn't need to be on there (data...media files?) and then re-size the partition which will make any approach easier. If you wanted to go the image route, clearing then shrinking that partition will leave you with enough space to make a full image of the smaller, new partition. :-)
– Alastair
Jan 6 '14 at 14:58
Related: Use physical harddisk in Virtual Box
– kenorb
Dec 10 '18 at 22:59
Why is your MSWIN partition 1TiB? Although, not a complete solution: If possible, move everything that doesn't need to be on there (data...media files?) and then re-size the partition which will make any approach easier. If you wanted to go the image route, clearing then shrinking that partition will leave you with enough space to make a full image of the smaller, new partition. :-)
– Alastair
Jan 6 '14 at 14:58
Why is your MSWIN partition 1TiB? Although, not a complete solution: If possible, move everything that doesn't need to be on there (data...media files?) and then re-size the partition which will make any approach easier. If you wanted to go the image route, clearing then shrinking that partition will leave you with enough space to make a full image of the smaller, new partition. :-)
– Alastair
Jan 6 '14 at 14:58
Related: Use physical harddisk in Virtual Box
– kenorb
Dec 10 '18 at 22:59
Related: Use physical harddisk in Virtual Box
– kenorb
Dec 10 '18 at 22:59
add a comment |
5 Answers
5
active
oldest
votes
The command you want is
VBoxManage internalcommands createrawvmdk -filename Win7.vmdk -rawdisk /dev/sda -partitions 1
This will create a special VMDK virtual disk file (Win7.vmdk) which is actually a pointer to the host disk partition /dev/sda1
.
In theory, you can then use this as the disk file for a VM to run directly from the actual disk partition, but...
- (a) I've never tried this, so don't know how reliable it is
- (b) you may get problems with Windows Activation depending on your license key and whether Windows decides that the detected 'hardware' has significantly changed
Thank you. I didn't even think about the activation problem. That's sure to put a stop to my plans.
– Jazz
Jul 26 '12 at 3:52
1
In addition, even if it worked (which I doubt) you may seriously damage your Windows when running from both boot, and the VM.
– Takkat
Jul 26 '12 at 8:54
@ubnewbie2: I'd probably only try this as an experiment and/or when using some sort of Volume Licensing key and I'd probably view it as a one-way operation; i.e. you'd have more difficulties trying to reverse it. I actually run Windows 7 and use a VirtualBox VM with Ubuntu, often in full screen mode so the PC seems only to be running Linux, and would be more confident of running Ubuntu off a raw disk partition.
– StarNamer
Jul 26 '12 at 11:19
FYI, I have now tried this, in reverse. I needed to change a machine running Ubuntu over to Win 7, so made freed some space by resizing partitions and creating a new one and installed Win 7. This replaced grub2 with he windows bootloader so I then installed VirtualBox and created a new VM, with a minimal virtual disk to book from, which then uses the existing 'raw' partitions to run from. It works OK, although a bit sluggish due to reduced memory and only seeing 1 CPU core (instead of 4).
– StarNamer
Aug 7 '12 at 12:55
-partitions at the end a list of the partitions you want virtual box to "see" (not the partition # you want to use)VBoxManage internalcommands --help
will show you other things you can do with the internal commands, as well as what the options mean.
– boatcoder
Dec 18 '13 at 13:10
|
show 1 more comment
Yes you can do that with the internal createrawvmdk
command, which will not create an entire disk image, but a pointer to the actual hardware.
There are two ways to do that
A. Full disk image (of /dev/sdb)
sudo VBoxManage internalcommands createrawvmdk -filename sdb.vmdk -rawdisk /dev/sdb
B. Partition image
As @StarNamer showed, you ca use only one or few partitions.
To create image of just one (/dev/sda1) partition:
sudo VBoxManage internalcommands createrawvmdk -filename sda1.vmdk -rawdisk /dev/sda -partitions 1
To create custom partition table which will map /dev/sda2 and /dev/sda1 in that order:
sudo VBoxManage internalcommands createrawvmdk -filename sda2_1.vmdk -rawdisk /dev/sda -partitions 2,1
Most striking difference will be that full disk image will use bootloader and partition table exactly as they are in your disk, so in theory (I did that previously only in qemu) you will be able to setup OS from your virtual machine. And from my limited experience I can say that full disk image will work exactly as qemu -hda /dev/sdb
.
Note: If you're using user to access the disk, you need to add it to disk
and vboxusers
groups, e.g.
sudo usermod -aG disk,vboxusers ubuntu
then make sure you re-login or restart your computer.
Further reading:
- VirtualBox documentation: Using a raw host hard disk from a guest
VirtualBox boots only in UEFI Interactive shell (just including the ESP for UEFI installs will not work)- Install the Windows MBR bootloader (temporarily) from within Ubuntu (1,
2). - Better, you can install MBR into a file and use the
-mbr
option (see 1) when creating the VMDK. - If you've got
VERR_ACCESS_DENIED
error, check: Virtualbox doesn't work with a real partition.
"full disk image will use bootloader and partition table exactly as they are in your disk" - under which scenario, the first (/dev/sdb) or the second (with partitions specified)?
– naught101
Jul 22 '13 at 23:39
1
Also, virtualbox needs to be run as root, otherwise you getPermission problem accessing the file for the medium '/home/naught101/sda2_windows.vmdk'
– naught101
Jul 22 '13 at 23:49
3
"Also, virtual-box needs to be run as root". Actually no, you need to be a member of group disk. Much safer than running virtual-box as root.
– user193006
Sep 15 '13 at 1:14
2
Here is what worked for me with Ubuntu 16.04 as a host system and Windows 10 as a guest: I created the .vmdk file usingsudo VBoxManage internalcommands createrawvmdk -filename sda1_2_3.vmdk -rawdisk /dev/sda -partitions 1, 2, 3
. That way I included the windows partition as well as the EFI boot loader partition. I then followed the shilka's instructions on virtualbox.org/ticket/7702 and added cloverefiboot. Works like a charm!
– dzmanto
Mar 10 '17 at 10:03
You can also prefix VirutalBox (and VBoxManage) command withsudo -g disk
to only grant that the access to virtualbox, but not all your other processes.
– Jan Hudec
Jan 2 at 21:16
add a comment |
There is an Disk option called "Immutable", so in theory if you select this option for the vmdk linking to your raw disk, it should not change the original partition.
To do so open "Virtual Media Manager" found under "File", select your image and click "Modify" (You have to make sure this image is not attached to any machine, otherwise you get an error). Now you can set the media type to "Immutable".
I have not tested this, though. If anyone does (of course with a test setup) it would be good to report back here.
Has anyone considerations which speak against this idea?
add a comment |
For several years now, I have been running dual-booted Windows and Ubuntu with the Ubuntu Partition also booting into Windows VirtualBox to take advantage of the touch-screen capabilities that Linux hasn't yet mastered.
I set it up with instructions similar to below;
- How to Dual Boot and Virtualize the Same Partition on Your Computer
The new machines can simultaneously handle both OSs better than single systems on old machines.
Downside: You need to save the instructions you use for setup in case an update disables the VirtualBox connection (my current problem).
add a comment |
After many tries I ended up with a neat and clean solution:
- Boot the windows partition you would like to virtualize
- Download Disk2VHD utility from Sysinternals
If you have a UEFI partition, follow these instructions
- Create a VHD (not VHDX) image of your C: partition, recovery, UEFI (if any) and whatever else you want
- Come back to Linux, open VirtualBox and create a VM accordingly to your windows operating system specifications
- Attach to that VM the VHD disk created at point 4
- That's it
- Profit
Troubleshooting in case of UEFI:
- In the VM settings, in VirtualBox, check the option "Enable EFI" under System tab
If you get stuck at the EFI Shell, run the following command:
fs0:EFIBootbkpbootx64.efi
Some comment about the downvote?
– garlix
Nov 8 '18 at 13:06
I see this happened a few days back, but I don't remember giving you downvotes, at least not on purpose. i'd gladly unvote it, sorry.
– userfuser
Nov 11 '18 at 21:14
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f168156%2fhow-to-use-a-real-partition-with-windows-7-installed-in-a-virtualbox-vm%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
The command you want is
VBoxManage internalcommands createrawvmdk -filename Win7.vmdk -rawdisk /dev/sda -partitions 1
This will create a special VMDK virtual disk file (Win7.vmdk) which is actually a pointer to the host disk partition /dev/sda1
.
In theory, you can then use this as the disk file for a VM to run directly from the actual disk partition, but...
- (a) I've never tried this, so don't know how reliable it is
- (b) you may get problems with Windows Activation depending on your license key and whether Windows decides that the detected 'hardware' has significantly changed
Thank you. I didn't even think about the activation problem. That's sure to put a stop to my plans.
– Jazz
Jul 26 '12 at 3:52
1
In addition, even if it worked (which I doubt) you may seriously damage your Windows when running from both boot, and the VM.
– Takkat
Jul 26 '12 at 8:54
@ubnewbie2: I'd probably only try this as an experiment and/or when using some sort of Volume Licensing key and I'd probably view it as a one-way operation; i.e. you'd have more difficulties trying to reverse it. I actually run Windows 7 and use a VirtualBox VM with Ubuntu, often in full screen mode so the PC seems only to be running Linux, and would be more confident of running Ubuntu off a raw disk partition.
– StarNamer
Jul 26 '12 at 11:19
FYI, I have now tried this, in reverse. I needed to change a machine running Ubuntu over to Win 7, so made freed some space by resizing partitions and creating a new one and installed Win 7. This replaced grub2 with he windows bootloader so I then installed VirtualBox and created a new VM, with a minimal virtual disk to book from, which then uses the existing 'raw' partitions to run from. It works OK, although a bit sluggish due to reduced memory and only seeing 1 CPU core (instead of 4).
– StarNamer
Aug 7 '12 at 12:55
-partitions at the end a list of the partitions you want virtual box to "see" (not the partition # you want to use)VBoxManage internalcommands --help
will show you other things you can do with the internal commands, as well as what the options mean.
– boatcoder
Dec 18 '13 at 13:10
|
show 1 more comment
The command you want is
VBoxManage internalcommands createrawvmdk -filename Win7.vmdk -rawdisk /dev/sda -partitions 1
This will create a special VMDK virtual disk file (Win7.vmdk) which is actually a pointer to the host disk partition /dev/sda1
.
In theory, you can then use this as the disk file for a VM to run directly from the actual disk partition, but...
- (a) I've never tried this, so don't know how reliable it is
- (b) you may get problems with Windows Activation depending on your license key and whether Windows decides that the detected 'hardware' has significantly changed
Thank you. I didn't even think about the activation problem. That's sure to put a stop to my plans.
– Jazz
Jul 26 '12 at 3:52
1
In addition, even if it worked (which I doubt) you may seriously damage your Windows when running from both boot, and the VM.
– Takkat
Jul 26 '12 at 8:54
@ubnewbie2: I'd probably only try this as an experiment and/or when using some sort of Volume Licensing key and I'd probably view it as a one-way operation; i.e. you'd have more difficulties trying to reverse it. I actually run Windows 7 and use a VirtualBox VM with Ubuntu, often in full screen mode so the PC seems only to be running Linux, and would be more confident of running Ubuntu off a raw disk partition.
– StarNamer
Jul 26 '12 at 11:19
FYI, I have now tried this, in reverse. I needed to change a machine running Ubuntu over to Win 7, so made freed some space by resizing partitions and creating a new one and installed Win 7. This replaced grub2 with he windows bootloader so I then installed VirtualBox and created a new VM, with a minimal virtual disk to book from, which then uses the existing 'raw' partitions to run from. It works OK, although a bit sluggish due to reduced memory and only seeing 1 CPU core (instead of 4).
– StarNamer
Aug 7 '12 at 12:55
-partitions at the end a list of the partitions you want virtual box to "see" (not the partition # you want to use)VBoxManage internalcommands --help
will show you other things you can do with the internal commands, as well as what the options mean.
– boatcoder
Dec 18 '13 at 13:10
|
show 1 more comment
The command you want is
VBoxManage internalcommands createrawvmdk -filename Win7.vmdk -rawdisk /dev/sda -partitions 1
This will create a special VMDK virtual disk file (Win7.vmdk) which is actually a pointer to the host disk partition /dev/sda1
.
In theory, you can then use this as the disk file for a VM to run directly from the actual disk partition, but...
- (a) I've never tried this, so don't know how reliable it is
- (b) you may get problems with Windows Activation depending on your license key and whether Windows decides that the detected 'hardware' has significantly changed
The command you want is
VBoxManage internalcommands createrawvmdk -filename Win7.vmdk -rawdisk /dev/sda -partitions 1
This will create a special VMDK virtual disk file (Win7.vmdk) which is actually a pointer to the host disk partition /dev/sda1
.
In theory, you can then use this as the disk file for a VM to run directly from the actual disk partition, but...
- (a) I've never tried this, so don't know how reliable it is
- (b) you may get problems with Windows Activation depending on your license key and whether Windows decides that the detected 'hardware' has significantly changed
answered Jul 25 '12 at 23:25
StarNamerStarNamer
2,4461424
2,4461424
Thank you. I didn't even think about the activation problem. That's sure to put a stop to my plans.
– Jazz
Jul 26 '12 at 3:52
1
In addition, even if it worked (which I doubt) you may seriously damage your Windows when running from both boot, and the VM.
– Takkat
Jul 26 '12 at 8:54
@ubnewbie2: I'd probably only try this as an experiment and/or when using some sort of Volume Licensing key and I'd probably view it as a one-way operation; i.e. you'd have more difficulties trying to reverse it. I actually run Windows 7 and use a VirtualBox VM with Ubuntu, often in full screen mode so the PC seems only to be running Linux, and would be more confident of running Ubuntu off a raw disk partition.
– StarNamer
Jul 26 '12 at 11:19
FYI, I have now tried this, in reverse. I needed to change a machine running Ubuntu over to Win 7, so made freed some space by resizing partitions and creating a new one and installed Win 7. This replaced grub2 with he windows bootloader so I then installed VirtualBox and created a new VM, with a minimal virtual disk to book from, which then uses the existing 'raw' partitions to run from. It works OK, although a bit sluggish due to reduced memory and only seeing 1 CPU core (instead of 4).
– StarNamer
Aug 7 '12 at 12:55
-partitions at the end a list of the partitions you want virtual box to "see" (not the partition # you want to use)VBoxManage internalcommands --help
will show you other things you can do with the internal commands, as well as what the options mean.
– boatcoder
Dec 18 '13 at 13:10
|
show 1 more comment
Thank you. I didn't even think about the activation problem. That's sure to put a stop to my plans.
– Jazz
Jul 26 '12 at 3:52
1
In addition, even if it worked (which I doubt) you may seriously damage your Windows when running from both boot, and the VM.
– Takkat
Jul 26 '12 at 8:54
@ubnewbie2: I'd probably only try this as an experiment and/or when using some sort of Volume Licensing key and I'd probably view it as a one-way operation; i.e. you'd have more difficulties trying to reverse it. I actually run Windows 7 and use a VirtualBox VM with Ubuntu, often in full screen mode so the PC seems only to be running Linux, and would be more confident of running Ubuntu off a raw disk partition.
– StarNamer
Jul 26 '12 at 11:19
FYI, I have now tried this, in reverse. I needed to change a machine running Ubuntu over to Win 7, so made freed some space by resizing partitions and creating a new one and installed Win 7. This replaced grub2 with he windows bootloader so I then installed VirtualBox and created a new VM, with a minimal virtual disk to book from, which then uses the existing 'raw' partitions to run from. It works OK, although a bit sluggish due to reduced memory and only seeing 1 CPU core (instead of 4).
– StarNamer
Aug 7 '12 at 12:55
-partitions at the end a list of the partitions you want virtual box to "see" (not the partition # you want to use)VBoxManage internalcommands --help
will show you other things you can do with the internal commands, as well as what the options mean.
– boatcoder
Dec 18 '13 at 13:10
Thank you. I didn't even think about the activation problem. That's sure to put a stop to my plans.
– Jazz
Jul 26 '12 at 3:52
Thank you. I didn't even think about the activation problem. That's sure to put a stop to my plans.
– Jazz
Jul 26 '12 at 3:52
1
1
In addition, even if it worked (which I doubt) you may seriously damage your Windows when running from both boot, and the VM.
– Takkat
Jul 26 '12 at 8:54
In addition, even if it worked (which I doubt) you may seriously damage your Windows when running from both boot, and the VM.
– Takkat
Jul 26 '12 at 8:54
@ubnewbie2: I'd probably only try this as an experiment and/or when using some sort of Volume Licensing key and I'd probably view it as a one-way operation; i.e. you'd have more difficulties trying to reverse it. I actually run Windows 7 and use a VirtualBox VM with Ubuntu, often in full screen mode so the PC seems only to be running Linux, and would be more confident of running Ubuntu off a raw disk partition.
– StarNamer
Jul 26 '12 at 11:19
@ubnewbie2: I'd probably only try this as an experiment and/or when using some sort of Volume Licensing key and I'd probably view it as a one-way operation; i.e. you'd have more difficulties trying to reverse it. I actually run Windows 7 and use a VirtualBox VM with Ubuntu, often in full screen mode so the PC seems only to be running Linux, and would be more confident of running Ubuntu off a raw disk partition.
– StarNamer
Jul 26 '12 at 11:19
FYI, I have now tried this, in reverse. I needed to change a machine running Ubuntu over to Win 7, so made freed some space by resizing partitions and creating a new one and installed Win 7. This replaced grub2 with he windows bootloader so I then installed VirtualBox and created a new VM, with a minimal virtual disk to book from, which then uses the existing 'raw' partitions to run from. It works OK, although a bit sluggish due to reduced memory and only seeing 1 CPU core (instead of 4).
– StarNamer
Aug 7 '12 at 12:55
FYI, I have now tried this, in reverse. I needed to change a machine running Ubuntu over to Win 7, so made freed some space by resizing partitions and creating a new one and installed Win 7. This replaced grub2 with he windows bootloader so I then installed VirtualBox and created a new VM, with a minimal virtual disk to book from, which then uses the existing 'raw' partitions to run from. It works OK, although a bit sluggish due to reduced memory and only seeing 1 CPU core (instead of 4).
– StarNamer
Aug 7 '12 at 12:55
-partitions at the end a list of the partitions you want virtual box to "see" (not the partition # you want to use)
VBoxManage internalcommands --help
will show you other things you can do with the internal commands, as well as what the options mean.– boatcoder
Dec 18 '13 at 13:10
-partitions at the end a list of the partitions you want virtual box to "see" (not the partition # you want to use)
VBoxManage internalcommands --help
will show you other things you can do with the internal commands, as well as what the options mean.– boatcoder
Dec 18 '13 at 13:10
|
show 1 more comment
Yes you can do that with the internal createrawvmdk
command, which will not create an entire disk image, but a pointer to the actual hardware.
There are two ways to do that
A. Full disk image (of /dev/sdb)
sudo VBoxManage internalcommands createrawvmdk -filename sdb.vmdk -rawdisk /dev/sdb
B. Partition image
As @StarNamer showed, you ca use only one or few partitions.
To create image of just one (/dev/sda1) partition:
sudo VBoxManage internalcommands createrawvmdk -filename sda1.vmdk -rawdisk /dev/sda -partitions 1
To create custom partition table which will map /dev/sda2 and /dev/sda1 in that order:
sudo VBoxManage internalcommands createrawvmdk -filename sda2_1.vmdk -rawdisk /dev/sda -partitions 2,1
Most striking difference will be that full disk image will use bootloader and partition table exactly as they are in your disk, so in theory (I did that previously only in qemu) you will be able to setup OS from your virtual machine. And from my limited experience I can say that full disk image will work exactly as qemu -hda /dev/sdb
.
Note: If you're using user to access the disk, you need to add it to disk
and vboxusers
groups, e.g.
sudo usermod -aG disk,vboxusers ubuntu
then make sure you re-login or restart your computer.
Further reading:
- VirtualBox documentation: Using a raw host hard disk from a guest
VirtualBox boots only in UEFI Interactive shell (just including the ESP for UEFI installs will not work)- Install the Windows MBR bootloader (temporarily) from within Ubuntu (1,
2). - Better, you can install MBR into a file and use the
-mbr
option (see 1) when creating the VMDK. - If you've got
VERR_ACCESS_DENIED
error, check: Virtualbox doesn't work with a real partition.
"full disk image will use bootloader and partition table exactly as they are in your disk" - under which scenario, the first (/dev/sdb) or the second (with partitions specified)?
– naught101
Jul 22 '13 at 23:39
1
Also, virtualbox needs to be run as root, otherwise you getPermission problem accessing the file for the medium '/home/naught101/sda2_windows.vmdk'
– naught101
Jul 22 '13 at 23:49
3
"Also, virtual-box needs to be run as root". Actually no, you need to be a member of group disk. Much safer than running virtual-box as root.
– user193006
Sep 15 '13 at 1:14
2
Here is what worked for me with Ubuntu 16.04 as a host system and Windows 10 as a guest: I created the .vmdk file usingsudo VBoxManage internalcommands createrawvmdk -filename sda1_2_3.vmdk -rawdisk /dev/sda -partitions 1, 2, 3
. That way I included the windows partition as well as the EFI boot loader partition. I then followed the shilka's instructions on virtualbox.org/ticket/7702 and added cloverefiboot. Works like a charm!
– dzmanto
Mar 10 '17 at 10:03
You can also prefix VirutalBox (and VBoxManage) command withsudo -g disk
to only grant that the access to virtualbox, but not all your other processes.
– Jan Hudec
Jan 2 at 21:16
add a comment |
Yes you can do that with the internal createrawvmdk
command, which will not create an entire disk image, but a pointer to the actual hardware.
There are two ways to do that
A. Full disk image (of /dev/sdb)
sudo VBoxManage internalcommands createrawvmdk -filename sdb.vmdk -rawdisk /dev/sdb
B. Partition image
As @StarNamer showed, you ca use only one or few partitions.
To create image of just one (/dev/sda1) partition:
sudo VBoxManage internalcommands createrawvmdk -filename sda1.vmdk -rawdisk /dev/sda -partitions 1
To create custom partition table which will map /dev/sda2 and /dev/sda1 in that order:
sudo VBoxManage internalcommands createrawvmdk -filename sda2_1.vmdk -rawdisk /dev/sda -partitions 2,1
Most striking difference will be that full disk image will use bootloader and partition table exactly as they are in your disk, so in theory (I did that previously only in qemu) you will be able to setup OS from your virtual machine. And from my limited experience I can say that full disk image will work exactly as qemu -hda /dev/sdb
.
Note: If you're using user to access the disk, you need to add it to disk
and vboxusers
groups, e.g.
sudo usermod -aG disk,vboxusers ubuntu
then make sure you re-login or restart your computer.
Further reading:
- VirtualBox documentation: Using a raw host hard disk from a guest
VirtualBox boots only in UEFI Interactive shell (just including the ESP for UEFI installs will not work)- Install the Windows MBR bootloader (temporarily) from within Ubuntu (1,
2). - Better, you can install MBR into a file and use the
-mbr
option (see 1) when creating the VMDK. - If you've got
VERR_ACCESS_DENIED
error, check: Virtualbox doesn't work with a real partition.
"full disk image will use bootloader and partition table exactly as they are in your disk" - under which scenario, the first (/dev/sdb) or the second (with partitions specified)?
– naught101
Jul 22 '13 at 23:39
1
Also, virtualbox needs to be run as root, otherwise you getPermission problem accessing the file for the medium '/home/naught101/sda2_windows.vmdk'
– naught101
Jul 22 '13 at 23:49
3
"Also, virtual-box needs to be run as root". Actually no, you need to be a member of group disk. Much safer than running virtual-box as root.
– user193006
Sep 15 '13 at 1:14
2
Here is what worked for me with Ubuntu 16.04 as a host system and Windows 10 as a guest: I created the .vmdk file usingsudo VBoxManage internalcommands createrawvmdk -filename sda1_2_3.vmdk -rawdisk /dev/sda -partitions 1, 2, 3
. That way I included the windows partition as well as the EFI boot loader partition. I then followed the shilka's instructions on virtualbox.org/ticket/7702 and added cloverefiboot. Works like a charm!
– dzmanto
Mar 10 '17 at 10:03
You can also prefix VirutalBox (and VBoxManage) command withsudo -g disk
to only grant that the access to virtualbox, but not all your other processes.
– Jan Hudec
Jan 2 at 21:16
add a comment |
Yes you can do that with the internal createrawvmdk
command, which will not create an entire disk image, but a pointer to the actual hardware.
There are two ways to do that
A. Full disk image (of /dev/sdb)
sudo VBoxManage internalcommands createrawvmdk -filename sdb.vmdk -rawdisk /dev/sdb
B. Partition image
As @StarNamer showed, you ca use only one or few partitions.
To create image of just one (/dev/sda1) partition:
sudo VBoxManage internalcommands createrawvmdk -filename sda1.vmdk -rawdisk /dev/sda -partitions 1
To create custom partition table which will map /dev/sda2 and /dev/sda1 in that order:
sudo VBoxManage internalcommands createrawvmdk -filename sda2_1.vmdk -rawdisk /dev/sda -partitions 2,1
Most striking difference will be that full disk image will use bootloader and partition table exactly as they are in your disk, so in theory (I did that previously only in qemu) you will be able to setup OS from your virtual machine. And from my limited experience I can say that full disk image will work exactly as qemu -hda /dev/sdb
.
Note: If you're using user to access the disk, you need to add it to disk
and vboxusers
groups, e.g.
sudo usermod -aG disk,vboxusers ubuntu
then make sure you re-login or restart your computer.
Further reading:
- VirtualBox documentation: Using a raw host hard disk from a guest
VirtualBox boots only in UEFI Interactive shell (just including the ESP for UEFI installs will not work)- Install the Windows MBR bootloader (temporarily) from within Ubuntu (1,
2). - Better, you can install MBR into a file and use the
-mbr
option (see 1) when creating the VMDK. - If you've got
VERR_ACCESS_DENIED
error, check: Virtualbox doesn't work with a real partition.
Yes you can do that with the internal createrawvmdk
command, which will not create an entire disk image, but a pointer to the actual hardware.
There are two ways to do that
A. Full disk image (of /dev/sdb)
sudo VBoxManage internalcommands createrawvmdk -filename sdb.vmdk -rawdisk /dev/sdb
B. Partition image
As @StarNamer showed, you ca use only one or few partitions.
To create image of just one (/dev/sda1) partition:
sudo VBoxManage internalcommands createrawvmdk -filename sda1.vmdk -rawdisk /dev/sda -partitions 1
To create custom partition table which will map /dev/sda2 and /dev/sda1 in that order:
sudo VBoxManage internalcommands createrawvmdk -filename sda2_1.vmdk -rawdisk /dev/sda -partitions 2,1
Most striking difference will be that full disk image will use bootloader and partition table exactly as they are in your disk, so in theory (I did that previously only in qemu) you will be able to setup OS from your virtual machine. And from my limited experience I can say that full disk image will work exactly as qemu -hda /dev/sdb
.
Note: If you're using user to access the disk, you need to add it to disk
and vboxusers
groups, e.g.
sudo usermod -aG disk,vboxusers ubuntu
then make sure you re-login or restart your computer.
Further reading:
- VirtualBox documentation: Using a raw host hard disk from a guest
VirtualBox boots only in UEFI Interactive shell (just including the ESP for UEFI installs will not work)- Install the Windows MBR bootloader (temporarily) from within Ubuntu (1,
2). - Better, you can install MBR into a file and use the
-mbr
option (see 1) when creating the VMDK. - If you've got
VERR_ACCESS_DENIED
error, check: Virtualbox doesn't work with a real partition.
edited Jan 3 at 11:14
Jan Hudec
1,07269
1,07269
answered Jan 5 '13 at 10:49
JLarkyJLarky
25923
25923
"full disk image will use bootloader and partition table exactly as they are in your disk" - under which scenario, the first (/dev/sdb) or the second (with partitions specified)?
– naught101
Jul 22 '13 at 23:39
1
Also, virtualbox needs to be run as root, otherwise you getPermission problem accessing the file for the medium '/home/naught101/sda2_windows.vmdk'
– naught101
Jul 22 '13 at 23:49
3
"Also, virtual-box needs to be run as root". Actually no, you need to be a member of group disk. Much safer than running virtual-box as root.
– user193006
Sep 15 '13 at 1:14
2
Here is what worked for me with Ubuntu 16.04 as a host system and Windows 10 as a guest: I created the .vmdk file usingsudo VBoxManage internalcommands createrawvmdk -filename sda1_2_3.vmdk -rawdisk /dev/sda -partitions 1, 2, 3
. That way I included the windows partition as well as the EFI boot loader partition. I then followed the shilka's instructions on virtualbox.org/ticket/7702 and added cloverefiboot. Works like a charm!
– dzmanto
Mar 10 '17 at 10:03
You can also prefix VirutalBox (and VBoxManage) command withsudo -g disk
to only grant that the access to virtualbox, but not all your other processes.
– Jan Hudec
Jan 2 at 21:16
add a comment |
"full disk image will use bootloader and partition table exactly as they are in your disk" - under which scenario, the first (/dev/sdb) or the second (with partitions specified)?
– naught101
Jul 22 '13 at 23:39
1
Also, virtualbox needs to be run as root, otherwise you getPermission problem accessing the file for the medium '/home/naught101/sda2_windows.vmdk'
– naught101
Jul 22 '13 at 23:49
3
"Also, virtual-box needs to be run as root". Actually no, you need to be a member of group disk. Much safer than running virtual-box as root.
– user193006
Sep 15 '13 at 1:14
2
Here is what worked for me with Ubuntu 16.04 as a host system and Windows 10 as a guest: I created the .vmdk file usingsudo VBoxManage internalcommands createrawvmdk -filename sda1_2_3.vmdk -rawdisk /dev/sda -partitions 1, 2, 3
. That way I included the windows partition as well as the EFI boot loader partition. I then followed the shilka's instructions on virtualbox.org/ticket/7702 and added cloverefiboot. Works like a charm!
– dzmanto
Mar 10 '17 at 10:03
You can also prefix VirutalBox (and VBoxManage) command withsudo -g disk
to only grant that the access to virtualbox, but not all your other processes.
– Jan Hudec
Jan 2 at 21:16
"full disk image will use bootloader and partition table exactly as they are in your disk" - under which scenario, the first (/dev/sdb) or the second (with partitions specified)?
– naught101
Jul 22 '13 at 23:39
"full disk image will use bootloader and partition table exactly as they are in your disk" - under which scenario, the first (/dev/sdb) or the second (with partitions specified)?
– naught101
Jul 22 '13 at 23:39
1
1
Also, virtualbox needs to be run as root, otherwise you get
Permission problem accessing the file for the medium '/home/naught101/sda2_windows.vmdk'
– naught101
Jul 22 '13 at 23:49
Also, virtualbox needs to be run as root, otherwise you get
Permission problem accessing the file for the medium '/home/naught101/sda2_windows.vmdk'
– naught101
Jul 22 '13 at 23:49
3
3
"Also, virtual-box needs to be run as root". Actually no, you need to be a member of group disk. Much safer than running virtual-box as root.
– user193006
Sep 15 '13 at 1:14
"Also, virtual-box needs to be run as root". Actually no, you need to be a member of group disk. Much safer than running virtual-box as root.
– user193006
Sep 15 '13 at 1:14
2
2
Here is what worked for me with Ubuntu 16.04 as a host system and Windows 10 as a guest: I created the .vmdk file using
sudo VBoxManage internalcommands createrawvmdk -filename sda1_2_3.vmdk -rawdisk /dev/sda -partitions 1, 2, 3
. That way I included the windows partition as well as the EFI boot loader partition. I then followed the shilka's instructions on virtualbox.org/ticket/7702 and added cloverefiboot. Works like a charm!– dzmanto
Mar 10 '17 at 10:03
Here is what worked for me with Ubuntu 16.04 as a host system and Windows 10 as a guest: I created the .vmdk file using
sudo VBoxManage internalcommands createrawvmdk -filename sda1_2_3.vmdk -rawdisk /dev/sda -partitions 1, 2, 3
. That way I included the windows partition as well as the EFI boot loader partition. I then followed the shilka's instructions on virtualbox.org/ticket/7702 and added cloverefiboot. Works like a charm!– dzmanto
Mar 10 '17 at 10:03
You can also prefix VirutalBox (and VBoxManage) command with
sudo -g disk
to only grant that the access to virtualbox, but not all your other processes.– Jan Hudec
Jan 2 at 21:16
You can also prefix VirutalBox (and VBoxManage) command with
sudo -g disk
to only grant that the access to virtualbox, but not all your other processes.– Jan Hudec
Jan 2 at 21:16
add a comment |
There is an Disk option called "Immutable", so in theory if you select this option for the vmdk linking to your raw disk, it should not change the original partition.
To do so open "Virtual Media Manager" found under "File", select your image and click "Modify" (You have to make sure this image is not attached to any machine, otherwise you get an error). Now you can set the media type to "Immutable".
I have not tested this, though. If anyone does (of course with a test setup) it would be good to report back here.
Has anyone considerations which speak against this idea?
add a comment |
There is an Disk option called "Immutable", so in theory if you select this option for the vmdk linking to your raw disk, it should not change the original partition.
To do so open "Virtual Media Manager" found under "File", select your image and click "Modify" (You have to make sure this image is not attached to any machine, otherwise you get an error). Now you can set the media type to "Immutable".
I have not tested this, though. If anyone does (of course with a test setup) it would be good to report back here.
Has anyone considerations which speak against this idea?
add a comment |
There is an Disk option called "Immutable", so in theory if you select this option for the vmdk linking to your raw disk, it should not change the original partition.
To do so open "Virtual Media Manager" found under "File", select your image and click "Modify" (You have to make sure this image is not attached to any machine, otherwise you get an error). Now you can set the media type to "Immutable".
I have not tested this, though. If anyone does (of course with a test setup) it would be good to report back here.
Has anyone considerations which speak against this idea?
There is an Disk option called "Immutable", so in theory if you select this option for the vmdk linking to your raw disk, it should not change the original partition.
To do so open "Virtual Media Manager" found under "File", select your image and click "Modify" (You have to make sure this image is not attached to any machine, otherwise you get an error). Now you can set the media type to "Immutable".
I have not tested this, though. If anyone does (of course with a test setup) it would be good to report back here.
Has anyone considerations which speak against this idea?
answered Feb 2 '13 at 20:04
EsokratesEsokrates
1
1
add a comment |
add a comment |
For several years now, I have been running dual-booted Windows and Ubuntu with the Ubuntu Partition also booting into Windows VirtualBox to take advantage of the touch-screen capabilities that Linux hasn't yet mastered.
I set it up with instructions similar to below;
- How to Dual Boot and Virtualize the Same Partition on Your Computer
The new machines can simultaneously handle both OSs better than single systems on old machines.
Downside: You need to save the instructions you use for setup in case an update disables the VirtualBox connection (my current problem).
add a comment |
For several years now, I have been running dual-booted Windows and Ubuntu with the Ubuntu Partition also booting into Windows VirtualBox to take advantage of the touch-screen capabilities that Linux hasn't yet mastered.
I set it up with instructions similar to below;
- How to Dual Boot and Virtualize the Same Partition on Your Computer
The new machines can simultaneously handle both OSs better than single systems on old machines.
Downside: You need to save the instructions you use for setup in case an update disables the VirtualBox connection (my current problem).
add a comment |
For several years now, I have been running dual-booted Windows and Ubuntu with the Ubuntu Partition also booting into Windows VirtualBox to take advantage of the touch-screen capabilities that Linux hasn't yet mastered.
I set it up with instructions similar to below;
- How to Dual Boot and Virtualize the Same Partition on Your Computer
The new machines can simultaneously handle both OSs better than single systems on old machines.
Downside: You need to save the instructions you use for setup in case an update disables the VirtualBox connection (my current problem).
For several years now, I have been running dual-booted Windows and Ubuntu with the Ubuntu Partition also booting into Windows VirtualBox to take advantage of the touch-screen capabilities that Linux hasn't yet mastered.
I set it up with instructions similar to below;
- How to Dual Boot and Virtualize the Same Partition on Your Computer
The new machines can simultaneously handle both OSs better than single systems on old machines.
Downside: You need to save the instructions you use for setup in case an update disables the VirtualBox connection (my current problem).
edited Dec 29 '15 at 8:48
AzkerM
7,79242045
7,79242045
answered Dec 29 '15 at 4:02
DespritDesprit
1
1
add a comment |
add a comment |
After many tries I ended up with a neat and clean solution:
- Boot the windows partition you would like to virtualize
- Download Disk2VHD utility from Sysinternals
If you have a UEFI partition, follow these instructions
- Create a VHD (not VHDX) image of your C: partition, recovery, UEFI (if any) and whatever else you want
- Come back to Linux, open VirtualBox and create a VM accordingly to your windows operating system specifications
- Attach to that VM the VHD disk created at point 4
- That's it
- Profit
Troubleshooting in case of UEFI:
- In the VM settings, in VirtualBox, check the option "Enable EFI" under System tab
If you get stuck at the EFI Shell, run the following command:
fs0:EFIBootbkpbootx64.efi
Some comment about the downvote?
– garlix
Nov 8 '18 at 13:06
I see this happened a few days back, but I don't remember giving you downvotes, at least not on purpose. i'd gladly unvote it, sorry.
– userfuser
Nov 11 '18 at 21:14
add a comment |
After many tries I ended up with a neat and clean solution:
- Boot the windows partition you would like to virtualize
- Download Disk2VHD utility from Sysinternals
If you have a UEFI partition, follow these instructions
- Create a VHD (not VHDX) image of your C: partition, recovery, UEFI (if any) and whatever else you want
- Come back to Linux, open VirtualBox and create a VM accordingly to your windows operating system specifications
- Attach to that VM the VHD disk created at point 4
- That's it
- Profit
Troubleshooting in case of UEFI:
- In the VM settings, in VirtualBox, check the option "Enable EFI" under System tab
If you get stuck at the EFI Shell, run the following command:
fs0:EFIBootbkpbootx64.efi
Some comment about the downvote?
– garlix
Nov 8 '18 at 13:06
I see this happened a few days back, but I don't remember giving you downvotes, at least not on purpose. i'd gladly unvote it, sorry.
– userfuser
Nov 11 '18 at 21:14
add a comment |
After many tries I ended up with a neat and clean solution:
- Boot the windows partition you would like to virtualize
- Download Disk2VHD utility from Sysinternals
If you have a UEFI partition, follow these instructions
- Create a VHD (not VHDX) image of your C: partition, recovery, UEFI (if any) and whatever else you want
- Come back to Linux, open VirtualBox and create a VM accordingly to your windows operating system specifications
- Attach to that VM the VHD disk created at point 4
- That's it
- Profit
Troubleshooting in case of UEFI:
- In the VM settings, in VirtualBox, check the option "Enable EFI" under System tab
If you get stuck at the EFI Shell, run the following command:
fs0:EFIBootbkpbootx64.efi
After many tries I ended up with a neat and clean solution:
- Boot the windows partition you would like to virtualize
- Download Disk2VHD utility from Sysinternals
If you have a UEFI partition, follow these instructions
- Create a VHD (not VHDX) image of your C: partition, recovery, UEFI (if any) and whatever else you want
- Come back to Linux, open VirtualBox and create a VM accordingly to your windows operating system specifications
- Attach to that VM the VHD disk created at point 4
- That's it
- Profit
Troubleshooting in case of UEFI:
- In the VM settings, in VirtualBox, check the option "Enable EFI" under System tab
If you get stuck at the EFI Shell, run the following command:
fs0:EFIBootbkpbootx64.efi
edited Mar 15 '18 at 13:14
Melebius
4,57751839
4,57751839
answered Mar 15 '18 at 12:50
garlixgarlix
1091
1091
Some comment about the downvote?
– garlix
Nov 8 '18 at 13:06
I see this happened a few days back, but I don't remember giving you downvotes, at least not on purpose. i'd gladly unvote it, sorry.
– userfuser
Nov 11 '18 at 21:14
add a comment |
Some comment about the downvote?
– garlix
Nov 8 '18 at 13:06
I see this happened a few days back, but I don't remember giving you downvotes, at least not on purpose. i'd gladly unvote it, sorry.
– userfuser
Nov 11 '18 at 21:14
Some comment about the downvote?
– garlix
Nov 8 '18 at 13:06
Some comment about the downvote?
– garlix
Nov 8 '18 at 13:06
I see this happened a few days back, but I don't remember giving you downvotes, at least not on purpose. i'd gladly unvote it, sorry.
– userfuser
Nov 11 '18 at 21:14
I see this happened a few days back, but I don't remember giving you downvotes, at least not on purpose. i'd gladly unvote it, sorry.
– userfuser
Nov 11 '18 at 21:14
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- 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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f168156%2fhow-to-use-a-real-partition-with-windows-7-installed-in-a-virtualbox-vm%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Why is your MSWIN partition 1TiB? Although, not a complete solution: If possible, move everything that doesn't need to be on there (data...media files?) and then re-size the partition which will make any approach easier. If you wanted to go the image route, clearing then shrinking that partition will leave you with enough space to make a full image of the smaller, new partition. :-)
– Alastair
Jan 6 '14 at 14:58
Related: Use physical harddisk in Virtual Box
– kenorb
Dec 10 '18 at 22:59