DEV Community

michaellee8
michaellee8

Posted on

Trying out Fuchsia in a GCP VM

I tried to build the whole Fuchsia thing in my own notebook, however obviously it doesn't have enough power to build the whole thing in reasonable time. Here are briefly my steps I took to build and run it in GCP.

Note: It takes real money (or free credits if you got any of them left) to do this, so check your pocket!

  1. Start a High CPU VM with SSD disk. I personally chose a 16cpu 16gb Ubuntu 18.04 LTS instance with a 500gb ssd since the build size is very large (took my disk about 400gb space!). The compilation is mostly CPU and IO bound so RAM usage is only about 2gb mostly. I took 16cpu and 500gb ssd since this is the largest amount I can get with my account quota. Previously I tried to do it with a HDD and it stuck for a long time.

  2. Follow the instructions in https://fuchsia.dev/fuchsia-src/development/source_code/README to clone the whole source code in to your SSD (should be fast since this is GCP), and then build the whole thing according to the instructions in https://fuchsia.dev/fuchsia-src/getting_started#build_fuchsia . Note that I would suggest you to do fx set workstation.x64 --ccache with a CCACHE_DIR set to an existing directory so that you will get an usable build with build caching enabled.

  3. After you built the whole project (congratulations!) with a few hours, you can now stop the instance and make a nested VM enabled image with the disk according to https://cloud.google.com/compute/docs/instances/enable-nested-virtualization-vm-instances . You need to do this to run the emulator inside the cloud VM.

  4. Create another nested VM-enabled instance with the image we just made. I uses a 8cpu 32gb instance. Remember to choose Intel Cascade Lake or Later for CPU platform, turn on virtual display device and choose SSD for the boot disk.

  5. Keep following the instructions in https://cloud.google.com/compute/docs/instances/enable-nested-virtualization-vm-instances#tested_os_versions , make sure that virtualization is enabled and install qemu-kvm. You may want to do sudo usermod -a -G kvm <your_username> and then login again to give yourself permission to kvm.

  6. Follow the instructions in https://cloud.google.com/solutions/chrome-desktop-remote-on-compute-engine to setup Chrome Remote Desktop.

  7. Now you can run Fuchsia with fx emu -N. Note that you won't be able to see anything since the GCE instance has no Vulkan support! Even you enable the T4 GRID Workstation GPU, NVIDIA's GRID driver still won't support Vulkan, as verified in their datasheet.

  8. Now you have two choices here. Either transfer the whole build artifacts back to your own computer with Vulkan support, preferably with Google Drive to minimize network cost, or switch to command line mode with fx set core.x64 --ccache and then fx build so that it won't use Vulkan, which will allows you to happily do some Fuchsia development, but you will not have any GUI.

Note: Maybe the 500gb thing is just a miscalculation by the ncdu. I verified that the whole fuchsia + ccache directory will only take like 140gb, which is about 50gb after compression.

Top comments (0)