1
0

example_fs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. # Copyright 2023 The ChromiumOS Authors
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. # Example VM with a shared directory
  6. set -e
  7. SRC=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
  8. #If "example_simple" is executed, reuse its image. Otherwise, create one.
  9. mkdir -p "$SRC/images/simple" && cd "$_"
  10. mkdir -p "host_shared_dir"
  11. HOST_SHARED_DIR="$SRC/images/simple/host_shared_dir"
  12. if ! [ -f rootfs ]; then
  13. # Build a simple ubuntu image and create a user with no password.
  14. virt-builder ubuntu-20.04 \
  15. --run-command "useradd -m -g sudo -p '' $USER ; chage -d 0 $USER" \
  16. -o ./rootfs
  17. virt-builder --get-kernel ./rootfs -o .
  18. fi
  19. # Use crosvm/tools/examples/images/simple/host_shared_dir as mount point
  20. cargo run -- run \
  21. --shared-dir "$HOST_SHARED_DIR:my_shared_tag:type=fs" \
  22. --rwdisk ./rootfs \
  23. --initrd ./initrd.img-* \
  24. -p "root=/dev/vda5 " \
  25. ./vmlinuz-*
  26. ## In guest OS, run following instructions to set up the shared directory
  27. ## sudo su
  28. ## mkdir /tmp/guest_shared_dir
  29. ## mount -t virtiofs my_shared_tag /tmp/guest_shared_dir