Skip to content

Instantly share code, notes, and snippets.

@kanchudeep
Last active November 24, 2022 22:00
Show Gist options
  • Save kanchudeep/b607dbbef95b53d91768bda576fcb270 to your computer and use it in GitHub Desktop.
Save kanchudeep/b607dbbef95b53d91768bda576fcb270 to your computer and use it in GitHub Desktop.
Access Host Machine Localhost:
10.0.2.2
Access Guest Machine Localhost:
1. In VM settings under 'Network', change 'Attached to' from 'NAT' to
'Bridged Adapter'.
2. Find IP address of VM and use it to access.
Compact virtual disk:
1. Zero out free space in VMs...
a. For GNU/Linux VMs, in guest OS execute:
sudo dd if=/dev/zero of=/bigemptyfile bs=4096k status=progress
sudo rm -f /bigemptyfile
b. For macOs VMs, in guest OS execute:
sudo diskutil secureErase freespace 0 "/Volumes/<drive-name>"
c. For Windows VMs, in guest OS execute:
sdelete -z c:
2. From the host:
vboxmanage modifymedium --compact disk {disk-image-uuid}
...or...
vboxmanage modifymedium --compact disk /path/to/disk.vdi
Convert disk image:
Convert raw Disk Image to VDI:
vboxmanage convertfromraw --format VDI file.img file.vdi
Convert VDI to raw Disk Image:
vboxmanage internalcommands converttoraw file.vdi file.raw
Convert VMDK to VDI:
vboxmanage clonehd --format VDI /path/to/disk.vmdk /path/to/disk.vdi
Enable USB support (GNU/Linux)
sudo usermod -a -G vboxusers <username>
Fix Error 1055 while installing Guest Additions
1. Open command prompt.
2. Run 'sc lock' and then press 'u' at the prompt.
3. In case of no prompt, start VM in safe mode and install.
Garbled Video in GNU/Linux VM:
1. On the garbled screen press 'Host key' + F2 to switch to tty02. Then
switch back to tty07 by pressing 'Host key' + F7.
2. To prevent add argument 'nomodeset' to 'linux' line while booting in
Grub.
Install macOS VM:
1. Choose at least 4 GiB of RAM (70% of actual) for the Virtual Machine.
2. In 'Settings':
a. Under 'System > Motherboard':
i. Disable 'Floppy' from boot order.
ii. Select 'ICH9' as chipset.
iii. Enable 'EFI'.
b. Under 'System > Processor':
i. Set maximum No of processors you can spare.
ii. Enable 'PAE/NX'.
c. In the 'Display' tab:
i. Set 'Video Memory' as 128MiB.
ii. Enable 3D acceleration.
d. In 'USB' tab, select 'USB 3.0 (xHCI) Controller'.
e. In 'Audio', deselect 'Enable Audio'.
3. With VirtutalBox not running, execute following ('macOS' is VM name):
vboxmanage modifyvm macOS --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
# vboxmanage modifyvm macOS --cpuidset 00000001 000306a9 04100800 7fbae3ff bfebfbff # Does not work!?
vboxmanage setextradata macOS "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
# vboxmanage setextradata macOS "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "MacBookPro11,3"
vboxmanage setextradata macOS "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
vboxmanage setextradata macOS "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Mac-2BD1B31983FE1663"
# vboxmanage setextradata macOS "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
vboxmanage setextradata macOS "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
vboxmanage setextradata macOS "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
vboxmanage setextradata macOS "VBoxInternal/Devices/efi/0/Config/DmiSystemSerial" "C02L6947F8JC"
4. Boot and run the installer.
5. Use 'Mac OS Extended (Journaled)' with 'GUID Partition Map' and NOT 'AFS'.
6. Once install finishes and reboots again into installer, remove disk image
image from virtual drive and reboot.
7. Boot will fail and bring you to UEFI prompt. Continue install after
booting: FS1:\macOS Install Data\Locked Files\Boot Files\boot.efi
* Note: Execute 'date 0101010116' in Terminal before installing El Capitan.
Mount VirtualBox Share in GNU/Linux:
sudo mount -t vboxsf <share name> /path/to/mount
Raw Disk Access
Linux
vboxmanage internalcommands createrawvmdk -filename /path/to/file.vmdk -rawdisk /dev/sdX
* Note: VirtualBox has to be started elevated with 'sudo'
Windows
vboxmanage internalcommands createrawvmdk -filename path\to\file_name.vmdk -rawdisk \\.\PhysicalDrive#
* Note: Can only be accessed when virtualbox is run with administrative
previlages.
Set UUID of disk image:
vboxmanage internalcommands sethduuid /path/to/disk-image.vdi
Speedup VM:
1. If saving disk image on non SSD, use fixed size disk image.
2. Enable ACPI for Windows XP and later.
3. Enable PAE/NX.
4. Try and enable 2D/3D acceleration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment