VirtualBox: Difference between revisions
Line 143: | Line 143: | ||
* Next, create the raw disk as a vmdk volume. Update the MBR code to remove GRUB. <font color="red">Repeat this every time the partitions change</font>: |
* Next, create the raw disk as a vmdk volume. Update the MBR code to remove GRUB. <font color="red">Repeat this every time the partitions change</font>: |
||
{{pl2|<source lang="bash" enclose="prevalid"> |
{{pl2|<source lang="bash" enclose="prevalid"> |
||
sudo dd if=/dev/sda of= |
sudo dd if=/dev/sda of=vm.mbr bs=512 count=1 |
||
sudo apt-get install mbr # For command "install-mbr" |
sudo apt-get install mbr # For command "install-mbr" |
||
sudo install-mbr -i n -p D -t 0 |
sudo install-mbr -i n -p D -t 0 vm.mbr |
||
sudo VBoxManage internalcommands createrawvmdk -filename nxl67002-sda2-mbr.vmdk -rawdisk /dev/sda -partitions 2 -relative -mbr |
sudo VBoxManage internalcommands createrawvmdk -filename nxl67002-sda2-mbr.vmdk -rawdisk /dev/sda -partitions 2 -relative -mbr vm.mbr |
||
</source>}} |
</source>}} |
||
* Boot the virtual machine with the raw disk above. When Windows is launched, install the '''VirtualBox guest additions'''. |
* Boot the virtual machine with the raw disk above. When Windows is launched, install the '''VirtualBox guest additions'''. |
Revision as of 18:11, 9 March 2013
Reference
- http://www.virtualbox.org
- Chapter 8. VBoxManage (all the VBoxManage commands)
Installation
Reference instructions can be found here.
Installation using repository
- For VirtualBox 4.x:
- Add the following lines to /etc/apt/sources.list (here for Ubuntu Lucid — now in contrib):
- Add the Oracle public key for apt-secure, then install
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add - sudo apt-get update sudo apt-get install virtualbox-4.0
- Download the extension pack from here, and install it using File → Preferences → Extensions menu, or with
- For VirtualBox 3.2.x:
- Add the following lines to /etc/apt/sources.list (here for Ubuntu Lucid):
- Add the Oracle public key for apt-secure, then install
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add - sudo apt-get update sudo apt-get install virtualbox-3.2
- For VirtualBox 3.1.x:
- Add the following lines to /etc/apt/sources.list (here for Ubuntu Karmic):
- Add the Sun public key for apt-secure, then install
wget -q http://download.virtualbox.org/virtualbox/debian/sun_vbox.asc -O- | sudo apt-key add - sudo apt-get update sudo apt-get install virtualbox-3.1
deb http://download.virtualbox.org/virtualbox/debian lucid contrib
VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.0.0-69151.vbox-extpack
deb http://download.virtualbox.org/virtualbox/debian lucid non-free
deb http://download.virtualbox.org/virtualbox/debian karmic non-free
The group vboxusers is created during installation.
- Users of the VirtualBox must be member of that group. New users can be added with
sudo usermod -a -G vboxusers username
- The daemon for the network interfaces will be assigned to that group.
Recompiling the vboxdrv module after kernel update
VirtualBox requires a kernel module vboxdrv. This module must be recompiled every time the kernel is updated (if not, there will be typically errors related to missing network interfaces).
- The default location of the module is given by setting KDIR=[fullpath] in file /etc/default/virtualbox.
- The kernel module can be compiled with
sudo /etc/init.d/vboxdrv setup
- Enable Dynamic Kernel Module Support to deal with Kernel Upgrade
Launch VirtualBox as another user
- Limitation! It seems that only one user can access PulseAudio (see [1]). This means that when launching VirtualBox as another user (other than root), it will not be possible to play sounds in the host anymore.
- Create user vbox (disabled, uid 7000, group vboxusers + groups cdrom,
audio,video, plugdev, fuse, netdev). This user will store VirtualBox settings and disks, access bluetooth... - If user vbox needs to access a partition directly (e.g. because using a raw drive), give RW access on the selected partition. For instance, to give RW access to partition /dev/sda2, create a new udev rule in file /etc/udev/rules.d/99-custom.rules:
# Rules to change the ownership of /dev/sda2 to user "vbox" (vbox will boot /dev/sda2 in VirtualBox + follow least privilege principle)
# reference: http://www.reactivated.net/writing_udev_rules.html#ownership
KERNEL=="sda2", SUBSYSTEM=="block", OWNER="vbox"
- Allow users to launch VirtualBox through user vbox. Add to /etc/sudoers:
ALL ALL=NOPASSWD: /bin/su vbox -c /usr/bin/VirtualBox
- Helper function to add to e.g. ~/.bashrc :
function winbox() {
#First allow user vbox to connect to X11
xhost +SI:localuser:vbox
sudo su vbox -c /usr/bin/VirtualBox&
}
Creating a New Virtual Machine
- To boot a Virtual Machine directly from a physical disk partitions, see section Advanced storage configuration in Ch. 9 Advanced topics.
Guests Installation
Windows Guest
- Enabling 3D accelerated graphics
- To enable 3D accelerated graphics, install the GuestAdditions in SAFE mode. Otherwise Windows file protection mechanism will revert the files to the original ones.
Migrating Windows
Reference: http://www.virtualbox.org/wiki/Migrate_Windows
- Check HAL (enable or disable IO APIC in virtualbox as a result, or update the HAL in Windows by changing the files)
- Run MergeIDE to avoid the error message
STOP: 0x0000007B (0xF741B84C,0xC0000034,0x00000000,0x00000000) INACCESSIBLE_BOOT_DEVICE
- Delete agp440.sys (necessary on WinXP) and if needed intelppm.sys
Other links:
- http://www.techspot.com/vb/topic21511.html
- http://forums.virtualbox.org/viewtopic.php?f=7&t=19847
- http://forum.driverpacks.net/viewtopic.php?id=3865
- http://ubuntuforums.org/showthread.php?t=769883
Migrating Windows 2000
Here are the steps I followed to migrate my W2K partition to a VirtualBox machine with .VDI disk:
- First copy the W2K partition (say /dev/sda1) to some file
sudo if=/dev/sda1 bs=4096 | gzip -c > w2k-sda1.dd.gz
- On the host, create an empty .VDI file of sufficient size.
- Attach the empty VDI to a new virtual machine, and boot from a Ubuntu Live CD or equivalent.
- Create a new NTFS partition on the empty disk (with gparted), and copy the partition above:
scp user@machine:/path/to/w2k-sda1.dd.gz >(gzip -d -c | sudo dd of=/dev/sda1 bs=4096)
- Again with gparted, resize the NTFS partition to full size (shrink then grow back if needed), and set the flag 'boot'.
- Shutdown the virtual machine, and attach an existing W2K disk to the virtual machine as master, and the migrated partition disk as slave. Start the machine.
- Delete the agp440.sys driver if present on the slave disk.
- Follow the mergeide.reg procedure here. Basically:
- Run regedt32, select HKEY_LOCAL_MACHINE, and load hive /WINNT/system32/config/system from slave disk in a key named aaaa. Close registry editor.
- Click on mergeide.reg to register the new keys.
- Run regedt32, and unload the hive aaaa. Close the editor.
- Stop the machine, remove the existing W2K disk, and set the migrated partition as master. Start the machine.
Reference links:
Booting Existing Windows XP from Physical Partition
Host Setup
- Dell Latitude E6500 (with virtualization instructions)
- VirtualBox 3.2.0, Ubuntu 10.04 Lucid Lynx
Guest Setup
- Windows XP SP3
- Base Memory 1536 MB, 2 cpus, VT-x/AMD-V enabled, Nested Paging enabled
- Video memory 48 MB, 2 monitors, 3D accel enabled, 2D accel enabled
- Audio host driver PulseAudio, controller ICH AC97
- Network PCnet-FAST III, bridged, eth0
Let's say the Windows partition is on partition /dev/sda2.
- First, as described in [2], delete agp440.sys (or rename) from C:\Windows\system32\drivers. This driver will conflict with the virtual video card installed by VirtualBox and will make it crash.
- Next, create the raw disk as a vmdk volume. Update the MBR code to remove GRUB. Repeat this every time the partitions change:
sudo dd if=/dev/sda of=vm.mbr bs=512 count=1
sudo apt-get install mbr # For command "install-mbr"
sudo install-mbr -i n -p D -t 0 vm.mbr
sudo VBoxManage internalcommands createrawvmdk -filename nxl67002-sda2-mbr.vmdk -rawdisk /dev/sda -partitions 2 -relative -mbr vm.mbr
- Boot the virtual machine with the raw disk above. When Windows is launched, install the VirtualBox guest additions.
This is done! When booting Windows natively, the VirtualBox guest additions will detect that VirtualBox is not running and will disable itself.
Windows Guest with BitLocker
Some interesting links:
- Locking down a Virtual Machine with BitLocker
- Enable BitLocker Without a TPM - Windows Vista and Windows 7 Help
Windows 7 P2V (Physical-to-Virtual) Migration
Refererences - tips
-
- Run MergeIDE
- Delete AGP440.SYS, intelppm.sys
- ...
- https://forums.virtualbox.org/viewtopic.php?f=6&t=33476 — BSOD x0000007B
- Select another virtual disk controller, i.e. either IDE PIIX3 or PIIX4.
Benchmarks
Settings:
- Dell Latitude E6500, 4GB RAM.
- VirtualBox 3.1.6.
- System: 1536 MB RAM, IO APIC, 2 CPU with PAE/NX, VT-x + Nested Paging.
- Video: 32 MB Video + 2D accel
- Storage: PIIX4 ctrl, raw vmdk image /dev/sda
- Audio: PulseAudio + ICH AC97
- Network: Bridged Adapter
task | U9.04-32 | U9.04-32 | U9.04-32 | U9.10-32 | U9.10-32 | U9.10-32 | U9.10-64 | U9.10-64 | U9.10-64 | U9.04-32 | U9.04-32 | Native | Native | Native |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
grub →hw profile | 2.86 s | 2.82 s | 2.77 s | 2.76 s | 2.68 s | 2.84 s | 2.50 s | 2.51 s | 2.61 s | 3.22 s | 2.73 s | 1.62 s | 1.57 s | 1.41 s |
... →login screen | 23.49 s | 23.46 s | 21.56 s | 42.07 s | 43.48 s | 40.28 s | 48.63 s | 52.00 s | 56.07 s | 33.15 s | 24.06 s | 29.52 s | 24.89 s | 25.16 s |
... →pwd typed | 17.69 s | 12.94 s | 12.62 s | 9.83 s | 9.69 s | 8.56 s | 15.41 s | 9.85 s | 9.31 s | 9.68 s | 8.75 s | 9.88 s | 8.42 s | 8.99 s |
... →communicator | 8.83 s | 7.73 s | 8.45 s | 32.51 s | 29.97 s | 36.57 s | 38.50 s | 33.53 s | 34.44 s | 20.48 s | 8.24 s | 9.47 s | 7.20 s | 6.81 s |
U9.04-32: Base Ubuntu 9.04 Jaunty i386 Live running on USB, 2.6.28-11-generic.
U9.10-32: Base Ubuntu 9.10 Karmic i386 Live running on USB
U9.10-64: Base Ubuntu 9.10 Karmic AMD64 running from HDD, 2.6.31-20-generic
Native: Running Windows directly, no emulation
Conclusions:
- Ubuntu 9.04 + VirtualBox 3.1.6 → FAST !!!
- Ubuntu 9.10 + VirtualBox 3.1.6 → SLOW !!!
External references:
- Interesting post about step-by-step configuration to run an existing Windows XP installation.
- Two posts about disabling IO APIC:[3] and [4]. But apparently this doesn't really fix anything (also the poster has a old cpu, etc).
Bugtracker
- Enhancement - #6854 - Allow hot-plug addition / removal of screens (monitors) in guest OS