Skip to content

Instantly share code, notes, and snippets.

@SaicharanKandukuri
Last active May 23, 2024 08:57
Show Gist options
  • Save SaicharanKandukuri/196f58746d511989ab508333d96641f6 to your computer and use it in GitHub Desktop.
Save SaicharanKandukuri/196f58746d511989ab508333d96641f6 to your computer and use it in GitHub Desktop.

Android pkvm

Booting a linux file system with crosvm provided in android. ( experiment )

Creating an ext4 image with tarballs

# ~2GB size
dd if=/dev/zero of=udroid_image.ext4.img bs=1M count=2000
# format to ext4
mkfs.ext4 udroid_image.ext4.img

# mount the formated image
mkdir udroid_image
sudo mount -o loop udroid_image.ext4.img udroid_image

# download a tarball
wget https://github.com/RandomCoderOrg/udroid-download/releases/download/V3R77/jammy-gnome-arm64.tar.gz

# extract to image dir and unmount it
sudo tar -xvpf jammy-gnome-arm64.tar.gz -C udroid_image

# resolve some dir's (just in case)
mkdir -pv udroid_image/{dev,proc,sys}

## setup root password
cd udroid_image
sudo mount -t sysfs /sys sys/
sudo mount -t proc /proc proc/
sudo mount -o bind /dev dev/
sudo  chroot ../udroid_image

# set your password
passwd root

# then exit the chroot
exit

# unmount 
sudo umount sys
sudo umount proc
sudo umount dev

# finally umount dir
cd ..
sudo umount udroid_image

# push image to android
adb
cd /apex/com.android.virt@2/bin
./crosvm run --disable-sandbox --block /data/local/tmp/udroid-noble.img,root -p 'root=/dev/vda' /data/local/tmp/Image

with network ( not working rn - need help )

./crosvm run --disable-sandbox --net tap-name=crosvm_tap --block /data/local/tmp/udroid-noble.img,root -p 'root=/dev/vda' /data/local/tmp/Image
@SaicharanKandukuri
Copy link
Author

SaicharanKandukuri commented May 22, 2024

New find: /dev/kvm is exposed for read writes for everyone excepth users

so in theory shell user (adb) could get qemu running

Update
Its not working, only option to boot is crosvm now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment