Showing posts with label m1. Show all posts
Showing posts with label m1. Show all posts

Friday, November 4, 2022

using UMT to create virtual machines using Apple Virtualization on M1 macbook

 

I'm documenting this mostly for myself so that I the steps to redo if I forget.

Background:

Setup up VM using Apple Virtualization (as opposed to QEMU) using UMT https://mac.getutm.app/


We need  ARM64 versions of:

1) linux kernel

2) ramdisk

3) linux image

I use Ubuntu and the cloud images has all the items ready for use.

Linux Kernel file

in https://cloud-images.ubuntu.com/jammy/current/unpacked/

Look for "jammy-server-cloudimg-arm64-vmlinuz-generic" and download

rename the file to gz and gunzip the file.

```mv jammy-server-cloudimg-arm64-vmlinuz-generic jammy-server-cloudimg-arm64-vmlinuz-generic.gz && gunzip jammy-server-cloudimg-arm64-vmlinuz-generic.gz```

Ramdisk

Look for " jammy-server-cloudimg-arm64-initrd-generic" and download

Virtual Disk Image

Download image file from https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-arm64.tar.gz   and untar the file






Optional: resize img file  

(This assumes you already have qemu installed via brew)

If you want to add additional 80G to the disk space for example.

```/opt/homebrew/bin/qemu-img resize -f raw jammy-server-cloudimg-arm64.img +80G```


Obtain iso file for cloud init



My personal setup

system login credentials are baked into user-data.yaml

which builds an iso file called 'seed.iso'. which will be used for below instuctions.


alternatively for a basic one see this version

additional reference : https://github.com/frederickding/Cloud-Init-ISO


Finally, set up VM

Launch UTM

1) Add VM
2) Select Virtualize


3) Select Linux




4) select Apple Virtualization
5) Uncompressed Linux kernel select "jammy-server-cloudimg-arm64-vmlinuz-generic"
6) Linux ramdisk select "jammy-server-cloudimg-arm64-initrd-generic"
7) Linux Root FS image select "jammy-server-cloudimg-arm64.img"
8) boot iso select "seed.iso" ( for user and package provisioning)
9) boot argument enter :    console=hvc0 root=/dev/vdb (depends on the order of your storage devices, in this instruction /dev/vda is the iso file, and dev/vdb is the disk)
10) continue and set the rest of the VM resources or leave it default, 












11) save, then start VM

12) you will see a prompt, shortly, the cloud init scripts will update, provision the user and my cloud init will restart system 







13) log in with configured user  and verify diskspace ```df -h```
as with the hyper-v version, I don't seem to require to resize2fs