|
| 1 | +# Mount a Tigris bucket with geesefs |
| 2 | + |
| 3 | +[geesefs](https://github.com/yandex-cloud/geesefs) lets you mount S3 buckets to |
| 4 | +your local Linux system. This tool works with Tigris too, letting you mount any |
| 5 | +Tigris bucket as if it was a normal Linux filesystem. |
| 6 | + |
| 7 | +- Install geesefs |
| 8 | +- Configure credentials |
| 9 | +- systemd service to start geesefs on boot |
| 10 | +- Reboot test |
| 11 | + |
| 12 | +Prerequisites: |
| 13 | + |
| 14 | +- A Tigris account |
| 15 | +- A bucket you want to mount into your system (`mybucket`) |
| 16 | +- A target location you want to mount your bucket to (`~/data`) |
| 17 | + |
| 18 | +:::note |
| 19 | + |
| 20 | +geesefs uses |
| 21 | +[FUSE](https://www.kernel.org/doc/html/latest/filesystems/fuse.html) to mount |
| 22 | +buckets into the filesystem. FUSE has limitations involving multiple users |
| 23 | +accessing the same mountpoint. If you need multiple users (human or service) to |
| 24 | +access the same bucket, consider creating multiple systemd services mounting the |
| 25 | +bucket in each user's home directory. |
| 26 | + |
| 27 | +::: |
| 28 | + |
| 29 | +## Installing geesefs |
| 30 | + |
| 31 | +Download the latest release for your machine from |
| 32 | +[the list of geesefs releases](https://github.com/yandex-cloud/geesefs/releases) |
| 33 | +to `/usr/local/bin`: |
| 34 | + |
| 35 | +<details> |
| 36 | +<summary>amd64 Linux</summary> |
| 37 | + |
| 38 | +```text |
| 39 | +sudo wget -O /usr/local/bin/geesefs https://github.com/yandex-cloud/geesefs/releases/download/v0.42.0/geesefs-linux-amd64 |
| 40 | +``` |
| 41 | + |
| 42 | +</details> |
| 43 | +<details> |
| 44 | +<summary>arm64/aarch64 Linux</summary> |
| 45 | + |
| 46 | +```text |
| 47 | +sudo wget -O /usr/local/bin/geesefs https://github.com/yandex-cloud/geesefs/releases/download/v0.42.0/geesefs-linux-arm64 |
| 48 | +``` |
| 49 | + |
| 50 | +</details> |
| 51 | + |
| 52 | +Then mark it as executable: |
| 53 | + |
| 54 | +``` |
| 55 | +sudo chmod +x /usr/local/bin/geesefs |
| 56 | +``` |
| 57 | + |
| 58 | +## Configure credentials |
| 59 | + |
| 60 | +Create a new access key with edit permissions on your target bucket. Edit |
| 61 | +`~/.aws/credentials` with a text editor: |
| 62 | + |
| 63 | +``` |
| 64 | +[default] |
| 65 | +aws_access_key_id = <paste access key starting with tid_> |
| 66 | +aws_secret_access_key = <paste secret access key starting with tsec_> |
| 67 | +``` |
| 68 | + |
| 69 | +## Mount bucket on login with systemd |
| 70 | + |
| 71 | +Make a folder for the geesefs service: |
| 72 | + |
| 73 | +```text |
| 74 | +mkdir -p ~/.local/share/systemd/user |
| 75 | +``` |
| 76 | + |
| 77 | +Then copy this unit into `~/.local/share/systemd/user/mount-data.service`: |
| 78 | + |
| 79 | +```text |
| 80 | +[Unit] |
| 81 | +Description=Mount Tigris bucket mybucket to ~/data |
| 82 | +After=network.target |
| 83 | +
|
| 84 | +[Service] |
| 85 | +Type=forking |
| 86 | +WorkingDirectory=%h |
| 87 | +ExecStart=/usr/local/bin/geesefs --endpoint https://fly.storage.tigris.dev mybucket %h/data |
| 88 | +
|
| 89 | +[Install] |
| 90 | +WantedBy=default.target |
| 91 | +``` |
| 92 | + |
| 93 | +Make sure to adjust `mybucket` and `%h/data` as needed. In systemd units, `%h` |
| 94 | +refers to your home directory, so this mounts bucket `mybucket` to `~/data`. |
| 95 | + |
| 96 | +Enable the unit with `systemctl daemon-reload` and `systemctl enable`: |
| 97 | + |
| 98 | +```text |
| 99 | +systemctl --user daemon-reload |
| 100 | +systemctl --user enable --now mount-data.service |
| 101 | +``` |
| 102 | + |
| 103 | +## Reboot test |
| 104 | + |
| 105 | +Reboot your system and log back in. Run the mount command and you should see |
| 106 | +information about geesefs mounting your bucket: |
| 107 | + |
| 108 | +```text |
| 109 | +$ mount | grep geesefs |
| 110 | +mybucket on /home/opc/data type fuse.geesefs (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000,default_permissions) |
| 111 | +``` |
| 112 | + |
| 113 | +You did it! |
0 commit comments