Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend the documentation with more examples #54

Open
itssamuelrowe opened this issue Aug 5, 2021 · 1 comment
Open

Extend the documentation with more examples #54

itssamuelrowe opened this issue Aug 5, 2021 · 1 comment

Comments

@itssamuelrowe
Copy link

itssamuelrowe commented Aug 5, 2021

I am trying to build a system like HackerRank, i.e., the code submitted by the user should be executed on the server. From what I understand, bst can be used for this.

If I run bst, it opens my shell as mentioned in the documentation. If I delete files the changes are persisted outside my isolated environment. Can somebody please explain what I am missing?

I tried changing the root with --root, but this is what I get:

samuel@Titan ~/p/bst (main) [1]> bst --root ~/Desktop/test-root ls
bst-init: execvpe ls: No such file or directory

PS: I have no knowledge about namespaces.

@Snaipe
Copy link
Member

Snaipe commented Aug 5, 2021

In these cases bst won't setup a root filesystem for you because there's just too much variation between use-cases. For what you want to do, there's a few options:

  1. Bind-mount the root onto itself read-only (e.g., bst -r <root> --mount <root>,/,none,rbind,ro). This of course means that your rootfs won't be mutable (so no running some package manager) but is probably the fastest way to provide a working immutable root.
  2. Copy the root dir and just enter it. If your system supports filesystems with unprivileged subvolume creation and snapshotting like btrfs, this can be extremely quick too.
  3. If your kernel allows the use of overlay2 mounts unprivileged in a user namespace, then you can use a setup script to create a discardable overlay: bst -r /mnt --setup 'mount -t tmpfs tmp /tmp && mount -t overlay overlay -o lowerdir=/,upperdir=/tmp/upper,workdir=/tmp/work $ROOT'. Most distro kernels disable this though.

All of these are still highly dependent on what you want to achieve. You could also construct a rootfs dynamically with copies and bind-mounts with an elaborate setup script too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants