Skip to content

pluvial/vm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vm

Linux VMs on ARM64

Getting vm

mkdir vm && curl -L https://github.com/pluvial/vm/archive/main.tar.gz | tar xzf - --strip-components=1
mkdir vm && wget https://github.com/pluvial/vm/archive/main.tar.gz -O - | tar xzf - --strip-components=1
git clone --depth=1 https://github.com/pluvial/vm

Building vm binary

./build.sh
# or
xcodebuild -arch arm64
$ tree build/Release
build/Release/
├── vm
├── vm.dSYM
│   └── Contents
│       ├── Info.plist
│       └── Resources
│           ├── DWARF
│           │   └── vm
│           └── Relocations
│               └── aarch64
│                   └── vm.yml
└── vm.swiftmodule
    ├── Project
    │   └── arm64-apple-macos.swiftsourceinfo
    ├── arm64-apple-macos.abi.json
    ├── arm64-apple-macos.swiftdoc
    └── arm64-apple-macos.swiftmodule

9 directories, 8 files

Setup Ubuntu VM

ubuntu/setup.sh
tree ubuntu
ubuntu
├── cidata
│   ├── meta-data
│   └── user-data
├── initrd
├── noble-server-cloudimg-arm64.tar.gz
├── run.sh
├── setup.sh
├── vda.img
├── vdb.img
├── vdc.iso
├── vmlinuz
└── vmlinuz.gz

2 directories, 11 files

Run Ubuntu VM

ubuntu/run.sh

Mount host shared directories:

sudo mkdir /mnt/host
sudo mount -t virtiofs host /mnt/host
# or add to /etc/fstab :
# host /mnt/host virtiofs defaults 0 0

Setup Alpine VM

In Ubuntu VM:

cd /mnt/host/cwd/alpine
sudo ./build.sh

Creates /mnt/host/cwd/vm-build

In host:

mv vm-build/* alpine
alpine/setup.sh
tree alpine
alpine
├── alpine-minirootfs.tar.gz
├── etc
│   ├── fstab
│   ├── group
│   ├── hosts
│   ├── init.d
│   │   ├── rcK
│   │   └── rcS
│   ├── inittab
│   └── passwd
├── image.sh
├── linux.config
├── linux.sh
├── linux.tar.xz
├── linux.version
├── mnt
├── root
│   ├── build.sh
│   ├── setup-podman.sh
│   └── setup-vdb.sh
├── run.sh
├── setup.sh
├── usr
│   └── share
│       └── udhcpc
│           └── default.script
├── vda.img
├── vdb.img
└── vmlinuz

8 directories, 22 files

Run Alpine VM

alpine/run.sh

SSH into VM

In VM:

apk add dropbear && reboot

In host:

alpine/ssh.sh

Setup Podman

In VM:

./setup-vdb.sh
./setup-podman.sh

Test with:

podman run --rm -it alpine

Build Linux in Podman

./build.sh

Creates ~/build/vmlinuz, can be copied to host with:

cp build/vmlinuz /mnt/host/cwd/

Cleaning

Clean disk images:

./clean.sh

Clean disk images, downloads, and build artifacts

./clean.sh --all

Inspiration

apinske/virt

Apple sample code: