VirtualBox Tips
TyeYeah Lv4

Here are some tips for virtual box.

Minimize VirtualBox’s VM Space

Defrag

Linux guest machine:

1
2
$ sudo dd if=/dev/zero of=/EMPTY bs=1M
$ sudo rm -f /EMPTY

Windows guest os (using Sysinternals Suite):

1
sdelete –z c: % or other drive %

Compress Disk

for VDI file:

1
$ VBoxManage modifyhd xxx.vdi --compact

but for Vmware’s VMDK file:

1
2
3
4
5
$ VBoxManage clonehd "source.vmdk" "cloned.vdi" --format vdi
$ VBoxManage modifyhd cloned.vdi --compact
$ VBoxManage clonehd "cloned.vdi" "compressed.vmdk" --format vmdk
# after transforming vmdk to vdi, you will find size reduced largely
# so you can neglect step 2

or

1
vmware-vdiskmanager -k disk.vmdk

Install MacOS Virtual Machine

See Here to get the complete process of operation.

Download the ISO image of macOS first.
Contact me if you want ISO of macOS High Sierra.

Create a Machine

Create a new macOS virtual machine, which is supported in VirtualBox by default.

even supports mojave

Bigger video memory, more processor cores and larger storage are needed.

larger is better

After the Creation

After creating virtual disk, run VBoxManage commands before booting macOS virtual machine

High Sierra:

1
2
3
4
5
6
7
8
# 'macOS' is your vm's name
# use VBoxManage.exe on Windows
$ VBoxManage.exe modifyvm "macOS" --cpuidset 00000001 000306a9 04100800 7fbae3ff bfebfbff
$ 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/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
$ VBoxManage setextradata "macOS" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1

Mojave:

1
2
3
4
5
6
$ VBoxManage modifyvm macOS --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
$ VBoxManage setextradata macOS "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
$ VBoxManage setextradata macOS "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
$ 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

Resolution Configuration

When booting up, you will find the resolution not fitting.

Configure resolution:

1
2
3
4
5
$ VBoxManage setextradata macOS CustomVideoMode1 1366x768x32
$ VBoxManage setextradata macOS VBoxInternal2/EfiGraphicsResolution 1366x768

$ VBoxManage setextradata macOS VBoxInternal2/EfiHorizontalResolution 1366
$ VBoxManage setextradata macOS VBoxInternal2/EfiVerticalResolution 768

More in Fix VirtualBox macOS High Sierra Screen Resolution (1920×1080 – 4K – 5K) and How to Fix macOS Sierra Screen Resolution on VirtualBox?

Others

In Mac OS some root users are still limited to do some operations. Reboot to enter recovery mode (command + r) and:

1
$ csrutil disable   # `csrutil enable` to recovery

to let users edit some key files.

Powered by Hexo & Theme Keep
Total words 135.7k