Showing posts with label linux. Show all posts
Showing posts with label linux. 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













Saturday, January 2, 2010

Android app development on Netbooks

I like the size of netbooks, their small size means that you can bring them around easily. What I didn't anticipate was how underpowered the processor really was.

I've been doing development work on the Android platform and I wanted to use the netbook so that I can bring my code around and work on it when time permits.

Problem
Eclipse runs fine on the netbook but the emulator that comes with ADT is another matter. I was totally unable to launch my program from Eclipse using the emulator. It takes ages to get past the Android splash screen and I get a lot of error messages .

Speeding it up

Since android code runs on a Dalvik virtual machine, I could simply grab a x86 android machine and test my code on it. The x86 version should run pretty well on the netbook. I got a copy of Live-Android and a copy of VirtualBox x86 VM and tried the image.

Be sure to boot it using VESA in VirtualBox. Normal boot will produce strange flickering and blank screens.

It works!

How to install app onto Live Android

Live Android is a live cd, which means all data is transient. Once you reboot, all data will be wiped. That includes installed programs.

How do you get around it?

In Virtualbox, configure the Android vm, set your OS to Linux and Version to Linux 2.6
Create a hard disk (I used 100mb which is sufficient for my needs), attach it to the VM

Boot into Android Debug Mode.

You should see a Linux prompt, use fdisk(or cfdisk) to create 2 partitions.

Run "mdev -s" to create the device nodes for your new partitions.

Create file system for both partition
mke2fs -j -L /DATA /dev/sda1
mke2fs -j -L /SDCARD /dev/sda2
Reboot box

reboot -f

At the Android bootloader menu, select VESA and hit TAB, edit DATA=/dev/sda1 and SDCARD=/dev/sda2
Hit enter to resume boot.

To verify that you have mounted both partitions - hit ALT + F1 and issue "mount"

You should see /dev/sda1 and /dev/sda2 mounted.
That's it for the VM configuration. Remember to issue the boot options every time you reboot. I save the machine state when I need to shut it down so I don't have to go through that step every time.

Development Host

What you need:
  • Eclipse with ADT installed
  • Mongooose HTTP server (or any web server of your choice)


  1. In Eclipse, right click on your project, select Android Tools->Export Signed Application
  2. Follow through the dialogs, if you don't have a new keystore and key, create it now.
  3. Export it to a directory( say e:\projects\Exports)
  4. Copy mongoose.exe into e:\projects\Exports
  5. Run mongoose.exe

In Android VM

Configure the Application Settings to allow Unknown Sources

Launch browser, open HTTP://192.168.56.1:8080

You should be able to browse your directory. Download your apk and launch it.

That's it!






Resources

Mongoose HTTP server (http://code.google.com/p/mongoose/)