Site icon UnixArena

Virtual Machine on Apple Mac chip M1/M2 – Fusion/Vagrant

Mac M1 VMware Vagrant

Mac M1 VMware Vagrant

All new Macbooks are shipping with M1 / M2 chips which are based on ARM (Advanced RISC Machines). Apple is no longer releasing the x86-based MacBooks to eliminate the intel dependencies for any advancement. It also brings a lot of challenges for people who are very familiar with intel macbooks which support most of the software libraries in the market. One of the major challenges that I have faced to install guest operating systems / virtual machines on the new MacBook.

Hosted Hypervisor: (Type2)

Virtual box is the widely used hosted hypervisor to install virtual machines. But in M1/M2 Macbooks, you can’t install VirtualBox since it supports only x86 architecture. VMware Fusion is another paid software for x86-based Macbook users. Parallels is hosted hypervisor(type-2) available for Mac M1/M2 variant. Unfortunately, it’s a paid software, it might suit for enterprises.

Free hosted hypervisor for Mac M1/M2:

VMware has released a VMware fusion tech preview for Mac M1 models. You can freely download and use it for personal use. Since its initial version and released for tech preview, it had some bugs. As silicon chips support only ARM architecture-supported operating systems, you will be having very limited options unlike x86. Use the wizard to create a virtual machine. You need a 64-bit ARM ISO image to install the guest operating system. The x86 virtual machines are not supported under ARM architecture unless you use emulate like Qemu (Resource intensive translation).

https://customerconnect.vmware.com/downloads/get-download?downloadGroup=FUS-PUBTP-22H2

Mac VMware Fusion – ARM

How am I using VMware Fusion Tech Preview?

I am not directly spinning up the virtual machine using VMware fusion. I am using Vagrant software to manage the guest operating system. Vagrant is an opensource software for building and maintaining portable virtualized environments for VirtualBox, KVM, Hyper-V, Docker, AWS, and VMware. Vagrant also provides prebuilt boxes to use.

1. Install vagrant software on your Macbook M1/M2.

$ brew install vagrant

2. Validate the installation.

uxpro-$vagrant --version
Vagrant 2.2.19
uxpro-$

3. Install the VMware provider plugin which will be responsible to communicate with VMware Fusion.

uxpro-$vagrant plugin install vagrant-vmware-desktop

4. List the installed VMware plugin.

uxpro-$vagrant plugin list                          
==> vagrant: A new version of Vagrant is available: 2.3.0 (installed version: 2.2.19)!
==> vagrant: To upgrade visit: https://www.vagrantup.com/downloads.html

vagrant-share (2.0.0, global)
vagrant-vmware-desktop (3.0.1, global)
uxpro-$

5. Verify the vagrant VMware utility service.

uxpro-$sudo launchctl list |grep vagrant
Password:
-	0	com.vagrant.vagrant-vmware-utility-stopper
383	-9	com.vagrant.vagrant-vmware-utility
uxpro-$

6. Identify the right prebuilt OS image from the vagrant.

Ubuntu ARM vagrant box

7. Once you select the right image, you can see the commands to create the vagrant file. You can click on the vagrant file to copy the file contents to start the virtual machine.

vagrant init – Mac ARM

8. Execute the vagrant init command to create the vagrant file. This file creates all the available options to customize the VM.

uxpro-$rm Vagrantfile 
uxpro-$vagrant init bytesguy/ubuntu-server-21.10-arm64 --box-version 1.0.0 
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
uxpro-$ls -lrt
total 8
-rw-r--r--  1 lingeswaran  staff  3074 Sep 15 22:59 Vagrantfile
uxpro-$

9. Here is the file content. Most of the lines will be commented out and can be enabled for custom configuration.

uxpro-$cat Vagrantfile |grep -v "#"  | grep -v -e '^$'
Vagrant.configure("2") do |config|
  config.vm.box = "bytesguy/ubuntu-server-21.10-arm64"
  config.vm.box_version = "1.0.0"
end
uxpro-$

10. Let’s bring up the guest ubuntu VM.

uxpro-$vagrant up
Bringing machine 'default' up with 'vmware_desktop' provider...
==> default: Box 'bytesguy/ubuntu-server-21.10-arm64' could not be found. Attempting to find and install...
    default: Box Provider: vmware_desktop, vmware_fusion, vmware_workstation
    default: Box Version: 1.0.0
==> default: Loading metadata for box 'bytesguy/ubuntu-server-21.10-arm64'
    default: URL: https://vagrantcloud.com/bytesguy/ubuntu-server-21.10-arm64
==> default: Adding box 'bytesguy/ubuntu-server-21.10-arm64' (v1.0.0) for provider: vmware_fusion
    default: Downloading: https://vagrantcloud.com/bytesguy/boxes/ubuntu-server-21.10-arm64/versions/1.0.0/providers/vmware_fusion.box
    default: Calculating and comparing box checksum...
==> default: Successfully added box 'bytesguy/ubuntu-server-21.10-arm64' (v1.0.0) for 'vmware_fusion'!
==> default: Cloning VMware VM: 'bytesguy/ubuntu-server-21.10-arm64'. This can take some time...
==> default: Checking if box 'bytesguy/ubuntu-server-21.10-arm64' version '1.0.0' is up to date...
==> default: Verifying vmnet devices are healthy...
==> default: Preparing network adapters...
WARNING: The VMX file for this box contains a setting that is automatically overwritten by Vagrant
WARNING: when started. Vagrant will stop overwriting this setting in an upcoming release which may
WARNING: prevent proper networking setup. Below is the detected VMX setting:
WARNING: 
WARNING:   ethernet0.pcislotnumber = "33"
WARNING: 
WARNING: If networking fails to properly configure, it may require this VMX setting. It can be manually
WARNING: applied via the Vagrantfile:
WARNING: 
WARNING:   Vagrant.configure(2) do |config|
WARNING:     config.vm.provider :vmware_desktop do |vmware|
WARNING:       vmware.vmx["ethernet0.pcislotnumber"] = "33"
WARNING:     end
WARNING:   end
WARNING: 
WARNING: For more information: https://www.vagrantup.com/docs/vmware/boxes.html#vmx-allowlisting
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Starting the VMware VM...
==> default: Waiting for the VM to receive an address...
==> default: Forwarding ports...
    default: -- 22 => 2200
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2200
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: 
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default: 
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Configuring network adapters within the VM...
==> default: Waiting for HGFS to become available...
==> default: Enabling and configuring shared folders...
    default: -- /Users/lingeswaran/unixarena: /vagrant
uxpro-$

11. Once the VM is up, you can log in using vagrant ssh.

uxpro-$vagrant ssh
Welcome to Ubuntu 21.10 (GNU/Linux 5.13.0-23-generic aarch64)

  System information as of Thu Sep 15 05:41:57 PM UTC 2022

  System load:  0.0                Processes:               195
  Usage of /:   23.5% of 19.52GB   Users logged in:         0
  Memory usage: 11%                IPv4 address for enp1s1: 192.168.22.130
  Swap usage:   0%


37 updates can be applied immediately.
To see these additional updates run: apt list --upgradable


New release '22.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


vagrant@ubuntu:~$ 

12. If you would like to access using ssh, create a new user and set the password.

vagrant@ubuntu:~$ sudo useradd lingesh
vagrant@ubuntu:~$ sudo passwd lingesh
New password: 
Retype new password: 
passwd: password updated successfully
vagrant@ubuntu:~$

13. Once you know the username and password, Login back in using ssh.

uxpro-$ssh lingesh@192.168.22.130 
The authenticity of host '192.168.22.130 (192.168.22.130)' can't be established.
ED25519 key fingerprint is SHA256:IWUrFbvcHgMkbQP+N3BXow4HaarBB33q5IiowQM2U7M.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.22.130' (ED25519) to the list of known hosts.
lingesh@192.168.22.130's password: 
Welcome to Ubuntu 21.10 (GNU/Linux 5.13.0-23-generic aarch64)

  System information as of Thu Sep 15 05:43:46 PM UTC 2022

  System load:  0.0                Processes:               198
  Usage of /:   23.6% of 19.52GB   Users logged in:         0
  Memory usage: 11%                IPv4 address for enp1s1: 192.168.22.130
  Swap usage:   0%

New release '22.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
$ 

14. You can use suspend command to stop the VM.

uxpro-$vagrant suspend
==> default: Suspending the VMware VM...
uxpro-$
uxpro-$vagrant status    
Current machine states:

default                   suspended (vmware_desktop)

The VM is suspended. To resume this VM, run `vagrant up`.
uxpro-$

Hope this article provides the way to install and use the free hypervisor on Apple Macbook with chip M1/M2. Vagrant is a bonus option to quickly bring up the VMs using pre-built images.

Exit mobile version