Kali Linux OS Virtual Machine on a Mac OS host using VirtualBox

Posted by admin at January 4, 2021

In this article, I will be documenting the steps I took when setting up the Linux Ubuntu visual machine on my Mac host.

I got a new mac computer recently and I am setting up my work environment on it. One of the tasks on my to-do list is the virtualize several versions of Linux and Windows using a simple and free hypervisor. VirtualBox presents the necessary tools without lightening the wallet to acquire it or racking the brain to set it up! Below are the host and guest machine specifications:

  1. Specifications
  2. Setting Up
  3. Booting Up
  4. Resolving Screen Resolution
  5. Guest to Host Functionalities
  6. Testing Guest Functionalities
  7. Conclusion

A. SPECIFICATIONS:

Mac Host specifications:
macOS High Sierra (64 bits)
Processor: Intel Core i7, 2.6 GHz
HDD 500GB
Memory 16GB

Ubuntu Guest specifications:
Ubuntu 20.10 (64 bits)
HDD 10GB
Memory 4GB

B. SETTING UP:

  1. First download the VirtualBox app from the VirtualBox website https://www.virtualbox.org/wiki/Downloads. Simply locate and click on the link for the appropriate host machine (in my case, the macOS is the host).

  2. Next queue up another download for the Ubuntu image file. This is an already installed virtual environment, prepared and packaged, ready for download and use in virtual machines. A very good repository of these VMs is OXBoxes (https://www.osboxes.org). Simply navigate and find the version of the OS you wish to host on the VirtualBox. I choose Ubuntu version 20.10 https://www.osboxes.org/kali-linux/

  3. Wait for the downloads to complete.

  4. Next install VirtualBox, locate and double click on the Virtual Box package. Follow the instructions on the dialog box to install the application.
  5. Navigate to the downloads folder and locate the VM image downloaded from OSBoxes. The file should be a .7z archive.

  6. Simply extract the contents of this archive and save in the downloads folder. For the Mac installation, I used “RAR Extractor – The Unarchiver” from the App Store. You can also use the macOS default Unarchiver tool as well. When extraction is finished a folder containing a file with a .VDI extension should be present in the extraction location.

  7. Navigate to your Apps folder. Open VirtualBox.

  8. Click on the New Icon at the top panel of the VirtualBox window.

  9. Complete the form provided in the resulting dialog box:
    Name: U20 Test Desk
    Type: Linux
    Version: Ubuntu (64 bit)
    Click on Continue

  10. Select the Memory size: I chose 4096MB. Click on Continue

  11. Next specify the hard disk: Because we have downloaded a VM image from OXBoxes, we select the “Use an existing virtual hard disk drive” option

  12. Click on the folder icon, which should open yet another dialog box showing the list of VM boxes available to VirtualBox. On a fresh installation, this list should be empty. Click on the Add icon at the top and navigate to the folder where the .VDI was extracted to. Double click on the image to add it to the list.

  13. Next select the new Image on the list and click Choose.

  14. Next click Create.

  15. You new guest machine should be available in the VirtualBox list.

B. BOOT UP THE VIRTUAL MACHINE:

  1. Select the guest machine and click on the Run icon or simply double click the machine on the list.

  2. Wait for the OS to completely boot. Notice that the resolution of the screen. During my installation, I had a very tiny fraction of the screen occupied. This problem will be resolved later.

  3. OSBoxes machines have a default account for logging in. Both the name and password of the account is osboxes.org, so when prompted, simply click on the name and enter the password: osboxes.org.

  4. Next, open Terminal, Activities > Terminal.

  5. Update and upgrade the OS with the following commands:
    ~$ sudo apt update
      ~$ sudo apt upgrade

  6. Next install the build essentials
    ~$ sudo apt install build-essential dkms linux-headers-$(uname -r)

  7. Next install the Guest Additions tools, this are the drivers required by VirtualBox to optimize the use of functionality of the virtual machine. Go to Devices > Insert Guest Additions CD. A pop-up should appear on the virtual machine screen, prompting you that the contents of the disk are set to auto run when entered into the drive.

  8. Click on Run to commence installation

  9. Wait for the installation to complete and when promptly hit Enter and restart the virtual machine.
    ~$ sudo reboot

C. SCREEN RESOLUTION

  1. If everything goes properly, the screen resolution should be resolved. Now when you hit Cmd + F for full screen the virtual machine screen should sufficiently fill the screen while maintaining aspect ratio of the contents.

  2. Now, rebooting the system presents a problem for the resolution during my installation. After a reboot, the screen resolution returned to 800 x 600 (4:3) even after correcting it to 2880 x 1800 (16:10) several times.

  3. To correct this, turn of the Virtual machine. Machine > ACPI Shutdown.

  4. Next, Go to Settings and click on the Display tab.

  5. On the Graphics Controller: Select VboxSVGA as the controller. This might through a warning “Invalid setting detected” Ignore this warning and click OK.

  6. Restart the virtual machine and verify that the correct resolution is achieved without additional settings.

  7. Another problem with the resolution, at 2880 x 1800 (16:10) on my 15.1′ screen, the fonts and icons become head-achingly small. To correct this problem, I set the Scale to 200% which increases the sizes to a more tolerable quantity. However for some reason, this setting is reverted after a reboot or every time I switch from full screen to window (Ctrl + F or Ctrl + C).

D. HOST TO GUEST FUNCTIONALITIES

Next, activate certain shared functionalities between host and the guest. These include: Drag-n-Drop, Clipboard, USB and Shared Folders

  1. Shared Folder:
    • First designate a folder to be used as the shared folder between the host and the guest. I created a folder in Documents called VMShared.

    • Next ensure that the Virtual machine is shut down

    • Go to Devices > Shared Folders > Shared Folders settings. This will load the settings dialog box with the Shared Folders tab selected.

    • Click on the plus folder icon.

    • Fill out the form:
      • Folder Path: Select “Other” and navigate to the designated shared folder /Users//Documents/VMShared
      • Folder Name: This should be automatically set to “VMShared”
      • Check “Auto mount” to ensure that the folder is automatically available every time the guest loads.
      • Leave the other setting as they are.
      • Click OK
    • Click OK to close the Settings

    • Next boot up the virtual machine and run the following command on the terminal:
      ~$ sudo apt install virtualbox-guest-utils
    • When this is finished, open Files and look at the left panel of the Window, you should be able to see a drive names “sf_” (in my case “sf_VMSHared”)

    • Trying to open this folder may result in an error message
      "This location cannot be displayed. 
      You do not have permission necessary to view the contents of VMShared"
    • We need to create permission for the user to access the folder. This will require adding the user to a user group permitted to use shared folder. This user group is called “vboxsf”.
      ~$ sudo adduser [username] vboxsf
        ~$ sudo adduser osboxes vboxsf
      
    • Next restart the system
      ~$ sudo reboot
    • On reboot, you should be able to access the shared folder.
  2. Next activate the Shared Clipboard:
    • Go to Devices > Shared Clipboard > Bidirectional to activate the clipboard functionality. This should allow items to be copy-and-paste from guest to host and vice-versa.

  3. Then activate the Drag and Drop features:
    • Go to Devices > Drag and Drop > Bidirectional to activate the drag and drop functionality between guest to host.

E. TEST GUEST FUNCTIONALITIES

Test the Network connectivity:

  1. OSBoxes VMs are provided with a virtual wired connection link to the host OS. Simply check the connectivity icon at the top right corner of the screen, you should see the network sign.

  2. If not click on the down arrow button to view the menu.

  3. On the menu, You should see Wired Connection as the second item on the list.

  4. To view the connection details in the Terminal, enter the command:
    ~$ ip a
  5. You should see the following:
    osboxes@osboxes:~$ ip a
    1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    $(inet 127.0.0.1/8) scope host lo
    valid_lft forever preferred_lft forever
    $(inet6 ::1/128) scope host
    valid_lft forever preferred_lft forever
    2: enp0s3: mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:72:c0:89 brd ff:ff:ff:ff:ff:ff
    $(inet 10.0.2.15/24) brd 10.0.2.255 scope global dynamic noprefixroute enp0s3
    valid_lft 81274sec preferred_lft 81274sec
    $(inet6 fe80::8dd7:b3ee:76e9:a3b5/64) scope link noprefixroute
    valid_lft forever preferred_lft forever
  6. The highlighted text are of interest. The first two items provide details about the localhost or the loopback (lo), while last two provide details about the ethernet. If the second item contains valid addresses for IPv4: inet (N.N.N.N/port) and IPv6: inet6, then we can connect to the internet.

  7. To check internet connectivity, open Firefox and try to open a webpage.

Test the sound:

  1. Simply play a system sound or video.

  2. First ensure that the volume meters are up on both the guest and the host machines.

  3. To test sound using system settings, Open the Settings window.

  4. Click on Sound, scroll down to Output.

  5. Locate Output Device, click on Test.

  6. A dialog box containing all available speakers will be displayed.

  7. Click on each speaker to test the sound.

CONCLUSION:

So far I have listed all the steps I took to setting up an Ubuntu guest virtual machine on my Mac Book Pro using the VirtualBox hypervisor. This article is meant is serve as log to help me remember the steps I took and will be updated if there are any changes in the future.

   0 likes

Suggested Read