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).

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

Download[edit]

Just recover the 101 MB .exe from the official site.

Installation[edit]

Simply double-click and let the installer adds the Oracle VM VirtualBox shortcut to launch it further.



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.

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]



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]

  1. Get a copy of Windows OS from Microsoft Official Website.
  2. Open the .exe file.
  3. Select the Installation Media Type. Choose "Create a bootable disk image".
  4. Use a blank USB Drive Because all the files on the Drive will be deleted.
  5. Create file destination.
  6. Wait for a while. When the creation of installation media completes, you will be redirected to the file destination. You should see a .iso file in that folder.

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.

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 the 32-bit version of Desktop Ubuntu 14.04.1 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 "testUbuntu14")
  • 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 (32 bit). .
  • Hit the "Continue" or "Create" button a few times (default 512 MB RAM, 8 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 ("testUbuntu14") 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".
  • 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 32-bit version of Desktop Ubuntu 14.04.1 LTS, you'll choose the "ubuntu-14.04.1-desktop-i386.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 and take a minute or so to boot up. 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 640x480 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, and 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", make sure everything is checked on the "Preparing to install Ubuntu" screen, then hit the "Continue" button.
  • 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,[1] and a "Encrypt my home folder" option[2] a few steps later).
  • ... Continue ...
  • 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 "All processes ended within 2 seconds" message, with a few more obscure messages. If it appears to hang on that screen, at the top of the "testUbuntu14 [Running] - Oracle VM VirtualBox" window, hit the "close window" icon and choose "Power off the machine", OK.
  • Open up the Oracle VM VirtualBox manager. The "testUbuntu1" VM currently has the "Powered Off" icon, right? Select the VM, and hit the green arrow "start" icon.
  • 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'll see a normal Ubuntu desktop with the default Ubuntu background, menu bars, etc.
  • This would be a good time to hit the gear icon on the top right corner, select "About this computer", and then in the "Details" window hit the "Install Updates" button.
    • (For Ubuntu 12 and earlier versions: This would be a good time to hit the "Software Updater" icon on the left side (not to be confused with the "Ubuntu Software Center"), and install the latest updates.)
  • 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.[3]

  • Go back to the host operating system. At the top of the "testUbuntu14 [Running] - Oracle VM VirtualBox" window, choose Devices >> "Insert Guest Additions CD image..."
  • (VirtualBox simulates inserting a CD into the simulated optical drive, and Ubuntu auto-mounts that CD under "/media/a/").[4]
  • When Ubuntu gives the "VBOXADDITIONS... automatically started. Would you like to run it?..." pop-up window, hit "run".
  • Hey, remember that password we wrote on a sticky note earlier? Type it in and hit the Authenticate button.
  • Ubuntu pops up a new terminal window and takes a minute to install and start up "VirtualBox Guest Additions". When the last line of that terminal window says "Press Return to close this window...", click inside that window and press Return.
  • Go back to the host operating system. At the top of the "testUbuntu14 [Running] - Oracle VM VirtualBox" window, most people find it convenient to enable Devices >> Shared Clipboard >> Bidirectional.
  • Shut down the virtual machine from the "gear" icon in the upper right corner, "Shut down..." >> Shut Down.
  • Open up the Oracle VM VirtualBox manager. The "testUbuntu1" VM currently has the "Powered Off" icon, right? Select the VM, and hit the green arrow "start" icon.
  • (The next time you restart after installing the guest additions, the "virtual monitor" window should now be 800x600 pixels).
  • (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?)
  • (optional) To automagically resize the size of the virtual monitor to fill the "testUbuntu14 [Running] - Oracle VM VirtualBox" window whenever you stretch or shrink that window,
    • At the top of the "testUbuntu14 [Running] - Oracle VM VirtualBox" window, choose View >> Auto-resize Guest Display.
    • 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:[5][6]
    • Some people suggest editing a "/etc/X11/xorg.conf" file, but that file apparently no longer exists in Ubuntu14.
    • 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:[7]
      • 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.
      • 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).
      • 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.
      • Reboot
      • wait a minute until the GUI desktop comes up
      • At the top of the "testUbuntu14 [Running] - Oracle VM VirtualBox" window, choose View >> Auto-resize Guest Display.


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)[8] or XFCE,[9]

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[10]

   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:[11][12]

  • 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.


Further reading[edit]



Setting up a Virtual Machine/Mac OS X

License violations[edit]

According to the macOS and OS X software license agreement[13], 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:

  • Doesn't require a ready-made bootable installation ISO
  • Downloads macOS Catalina, Mojave and High Sierra directly from Apple's servers.
  • Runs on Linux and Windows (WSL, Cygwin)
  • Uses only open-source software, no custom bootloader, and original Apple files directly from Apple
  • Has easily-installed dependencies: VirtualBox>6.0 with Extension Pack, bash>4, coreutils, unzip, wget, dmg2img

https://github.com/img2tab/macos-guest-virtualbox - Semi-automatic 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[14] (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 "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. [14]

References[edit]



Setting up a Virtual Machine/macOS Mojave

The following installation script:

  • Doesn't require a ready-made bootable installation ISO
  • Downloads macOS Catalina, Mojave, and High Sierra directly from the Apple Store servers
  • Runs on Linux and Windows (WSL, Cygwin)
  • Uses only open-source software, no custom bootloader, and original Apple files directly from Apple
  • Has easily-installed dependencies: VirtualBox>6.0 with Extension Pack, bash>4, coreutils, unzip, wget, dmg2img

https://github.com/img2tab/macos-guest-virtualbox - Semi-automatic 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.[1]

  1. Go back to the host operating system. At the top of the "testUbuntu14 [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]
  3. When Ubuntu gives the "VBOXADDITIONS... automatically started. Would you like to run it?..." pop-up window, hit "run".
  4. Hey, remember that password we wrote on a sticky note earlier? Type it in and hit the Authenticate button.
  5. Ubuntu pops up a new terminal window and takes a minute to install and start up "VirtualBox Guest Additions". When the last line of that terminal window says "Press Return to close this window...", click inside that window and press Return.
  6. Go back to the host operating system. At the top of the "testUbuntu14 [Running] - Oracle VM VirtualBox" window, most people find it convenient to enable Devices >> Shared Clipboard >> Bidirectional.
  7. Shut down the virtual machine from the "gear" icon in the upper right corner, "Shut down..." >> Shut Down.
  8. Open up the Oracle VM VirtualBox manager. The "testUbuntu1" VM currently has the "Powered Off" icon, right? Select the VM, and hit the green arrow "start" icon.
  9. (The next time you restart after installing the guest additions, the "virtual monitor" window should now be 800x600 pixels).
  10. (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?)
  11. (optional) To automagically resize the size of the virtual monitor to fill the "testUbuntu14 [Running] - Oracle VM VirtualBox" window whenever you stretch or shrink that window,
    1. At the top of the "testUbuntu14 [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 "testUbuntu14 [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.