VirtualBox/Print version

From Wikibooks, open books for an open world
Jump to navigation Jump to search


VirtualBox

The current, editable version of this book is available in Wikibooks, the open-content textbooks collection, at
https://en.wikibooks.org/wiki/VirtualBox

Permission is granted to copy, distribute, and/or modify this document under the terms of the Creative Commons Attribution-ShareAlike 3.0 License.


Basics

Symbol version newer.svg

This page applies to version 5.2 and newer of Oracle VM VirtualBox.


Hypervisors are a type of software that manage virtual machines which are, in theory, emulated PCs. Thus, hypervisors can be seen as a type of emulator, in which one system pretends to be another by translating its code into something that can be executed.

Because the IBM PC's architecture, x86, is a complex instruction set by design, it is able to do complex operations that allow it to efficiently emulate other platforms. But how about x86 itself?

In x86, software runs in privilege levels (often called rings) and are organized by the operating system. Operating systems will often run their portion of the code (the kernel) in as low of a level as possible so that it can effectively manage the system and the userspace-- ring 0, thus referred to as the kernel mode. Standard software (like executable files you download from websites) run in ring 3, referred to as the user mode.

VirtualBox virtualizes x86 and does very little emulation of the user mode; instead of translating every instruction on-the-fly, it emulates ring 0 by relocating the virtual kernel code to ring 1 and traps instructions when the kernel or software calls for I/O access (i.e. drivers). There are other specific situations that the developers had to work around, but the rest of the software runs almost unmodified, allowing for near-bare-metal performance of software in many cases.

VirtualBox uses code based on QEMU, but it is not a QEMU fork. QEMU has KVM which allows for it to employ similar practices to VirtualBox, but it also targets a wide variety of platforms outside of x86 (such as PowerPC, ARM, and SPARC) that VirtualBox does not.

Hosts emulating Guests[edit]

In the context of virtualization, your main computer is called the host. It has access to physical components like the monitor, the keyboard and mouse, and the hard disk. When running an operating system in VirtualBox, a guest does not have that same access. It's instead replaced with virtual components that are managed by the hypervisor and the OS kernel, like virtual hard disks on the filesystem. VirtualBox allows you to interface with the guest using an emulated keyboard, mouse, and monitor that's as close to generic as possible so that the operating system has the correct drivers. If those drivers are not part of the operating system, VirtualBox will also include Guest Additions that install integrations with the host like clipboard sharing and dynamic resolutions (where the OS will resize the display to the window).

Host CPU requirements[edit]

SSE2 (Streaming SIMD Extensions 2) support is required for host CPUs in order for VirtualBox to work.

Virtual Media[edit]

Within VirtualBox you will encounter the Virtual Media Manager. This is a list of disks VirtualBox has previously used with guests. The three types-- hard disks, optical disks, and floppy disks-- are memorized and grouped by the manager, and can be removed or copied if needed. When these images cannot be detected at the program's start, it will notify the user.

The list of supported hard drive formats are:

  • VDI (Virtual Disk Image): VirtualBox's native format.
  • VMDK (Virtual Machine DisK): Designed by VMware.
  • VHD (Virtual Hard Disk): Previously Connectix's format for Virtual PC, but now used by Microsoft. On a Windows host, these files can be mounted natively in the Disk Management utility.[note 1]
  • VHDX (Virtual Hard Disk Extended): Microsoft's format for Hyper-V.
  • HDD (Hard Disk Drive): Parallels' native format. VirtualBox does not support versions newer than 2, citing lack of documentation on the format. Parallels includes utilities to downgrade the format, however.
  • QCOW (Quick Copy-On-Write): Previously QEMU's native format; it's since been succeeded by QCOW2. QCOW2 support is read-only in VirtualBox.
  • QED: An experimental successor to QCOW that has since been deprecated. Support is only included for compatibility with existing images, and it is recommend to convert to another format.

Floppy disks are a special case as they hold a low amount of data and thus, do not need a special image format to save disk space or speed up the machine.

There are two file extensions, FLP and IMG, that are often used, but the amount of distinctions between these types are almost entirely zero. Floppy disk images are actually raw formats, as they completely preserve the data of the disk but not the physical aspects.

Dynamic Allocation and Compacting[edit]

Dynamic allocation is used in situations where saving space is crucial to your workflow, in which the image uses less space on the disk than it is assigned.

When you delete a file on any computer, the hard disk doesn't actually wipe its sectors (bigger files would take longer to delete if that was the case). Instead, it marks the sectors where the data was stored as overwritable, so that the space is freed. This explains why data recovery is possible; recovery software will search through "empty" sectors for data. To cut down the size of a virtual disk, you need software that will write null values to the empty sectors so that it becomes redundant, thus becoming a pattern that can be compressed. Disks can be compacted using the CLI tool VBoxManage.

The Files[edit]

The files for your VirtualBox VMs can be found at:

  • Windows: %USERPROFILE%\VirtualBox VMs
  • Linux: ~/VirtualBox VMs

You can quickly access a VM's folder by right-clicking on it from VirtualBox and selecting "Show in File Manager".[note 2]

The barebones components of a guest's folder includes:

  • A .vbox file. This makes up all the details of the system itself, such as the specs, which images and devices are routed where, etc.
  • A hard disk image

Other components may include:

  • A .vbox-prev file. This is a backup copy of the .vbox file.
  • A Logs folder. This contains logs of the machine in case anything goes wrong.
  • A Snapshots folder. This contains snapshots.

Notes[edit]

  1. On Windows 7 and newer only.
  2. On Windows, this is called Windows Explorer.



Installation

VirtualBox can be downloaded from the official website at virtualbox.org. The main page has a big blue download button that takes you to the download page. From there, you can select your system.

Windows
Linux



Installation/Windows

Supported Windows host operating systems (64 bit)[edit]

  • Windows 8.1
  • Windows 10 RTM (1507 / 2015 LTSB) build 10240
  • Windows 10 Anniversary Update (1607 / 2016 LTSB) build 14393
  • Windows 10 Fall Creators Update (1709) build 16299
  • Windows 10 April 2018 Update (1803) build 17134
  • Windows 10 October 2018 Update (1809 / 2019 LTSC) build 17763
  • Windows 10 May 2019 Update (19H1 / 1903) build 18362
  • Windows 10 November 2019 Update (19H2 / 1909) build 18363
  • Windows Server 2012
  • Windows Server 2012 R2
  • Windows Server 2016
  • Windows Server 2019

Download[edit]

The VirtualBox installer can be downloaded from the official VirtualBox website. You might want to compare the checksums to verify the integrity of downloaded packages. The SHA256 checksums should be favored as the MD5 algorithm must be treated as insecure!

Installation[edit]

Run the downloaded installer and follow the on-screen instruction to install Oracle VM VirtualBox. You can opt to add a desktop and start menu shortcut.

NOTE: Your network connections (including the Internet connection) will be interrupted for a short time while the installer installs VirtualBox network drivers.



Installation/Linux

Tux.svg

Specific Instruction Vary depending on your distribution. The first step is to download the version that is correct for your distro. However, Debian and Red Hat based systems now have an automatic install/update option for the OSE.

Officially supported Linux distributions[edit]

  • Ubuntu 18.04 LTS, 19.03 and 19.10
  • Debian GNU/Linux 9 ("Stretch") and 10 ("Buster")
  • Oracle Linux 6, 7 and 8
  • Red Hat Enterprise Linux 6, 7 and 8
  • Fedora 30 and 31
  • Gentoo Linux
  • SUSE Linux Enterprise server 12 and 15
  • openSUSE Leap 15.1

Note that Linux 2.4-based host OSes are no longer supported.

Installation for Debian Systems[edit]

These include Debian and Ubuntu

Building a Kernel Mod[edit]

See Below

Installation for Ubuntu[edit]

Open a terminal and type

   sudo apt-get update
   sudo apt-get install virtualbox

and follow the prompts.

Installation for Red Hat based Systems[edit]

These Include Red Hat Enterprise Linux (RHEL), CentOS, and Fedora.

PUEL Edition[edit]

After downloading the rpm file for your distro, there are a number of methods of installation.

1. Double Click on the file, it should install VirtualBox 2. In a Terminal using YUM

Using YUM in a Terminal[edit]

Load up a terminal and change directory to the one where you saved the rpm. To continue beyond this point you will need root privileges. You will either need to be logged on as root (not recommended), su to root, or use sudo (if you have that configured). The following assumes that you are using sudo. If you are logged on as root or you used su then the instructions will work as shown. However, you may also exclude the "sudo" in front of the commands.

In the terminal type

 sudo yum localinstall *name*.rpm --nogpgcheck

Replace *name* with the name of the rpm file.

Yum will load up and check for dependencies. After doing that it should ask if you want to install VirtualBox. Type 'Y' (without quotations) to continue. VirtualBox will now be installed on your machine.

Building a Kernel Mod[edit]

See Below

Other[edit]

Building a Kernel Mod[edit]

See Below

Building a Kernel Mod[edit]

In order to run VirtualBox requires a Kernel Mod. VirtualBox installed a script that can build the mod for you. In order to do this you will require the Kernel Development Tools and GCC to be installed on your machine. Assuming you have those you may continue by running the following command in a terminal:

sudo /etc/init.d/vboxdrv setup

If all is successful the script to successfully compile and initialise a VirtualBox Kernel Mod. This mod should load automatically each time you reboot your host computer.

NOTE: You will need to rebuild the mod (using the script mentioned above) every time you update the Kernel.

Further reading[edit]



Installation/macOS

Supported Mac OS hosts[edit]

  • 10.13 (High Sierra)
  • 10.14 (Mojave)
  • 10.15 (Catalina)

Note that Intel hardware is required for VirtualBox to function on Mac OS hosts.

Download[edit]

The VirtualBox installer can be downloaded from the official VirtualBox website. You might want to compare the checksums to verify the integrity of downloaded packages. The SHA256 checksums should be favored as the MD5 algorithm must be treated as insecure!



Setting up a Virtual Machine

Windows
Ubuntu
Mac OS X (macOS Catalina, Mojave, High Sierra)
Other

Prevent malware infection by downloading software only from its licensed distributor. Avoid ready-made installation images or virtual disk images, as they may contain malware.



Setting up a Virtual Machine/Windows

Remarks[edit]

  • Please check the images. They are not perfectly aligned.
  • As Windows is not open-source, no screenshots of Windows are present here to prevent any kind of copyright infringement.

Create Installation Media[edit]

Using Media Creation Tool (for Windows 10 VM)[edit]

  1. Download the Media Creation Tool from the Microsoft Official Website.
  2. Run the Media Creation Tool.
  3. Select the Installation Media Type. Choose "Create a bootable disk image".
  4. Choose file destination.
  5. Wait for a while. The download size is typically around 4.7 GB. When the creation of installation media completes, you will be redirected to the file destination. You should see a .iso file in that folder.

For other versions of Windows[edit]

  1. Download the Windows disk image from a trustworthy source. If you are not using a Windows host machine, the download link for the Media Creation Tool will be replaced by the direct download link of the official .iso file.
  2. Compare the checksum (if available) to verify the integrity of the disk image file.

Install in VirtualBox[edit]

  1. Open VirtualBox
    CreateVirtualHardDisk.png
  2. Press "New" Button on the Left Upper Corner
    VDIsize.png
  3. You will see the screen on the right. Enter a suitable name for the Virtual Machine. Also, Choose "Windows" for "Type" and your downloaded version for "Version".
    StorageVM.png
  4. For Memory, choose a suitable value (usually more than 2048 MB).
    WindowsVmSystem.png
  5. As shown on the right, choose "create a virtual hard disk".
    WindowsVMNetwork.png
  6. Select "VDI"
    SelectVDI.png
  7. Select "Dynamically Allocated".
    DynamicallyAllocated.png
  8. Select the name and a suitable size (at least 50GB, this is the maximum size of virtual machine)for the virtual storage.Also, create a file location.
  9. After that, a virtual machine will be created. However, do not boot.
    VirtualBoxWindowsChoose.png
  10. Go to "Storage" Section.
    WindowsVMMemory.png
  11. Add a SATA Controller
  12. Choose Add Optical Hard Drive
  13. Choose the .iso file created above.
  14. Go to "System" Section.
  15. Set the Boot Order to: Optical Hard Drive, Hard Disk
  16. Go to "Network" Section.
  17. Tick the "Enable Netork Adapter Checkbox" and the "Cable Connected" checkbox. (The latter checkbox is in the Advanced Section).
  18. Quit Settings and Boot by clicking "Start".
  19. You will see a installation screen. Click "Install Now".
  20. Then enter the product key in the spaces provided. Otherwise, click "I don't have a product key". This enables you to have limited functions.
  21. Accept End User License agreement.
  22. Wait for Installation.
  23. After installation completes, shut down machine and go to Settings.
  24. Go to "Systems" Section and revert boot order.]
  25. Click "Processor" tab and set the number of CPUs.
  26. Go to "Display" Section and set the video memory to maximum value.

GREAT! YOU HAVE FINISHED THE SET UP. EXPLORE YOURSELF!!!

Resize[edit]

Here is the DOS command for six gigs (the size must be in megabytes):

"C:\Program Files\Oracle\VirtualBox\VBoxManage" modifyhd "MyVMPath.vdi" --resize 6000

NB: you may need to resize the internal VM partition after, for example to enlarge "/" in Linux :

  • boot with gparted
  • move the other partitions at the disk end
  • then resize /

FAQ[edit]

The Windows installation page doesn't allow me to skip product key entry. How to skip this?[edit]

If this is the case, it would be quite complicated.

  1. First, you will need to mount the iso file by your own means: Windows does not have built-in function to unpack iOS files. But there is a software called Virtual CD-ROM Control Panel. If you are using OS X, mount it by "Disk Utility".
  2. Open the .iso file and search for a file called "ei.cfg".
  3. If this file exists, open with Notepad/TextEdit. Otherwise, create a CFG file. (Save it as "All Files" and type "ei.cfg" for name.
  4. Type the following (type all content as is if bracketed in [], write by instructions if bracketed in {}):
   [Edition ID]
   {Edition you desire (e.g. Home/Professional)}
   [Channel]
   {OEM/Retail}
   [VL]
   {0/1}
  • For any other problems, see this Microsoft page
  • Save this file and you should see the "Skip for now" option.



Setting up a Virtual Machine/Ubuntu

Once you have VirtualBox installed on your host computer -- it doesn't matter if your host OS is Linux, MacOS, or something else -- setting up an Ubuntu virtual machine is easy.

(This was tested installing Ubuntu Desktop 18.04 LTS as a guest in VirtualBox-6.0.18 on a Windows 10 host. Other versions and other hosts should work similarly.) (For Ubuntu 14.04.1 LTS, see https://en.wikibooks.org/w/index.php?title=VirtualBox/Setting_up_a_Virtual_Machine/Ubuntu&oldid=3656915 ).

host operating system pre-install steps[edit]

  • Go to http://www.ubuntu.com/ , hit the "download" link, and pick whichever version of Ubuntu you want to try out in a virtual machine. For example, you may want to try Ubuntu Desktop 18.04 LTS. Download it to your host computer. Don't wait until it is done, which may take a few minutes -- continue with the following while it's downloading.
  • Start the Oracle VM VirtualBox Manager.
  • Hit the starry blue "New" icon.
  • Name the virtual machine. (Many people give woefully uncreative names like "testUbuntu18")
  • Choose Type: Linux. (Ubuntu is one kind of Linux. Remember, this is the guest operating system running inside the virtual machine, not your host operating system).
  • Choose Version: Ubuntu (64 bit).
  • The default is 1024 MB RAM -- bump this up to at least 2048 MB RAM for Ubuntu 18.[1]
  • Hit the "Next" or "Create" button a few times (2048 MB RAM, keep the default 10 GB hard drive file -- you can make these bigger or smaller later), until you see an icon for your virtual machine in the left sidebar of the Oracle VM VirtualBox Manager.
  • (Optional: If your purpose for setting up this machine is to practice installing Ubuntu on a RAID array in a safe sandboxed environment, set up additional virtual hard drive images now under Settings >> Storage).
  • Click on the icon for that virtual machine ("testUbuntu18") and hit the big green arrow "Start" icon.
  • Has the download finished yet? When it's done downloading, you should have a file that ends in ".iso" in your downloads folder.
  • The "Select start-up disk" window should pop up. Hit the little folder icon next to the drop-down box to bring up a file chooser. Then pick the ISO image you just downloaded. If you want to try the 64-bit version of Ubuntu Desktop 18.04.4 LTS, you'll choose the "ubuntu-18.04.4-desktop-amd64.iso" file and click the "open" button. That should close the file chooser. Then click the "start" button.
  • A window saying something like "testUbuntu14 [Running] - Oracle VM VirtualBox" should pop up. It takes a minute or so for the Ubuntu LiveCD to boot up inside that window. Eventually it should show a big "Welcome" window with two big options: "Try Ubuntu" or "Install Ubuntu". We hit the "Install Ubuntu" option.
  • (By default, we'll be running in a tiny 800x600 pixel "virtual monitor" window for a while -- we'll fix the screen resolution later).

installing inside the virtual machine[edit]

The previous steps created .vdi file that acts like a fresh, empty hard drive. Now we're going to install Ubuntu on it, exactly the same we would on a physical machine with a physical fresh, empty hard drive.

  • We pick the "Install Ubuntu" option.
  • We choose keyboard layout, etc., hitting "Continue" a few times.
  • You are at the "Installation Type" window, still inside the "testUbuntu14 [Running] - Oracle VM VirtualBox" window, right? We accept the default "Erase disk and install Ubuntu" and hit the "Install Now" button. (There's also a "Encrypt" option here that does full-disk encryption.[2] (The "Encrypt my home folder" option[3] has apparently been removed,[4] in response to bug #1756840.[5]).
  • ... Hit the "Continue" button a few more times ...
  • After entering your user name and password and hitting "continue", Ubuntu will take many minutes install.
  • Write down that password on a sticky note. We'll need it later.
  • Eventually you see the "Installation Complete" message. Hit the "Restart Now" button.
  • Typically Ubuntu shows a few text logging messages as it shuts down.
  • If it appears to hang on that shutdown screen, at the top of the "testUbuntu18 [Running] - Oracle VM VirtualBox" window, hit the "close window" icon and choose "Power off the machine", OK. Then Open up the Oracle VM VirtualBox manager. The "testUbuntu18" VM currently has the "Powered Off" icon, right? Select the VM, and hit the green arrow "start" icon.
  • If you see the "Please remove the installation medium, then press ENTER:" message, go ahead and press ENTER -- VirtualBox should remove the (virtual) CD (actually a ".iso" file) automatically.
  • It may take Ubuntu a minute to boot up the first time from a cold start. (VirtualBox *should* have automatically ejected the ISO image, so you should *not* see the two big "Try Ubuntu" or "Install Ubuntu" options from the LiveCD ISO image).
  • When you see a bar with the username you typed in earlier, click it and type the password you wrote on the sticky note earlier.
  • Since this is the first time Ubuntu 18 has booted, you'll see the "What's new in Ubuntu". Check out the new features, click "Next" a few times, then "Done".
  • Typically the "Software Updater" window pops up saying "Updated software ... do you want to install it now?" You may as well click the "Install Now" button.
  • Hey, remember that password we wrote on a sticky note earlier? Type it in and hit the Authenticate button.
  • This may take a few minutes -- minimize the Updater window and continue with the following while it's downloading and installing updates.

So, are we finished installing?

return to the host operating system for further installation steps[edit]

Next we install the Guest Additions.

Please go to VirtualBox/Guest Additions/Ubuntu and follow the instructions there.


A few things you can do with this virtual machine[edit]

If your purpose for setting up this machine is to practice administering RAID arrays -- setting up a new RAID array, failing, operating while degraded, adding empty hard drives to the array, rebuilding, scrubbing, etc. -- in a safe sandboxed environment, you can add and remove additional virtual hard drive images at any time under Settings >> Storage.


You can easily move this virtual machine to some other computer -- even a computer running a completely different host operating system. (One exception: 64-bit Ubuntu will not run on 32-bit hardware. 32-bit Ubuntu, however, runs fine on both 64-bit Intel processors and 32-bit Intel processors.)

An operating system inside a virtual machine may see several hard drives. Typically they are all actually ".vdi" files stored on a single host hard drive. But some people tweak the VirtualBox settings so that the operating system can directly access (perhaps in read-only mode) physical drive(s), so the hard drive that guest operating system sees is, in fact, a physical hard drive.

Many people disable the "fading windows" effect and other pretty effects by installing "CompizConfig Settings Manager" and turning off "effects" and "Enhanced Zoom Desktop".

Many people install and use a "fast, lightweight" window manager such as GNOME Flashback (Metacity)[6] or XFCE,[7]

To try out Xubuntu (with XFCE), at the command line type "sudo apt-get install xubuntu-desktop gksu leafpad synaptic" (not including the quotes). Then press enter, type your password, then press enter again. It takes a few minutes for Ubuntu to download and install the Xubuntu stuff. Then log out of Ubuntu. At the login window, click the logo next to your user name, and pick "Xubuntu session".

Some people install zRam for better performance with limited RAM. This is a single command in Ubuntu 12.04 and newer: open a terminal window, and run[8]

   sudo apt-get install zram-config

Using ssh to access an Ubuntu virtual machine[edit]

Inside the virtual machine window, you can open a terminal window and ssh to some other server -- that's all installed by default.

Often people want to access a text terminal on an Ubuntu server from a Windows box -- that takes a few more steps:[9][10]

  • Make sure the openssh-server is installed:
    • Open the Ubuntu Software Center from the left sidebar, type "openssh-server" in the search sidebar, and click the install button.

OR

    • Open a terminal window from the left sidebar, and run the command
   sudo apt-get install openssh-server
  • Edit the config file
   sudo vim /etc/ssh/sshd_config
  • Find the line that says "PasswordAuthentication", and make sure it says
   PasswordAuthentication no

then save that file and exit.

  • restart the ssh server
   sudo /etc/init.d/ssh restart
  • Install PuTTY on the Windows box. (This works more-or-less the same as the "ssh" command installed by default in Ubuntu).
  • Get the IP address of the Ubuntu box: At the top of the virtual screen there's an icon that allegedly looks like an internet connection; pull it down and choose "Connection information".
  • Most likely the IP address will begin with "10." or "192.", a local address that is not usable outside the local network.
  • (FIXME: is this really the Right Thing to Do?) In the Oracle VM VirtualBox Manager, select the virtual machine, choose the big yellow gear "Settings", choose "Network" on the left side, and change the "Attached to:" from "NAT" to "Bridged Adapter", and hit OK.
  • Get the IP address of the Ubuntu box again: At the top of the virtual screen there's an icon that allegedly looks like an internet connection; pull it down and choose "Connection information". (This will almost certainly be a different IP address than the one you saw before enabling "Bridged Adapter").
  • Run PuTTY on the Windows box, and type the "Bridged Adapter" IP address in the "Host Name or IP address" box, and hit Enter.

You should be able to log into the virtual machine now.

USB[edit]

You may want to access some physical USB device from inside the virtual machine. (For example, you may want to run the Android SDK sandboxed inside a virtual machine, and then give it access to upload to a physical mobile phone).


Further reading[edit]



Setting up a Virtual Machine/Mac OS X

License violations[edit]

According to the macOS and OS X software license agreement[11], macOS should only be installed on Apple Mac devices. Neither the editors of this book nor Wikibooks have any liability over the installation of macOS or OS X guests on VirtualBox or any other violations of the software license.

This is against the EULA of Apple, doing this article IS considered piracy.

Installation script[edit]

The following installation script:

  • ...is free and open-source
  • ...requires only VirtualBox with its Extension Pack and dependencies that can be easily installed in a single command with most open-source package managers
  • ...downloads macOS Catalina, Mojave and High Sierra directly from Apple's servers
  • ...installs macOS without modifying the original Apple binaries and without third-party bootloaders
  • ...creates a VM that is compatible with OpenCore and can be exported (with manual modifications) to KVM/QEMU for near-native performance
  • ...runs on Linux, Windows (WSL, Cygwin), and macOS

https://github.com/myspaghetti/macos-guest-virtualbox - Push-button installer of macOS on VirtualBox

Manual installation[edit]

The manual installation requires access to the Mac App Store through an existing installation of macOS.

Create ISO Installation Media[edit]

  1. Download the macOS Installer file from the App Store[12] (OS X El Capitan and Sierra is downloadable from Apple's website).
  2. When download finishes, find the app, right-click and select "Show Package Contents".
  3. Inside the sub-folder Contents/SharedSupport you will find a InstallESD.dmg file.
  4. Open "Disk Utility"
  5. Choose Images > Convert
  6. In the window, choose the InstallESD.dmg to convert and the disk type to be "DVD/CD-R master for export". Also choose the name for installer disk and the final destination. Then click "Convert".
  7. After conversion completes, you will see a .cdr file in your destination folder.
  8. Open "Terminal"
  9. Enter hdiutil convert /Your/Path/To/YourCdrFile.cdr -format UDTO -o /Your/Path/To/macOSInstaller.iso
  10. Check destination folder. This is your file for installation in VirtualBox. There should be a .iso file extension.

Installation in VirtualBox[edit]

  1. Open VirtualBox. Click "new"
  2. Type the name for virtual machine and Mac OS X for type. Choose your version (if you have Mojave or Catalina, choose Mac OS X (64 bit)).
  3. Select memory size.
  4. Select "Create Virtual Disk Now"
  5. Choose VDI for format.
  6. Select storage name and size. The size should be at least 32 GB.
  7. Go to "Settings"
  8. Go to "Storage" Tab
  9. In the SATA controller, click "Add Optical Disk".
  10. Insert the .iso file.
  11. Go to "Display" tab.
  12. Set video memory to maximum value.
  13. Quit "Settings"
  14. Boot by clicking "Start".
  15. When it boots, you will see some data being displayed.
  16. This part needs clarification - UEFI Interactive Shell loads, but nothing happens. If you use the command "exit" you can shift to the EFI menu, but changing the settings doesn't seem to affect the progress of the UEFI Interactive Shell, which stops at the Shell> prompt.
  17. After a while, you will need to choose the language for installation. Choose your own language.
  18. Then you will be asked where to install macOS.
  19. On the upper-left corner, you will see a "Utilities" button. Click it and select "Disk Utility".
  20. You will see a window with different storages on the left. Choose "VBOX HARDDISK Media". Note: You may have to select View/View All Devices
  21. Erase the Storage by clicking the "Erase" button on the top.
  22. You will be prompted to enter the name for the storage. Enter your desired name and continue.
  23. Wait for the process to complete. Then quit Disk Utility.
  24. You will find a new storage media, which is like a hard disk. Choose that storage for the installation of OS X to install.
  25. After installation completes, the virtual machine will automatically shut down. Go to "Settings".
  26. Go to the "Storage" section to eject the .iso file.
  27. Boot virtual machine again.
  28. Choose system language.
  29. Choose allow location or not.
  30. You will be asked to enter your Apple ID. Even if you have an Apple ID, do not enter now.
  31. Accept EULA of macOS.
  32. Restore Time Machine Backups (if you have)
  33. You will see the main page of OS X, open App Store.
  34. Enter your Apple ID and sign in...


There should be 2 scenarios...

  • Scenario 1: You will sign in within a short time. Congratulations! You have done it!
  • Scenario 2: It took ages. Stop signing in and check the references below. [12]

References[edit]



Setting up a Virtual Machine/macOS Mojave

Installation script[edit]

The following installation script:

  • ...is free and open-source
  • ...requires only VirtualBox with its Extension Pack and dependencies that can be easily installed in a single command with most open-source package managers
  • ...downloads macOS Catalina, Mojave and High Sierra directly from Apple's servers
  • ...installs macOS without modifying the original Apple binaries and without third-party bootloaders
  • ...creates a VM that is compatible with OpenCore and can be exported (with manual modifications) to KVM/QEMU for near-native performance
  • ...runs on Linux, Windows (WSL, Cygwin), and macOS

https://github.com/myspaghetti/macos-guest-virtualbox - Push-button installer of macOS on VirtualBox

See also[edit]



Guest Additions

The VirtualBox Guest Additions are a plugin which improves the interoperability between the host and the hosted systems.



Guest Additions/Windows

Here we install the Guest Additions[1].

  1. Go to the host operating system. At the top of the VM window, choose Devices >> "Insert Guest Additions CD image...". Then, VirtualBox simulates inserting a CD into the simulated optical drive of the VM.
  2. If you need to eject this, you can either restart the VM or click on Devices >> optical drives >> eject.

^

If you didn't add a Windows shared folder into the "configuration" menu of the VirtualBox graphical interface[2], you can do it in Command Prompt with: VBoxManage sharedfolder add "VMName" --name "SharedName" --hostpath "C:\Users\Public\Documents\SharedFolderPath".

Linux guest[edit]

The Guest Additions CD should be read from the guest OS like this[3]:

  1. sudo mount /dev/cdrom /media/cdrom
  2. cd /media/cdrom
  3. sudo ./VBoxLinuxAdditions.run

Then, just mount the Windows folder from Linux[4]: mkdir ~/vboxshare sudo mount -t vboxsf SharedName ~/vboxshare

That's it, you can browse your Windows files: ls ~/vboxshare

References[edit]



Guest Additions/Ubuntu

Here we install the Guest Additions on an Ubuntu guest system running inside Virtualbox.[1]

This chapter assumes you already have Ubuntu installed in a VirtualBox virtual machine, perhaps using the process described in VirtualBox/Setting up a Virtual Machine/Ubuntu.

(This was tested on Ubuntu Desktop 18.04 LTS as a guest in VirtualBox-6.0.18 on a Windows 10 host. Other versions and other hosts should work similarly.)

  1. Go back to the host operating system. At the top of the "testUbuntu18 [Running] - Oracle VM VirtualBox" window, choose Devices >> "Insert Guest Additions CD image..."
  2. (VirtualBox simulates inserting a CD into the simulated optical drive of the VM, and Ubuntu auto-mounts that CD under "/media/a/").[2]
    1. At this point, with a fresh Ubuntu 18.04 LTS install, it typically says "This system is currently not set up to build kernel modules. Please install the gcc make perl packages from your distribution." If that happens,
      1. Inside the Ubuntu 18 VM, open up a terminal with Ctrl+Alt+T . Inside that terminal run:
   sudo apt update
   sudo apt install build-essential
   reboot

(What is build-essential? see https://superuser.com/questions/151557/what-are-build-essential-build-dep )

        1. (Earlier advice also recommended installing "dkms", but apparently that is no longer necessary).
        2. (Earlier advice also recommended installing gcc, make, and perl, but apparently they are already included with build-essential).
      1. When the VM starts up again, right-click the CD image on the desktop (if you don't see it, look in the left bar, at the bottom), and Eject.
      2. Install the Guest Additions again from the beginning.
  1. When Ubuntu gives the "VBox... Would you like to run it?..." pop-up window, hit "run".
  2. Hey, remember that password we wrote on a sticky note earlier? Type it in and hit the Authenticate button.
  3. Ubuntu pops up a new terminal window and takes a minute to install and start up "VirtualBox Guest Additions".
  4. When there are no errors and the last line of that terminal window says "Press Return to close this window...", click inside that window and press Return.
  5. Go back to the host operating system. At the top of the "testUbuntu18 [Running] - Oracle VM VirtualBox" window, most people find it convenient to enable Devices >> Shared Clipboard >> Bidirectional.
  6. Shut down the virtual machine from the tiny triangle icon in the upper right corner, the power icon, "Power Off".
  7. Open up the Oracle VM VirtualBox manager. The "testUbuntu18" VM currently has the "Powered Off" icon, right? Select the VM, and hit the green arrow "start" icon.
  8. (Now when you look under "/media/a/", the "Guest Additions CD image" is still there -- do I need to do something to "take it out of the (virtual) drive"? If so, how?)
  9. (optional) To automagically resize the size of the virtual monitor to fill the "testUbuntu18 [Running] - Oracle VM VirtualBox" window whenever you stretch or shrink that window,
    1. At the top of the "testUbuntu18 [Running] - Oracle VM VirtualBox" window, choose View >> Auto-resize Guest Display.
    2. When you installed the Guest Additions (as described above), that option should have been enabled. There is apparently two separate bugs that can keep it greyed out even after installing the Guest Additions and rebooting:[3][4]
    3. Some people suggest editing a "/etc/X11/xorg.conf" file, but that file apparently no longer exists in Ubuntu14.
    4. Some people suggest using apt-get to (re)install guest additions, uninstalling that version, and then re-install the guest additions again from the VirtualBox ISO:[5]
      1. Inside the virtual machine, open a terminal window and run "sudo apt-get install build-essential dkms virtualbox-guest-additions-iso". Hit "y" to continue.
      2. Next, uninstall the guest additions: "sudo apt-get remove --purge virtualbox-guest-additions-iso". (We only installed it to pick up a bunch of dependencies; it's probably the wrong version for whatever version of VirtualBox you have running on your host).
      3. At the top of the "testUbuntu14 [Running] - Oracle VM VirtualBox" window, choose Devices >> "Insert Guest Additions CD image..." and re-install it, as described above.
      4. Reboot
      5. wait a minute until the GUI desktop comes up
      6. At the top of the "testUbuntu18 [Running] - Oracle VM VirtualBox" window, choose View >> Auto-resize Guest Display.

References[edit]



Guest Additions/Mac OS X

Sorry, no Guest Additions are provided for Mac OS X.