Skip to content

Conversation

edubart
Copy link
Collaborator

@edubart edubart commented Oct 9, 2024

Some people are beginning to use cartesi-machine to prototype and test new software directly. This PR adds new shorthands to make easier to use common prototyping commands:

  • -m shorthand for --ram-length
  • -k shorthand for --ram-image
  • -q shorthand for --quiet --no-init-splash
  • -r/--rootfs shorthand for --flash-drive=label:root,filename:<filename>
  • -S/--shared-rootfs shorthand for setting rootfs as shared

Use case example

This PR goal is to make the following prototyping use case less boilerplate (smaller commands).

Suppose I installed latest cartesi machine on my system, and I would like to try out new software just to check if it the machine would run it (I don't want to mess with Docker yet! I am not really creating a dapp neither! just a quick test!).

First thing I would do is to copy standard rootfs.ext2 and resize it to be bigger, and I can use resize2fs inside cartesi machine to do this:

$ cp $(cartesi-machine --version-json | jq -r .default_rootfs_image) rootfs.ext2
$ cartesi-machine -q -v=.:/mnt -u=root -- resize2fs -f /mnt/rootfs.ext2 512M

Now I would like to install new software in this custom rootfs, like gcc, I also want the changes to persist:

$ cartesi-machine -q -n -S -r=rootfs.ext2 -u=root -- "apt-get update && apt-get install -y gcc"

Finally I could share host current directory and start compiling GCC and testing programs inside the cartesi machine:

$ echo "int main(){}" > test.c
$ cartesi-machine -q -m=256Mi -v=.:/mnt -w=/mnt -r=rootfs.ext2 -u=root -h=playground -it bash
root@playground:/mnt# gcc test.c -o test && ./test
root@playground:/mnt# 

Lastly I could even make this my rootfs with GCC the default on my machine, with:

$ cp $(cartesi-machine --version-json | jq -r .default_ram_image) linux.bin
$ export CARTESI_IMAGES_PATH=`pwd`
$ cartesi-machine -q -- gcc --version
gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0

-m shorthand for --ram-length
-k shorthand for --ram-image
-q shorthand for --quiet --no-init-splash
-r/--rootfs shorthand for --flash-drive=label:root,filename:<filename>
-S/--shared-rootfs shorthand for setting rootfs as shared
@edubart edubart added the enhancement New feature or request label Oct 9, 2024
@edubart edubart self-assigned this Oct 9, 2024
Base automatically changed from refactor/c-api to main December 10, 2024 16:50
@edubart edubart marked this pull request as draft December 10, 2024 17:03
@edubart edubart moved this from Todo to On Hold in Machine Unit Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: On Hold

Development

Successfully merging this pull request may close these issues.

1 participant