Error while following "Getting Started with LiteFS on Fly.io"

I’m following the tutorial on how to start with litefs, but for some reason there are permission issues and following the tutorial doesn’t help. More specifically: ERROR: cannot init file system: cannot open file system: mkdir /litefs: permission denied.

Example repo with the code: Github Repository

Logs:
2024-03-18T22:33:28.881 runner[e784e047b315e8] gru [info] Pulling container image registry.fly.io/go-litefs:deployment-01HS9V2VC4341CR20EN8B1CWX5

2024-03-18T22:33:29.625 runner[e784e047b315e8] gru [info] Successfully prepared image registry.fly.io/go-litefs:deployment-01HS9V2VC4341CR20EN8B1CWX5 (743.661241ms)

2024-03-18T22:33:29.644 runner[e784e047b315e8] gru [info] Setting up volume ‘litefs’

2024-03-18T22:33:29.644 runner[e784e047b315e8] gru [info] Opening encrypted volume

2024-03-18T22:33:30.767 runner[e784e047b315e8] gru [info] Configuring firecracker

2024-03-18T22:33:30.916 app[e784e047b315e8] gru [info] INFO Sending signal SIGINT to main child process w/ PID 313

2024-03-18T22:33:30.917 app[e784e047b315e8] gru [info] signal received, litefs shutting down

2024-03-18T22:33:30.917 app[e784e047b315e8] gru [info] level=INFO msg=“93E865EE614C2D22: exiting primary, destroying lease”

2024-03-18T22:33:31.287 app[e784e047b315e8] gru [info] litefs shut down complete

2024-03-18T22:33:32.148 app[e784e047b315e8] gru [info] INFO Main child exited normally with code: 0

2024-03-18T22:33:32.148 app[e784e047b315e8] gru [info] INFO Starting clean up.

2024-03-18T22:33:32.149 app[e784e047b315e8] gru [info] INFO Umounting /dev/vdb from /var/lib/litefs

2024-03-18T22:33:32.153 app[e784e047b315e8] gru [info] WARN hallpass exited, pid: 314, status: signal: 15 (SIGTERM)

2024-03-18T22:33:32.156 app[e784e047b315e8] gru [info] 2024/03/18 22:33:32 listening on [fdaa:1:872f:a7b:136:cad2:4933:2]:22 (DNS: [fdaa::3]:53)

2024-03-18T22:33:33.151 app[e784e047b315e8] gru [info] [ 73.382018] reboot: Restarting system

2024-03-18T22:33:33.616 app[e784e047b315e8] gru [info] [ 0.038245] PCI: Fatal: No config space access function found

2024-03-18T22:33:33.848 app[e784e047b315e8] gru [info] INFO Starting init (commit: 913ad9c)…

2024-03-18T22:33:33.866 app[e784e047b315e8] gru [info] INFO Mounting /dev/vdb at /var/lib/litefs w/ uid: 10001, gid: 10001 and chmod 0755

2024-03-18T22:33:33.870 app[e784e047b315e8] gru [info] INFO Resized /var/lib/litefs to 5364514816 bytes

2024-03-18T22:33:33.871 app[e784e047b315e8] gru [info] INFO Preparing to run: /bin/sh -c litefs mount as appuser

2024-03-18T22:33:33.876 app[e784e047b315e8] gru [info] INFO [fly api proxy] listening at /.fly/api

2024-03-18T22:33:33.880 app[e784e047b315e8] gru [info] 2024/03/18 22:33:33 listening on [fdaa:1:872f:a7b:136:cad2:4933:2]:22 (DNS: [fdaa::3]:53)

2024-03-18T22:33:33.890 runner[e784e047b315e8] gru [info] Machine created and started in 5.013s

2024-03-18T22:33:33.919 app[e784e047b315e8] gru [info] config file read from /etc/litefs.yml

2024-03-18T22:33:33.919 app[e784e047b315e8] gru [info] LiteFS v0.5.11, commit=63eab529dc3353e8d159e097ffc4caa7badb8cb3

2024-03-18T22:33:33.920 app[e784e047b315e8] gru [info] level=INFO msg=“host environment detected” type=fly.io

2024-03-18T22:33:33.920 app[e784e047b315e8] gru [info] level=INFO msg=“litefs cloud backup client configured: https://litefs.fly.io

2024-03-18T22:33:33.920 app[e784e047b315e8] gru [info] level=INFO msg=“Using Consul to determine primary”

2024-03-18T22:33:34.090 app[e784e047b315e8] gru [info] level=INFO msg=“initializing consul: key=litefs/go-litefs url=https://:1fe4619f-a4a4-11bc-239e-070b2d612d58@consul-iad-5.fly-shared.net/go-litefs-8gnr14rpey7qy7wm/ hostname=e784e047b315e8 advertise-url=http://e784e047b315e8.vm.go-litefs.internal:20202

2024-03-18T22:33:34.091 app[e784e047b315e8] gru [info] level=INFO msg=“using existing cluster id: "LFSC39AA62F6869BBAAA"”

2024-03-18T22:33:34.094 app[e784e047b315e8] gru [info] waiting for signal or subprocess to exit

2024-03-18T22:33:34.094 app[e784e047b315e8] gru [info] ERROR: cannot init file system: cannot open file system: mkdir /litefs: permission denied

2024-03-18T22:33:34.684 app[e784e047b315e8] gru [info] level=INFO msg=“43AB20FFB5E9890F: primary lease acquired, advertising as http://e784e047b315e8.vm.go-litefs.internal:20202

2024-03-18T22:33:34.803 app[e784e047b315e8] gru [info] level=INFO msg=“begin primary backup stream: url=https://litefs.fly.io

2024-03-18T22:33:35.804 app[e784e047b315e8] gru [info] level=INFO msg=“begin streaming backup” full-sync-interval=10s

2024-03-18T22:33:39.803 app[e784e047b315e8] gru [info] level=INFO msg=“cannot set environment metadata” reason=“retries exceeded” err=“Post "http://localhost/v1/apps/go-litefs/machines/e784e047b315e8/metadata/role\”: dial unix /.fly/api: connect: permission denied"

Hi… You really want to retain superuser privileges, at least at first:

It’s recommended that you run LiteFS as root in Docker instead of using the USER command to change users.

https://fly.io/docs/litefs/getting-started-fly/#installing-litefs-2

(It is possible to subsequently su down within the exec stanza of litefs.yml, but fair warning that there are non-intuitive complications, :dragon:.)

Hope this helps!

That fixed the issue, now im fighing alpine and CGO to run things. Either way, thanks for the help.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.