SELF-HOSTED OBJECT STORAGE

Run an S3-compatible object store with MinIO on your own dedicated server: install, TLS, buckets, least-privilege keys, and a restic repository that works.

Self-hosted S3 object storage with MinIO

 

Self-hosted S3 object storage with MinIO

Self-hosted object storage gives you an S3-compatible API on hardware you rent instead of hardware someone else meters. MinIO is the standard way to run it: a single Go binary that speaks the same S3 protocol your tools already know, so rclone, the AWS CLI, restic and every S3 SDK talk to it without changes. This guide sets up a MinIO dedicated server on Ubuntu 24.04 LTS from an empty box to a working bucket with scoped access keys, every command ready to paste.

The reader here is the sysadmin. Server.Biz sells unmanaged dedicated servers, so the drives, the certificates and the firewall are yours to run. Follow this top to bottom and you finish with self-hosted S3 storage, TLS in front of it, a least-privilege user for each application, a restic backup repository as the worked example, and the monitoring that tells you when a drive is unhappy.

Why run S3-compatible storage on your own hardware

The case for a self-hosted object store is almost always about egress. Cloud object storage is cheap to fill and expensive to read out of: the per-gigabyte charge for data leaving the provider is what turns a media library, a public download mirror or a busy artifact store into a bill that grows with your traffic rather than your data. Move that same workload onto a dedicated server and the economics flip, because each server on the platform comes with a monthly traffic allowance from the network. Serving terabytes to your users draws down that included allowance instead of metering you per gigabyte, which is exactly the shape of bill an egress-heavy workload wants.

Four workloads fit this pattern well. Media serving, where the same images and video get read far more often than they are written. Backup targets, where restic or Veeam pushes nightly data and you occasionally pull it all back. Machine-learning datasets, which are large, read repeatedly during training, and painful to re-download from a cloud each time. And artifact or build stores, where a CI pipeline writes and fetches containers, packages and release binaries all day. In each of these the read volume dwarfs the storage size, and reads are what cloud egress charges for.

Be honest about where real cloud S3 still wins, because it does. A hyperscaler replicates every object across multiple physically separate zones and quotes eleven nines of durability off the back of it; one server in one rack cannot match that on its own, and pairing it with an offsite copy is on you. The lifecycle and event ecosystem is deeper too: automatic tiering to cold storage, per-object expiry rules, and triggers that fire a function when an object lands. And a cloud scales to effectively unlimited capacity with no hardware to rack. If you need any of those specifically, self-hosting is the wrong tool. If you need a lot of cheap, fast, S3-shaped capacity that you read from constantly, it is the right one.

What object storage is, and when a filesystem is simpler

Object storage is not a filesystem with a web address bolted on. An object is an immutable blob plus a key and some metadata, written and read whole over an HTTP API. There are no directories, only key prefixes that look like paths. There is no seeking to byte 40,000 and rewriting ten bytes in place: to change an object you upload a new version of the whole thing. That constraint is the point. It is what lets object storage scale flat to billions of keys and hand out signed URLs that let a browser download straight from the store.

An application genuinely needs S3 semantics when it was built for them: it already speaks the S3 API, wants presigned upload and download URLs, expects versioning and object metadata, or has to scale past what a single directory tree handles comfortably. restic, most backup tools, and anything cloud-native fall here. If instead you just need a shared folder between two servers, plain files on a filesystem synced with rsync or served over NFS is simpler, faster to reason about, and has no API to secure. Do not reach for object storage because it sounds modern. Reach for it when something you run actually wants an S3 endpoint.

A licensing note before you install

MinIO is licensed under the GNU AGPLv3. For running your own infrastructure, backups and internal services, that is fine: you deploy the released binary, you do not distribute a modified version, and the copyleft terms never bite. Where AGPLv3 needs real legal thought is if you embed MinIO inside a proprietary product you ship or offer as a service to others, because the AGPL extends its source-sharing obligation to users who interact with the software over a network. That is a conversation to have with a lawyer, not a blog post, before you build a product on top of it.

If the AGPL does not fit

Two lighter S3-compatible stores are worth knowing: Garage, aimed at small self-hosted clusters, and SeaweedFS, which is Apache-licensed and good with very large numbers of small files. This guide uses MinIO because it is the most widely deployed and the closest match to the AWS S3 API, but the concepts carry over.

The hardware shape: big drive bays and erasure coding

Object storage wants capacity, so the machine to pick is one with many large drive bays rather than one fast NVMe pair. Bulk SATA HDDs give you the terabytes cheaply; the backup and storage servers in our catalogue are built for exactly this profile, and the RAID guide covers how to think about the disks underneath.

There are two ways to get redundancy, and it matters which you rely on. RAID protects against a drive dying at the block layer, below MinIO, and any level survives what the RAID guide says it survives. MinIO also has its own redundancy, erasure coding, but only when you give it several drives to spread across. This is the fork in the road. A single-node single-drive MinIO has no redundancy from MinIO itself: if that drive fails, the objects are gone, so you must put the drive on a redundant RAID array underneath. A single-node multi-drive MinIO with four or more drives is the sweet spot on one box: MinIO shards every object with erasure coding across the drives, so it keeps serving through a failed drive with no RAID at all, and heals itself onto a replacement. Four drives is the practical minimum for that scheme to be worthwhile.

Single drive

MinIO gives you no redundancy. The one drive must sit on a redundant RAID array, or a failure loses the data. Fine for a test box, not for anything you care about.

Four or more drives

MinIO erasure-codes objects across the set and survives drive loss on its own, no RAID needed. This is the recommended single-box layout for real object storage.

Still needs an offsite copy

Erasure coding survives a dead drive, not a dead datacenter. One box is one failure domain, so a second location stays part of the plan.

Install the MinIO server

MinIO runs best as a dedicated system user with a systemd unit, reading its settings from an environment file. Start by fetching the server binary and creating the user it will run as. These commands assume Ubuntu 24.04; harden the box itself first with the getting-your-server-online guide, this picks up from a patched machine behind a firewall.

Download the MinIO server binary and the mc admin client, and make both executable.

shell
sudo curl -fsSL https://dl.min.io/server/minio/release/linux-amd64/minio -o /usr/local/bin/minio
sudo curl -fsSL https://dl.min.io/client/mc/release/linux-amd64/mc -o /usr/local/bin/mc
sudo chmod +x /usr/local/bin/minio /usr/local/bin/mc
minio --version

Create a system user for MinIO to run as, so it never runs as root.

shell
sudo groupadd -r minio-user
sudo useradd -M -r -g minio-user minio-user

Format the data drives with XFS, which MinIO recommends over ext4 for large object stores because it handles many files and big volumes with less overhead. This example prepares four drives for erasure coding; adjust the device names to match "lsblk" on your machine. If you run a single drive on RAID instead, format and mount just that one array.

shell
for i in 1 2 3 4; do
  dev="/dev/sd$(printf "\\$(printf '%03o' $((97 + i)))")"   # sdb, sdc, sdd, sde
  sudo mkfs.xfs -f -L "DISK${i}" "$dev"
  sudo mkdir -p "/mnt/disk${i}"
done

Mount the drives by label so they survive device-name reshuffles, then let MinIO own them. Add matching lines to /etc/fstab so they mount on boot.

/etc/fstab
LABEL=DISK1  /mnt/disk1  xfs  defaults,noatime  0  2
LABEL=DISK2  /mnt/disk2  xfs  defaults,noatime  0  2
LABEL=DISK3  /mnt/disk3  xfs  defaults,noatime  0  2
LABEL=DISK4  /mnt/disk4  xfs  defaults,noatime  0  2

Apply the mounts and hand the directories to the MinIO user.

shell
sudo mount -a
sudo chown minio-user:minio-user /mnt/disk1 /mnt/disk2 /mnt/disk3 /mnt/disk4

Write the environment file. MINIO_VOLUMES points at the four drives with a range expansion so MinIO erasure-codes across them; for a single RAID-backed drive use MINIO_VOLUMES="/mnt/data" instead. Replace the root password with a long random string of your own: generate one with "openssl rand -base64 24". The console is bound to localhost so it never faces the internet, and the S3 API listens on 9000 behind the reverse proxy you add next.

/etc/default/minio
MINIO_VOLUMES="/mnt/disk{1...4}"
MINIO_ROOT_USER="admin"
MINIO_ROOT_PASSWORD="REPLACE_WITH_A_LONG_RANDOM_SECRET"
MINIO_OPTS="--address :9000 --console-address 127.0.0.1:9001"

Create the systemd unit. It reads the environment file, runs as the minio-user, and restarts on failure.

/etc/systemd/system/minio.service
[Unit]
Description=MinIO object storage
Documentation=https://min.io/docs
Wants=network-online.target
After=network-online.target
AssertFileIsExecutable=/usr/local/bin/minio

[Service]
Type=notify
User=minio-user
Group=minio-user
EnvironmentFile=/etc/default/minio
ExecStart=/usr/local/bin/minio server $MINIO_OPTS $MINIO_VOLUMES
Restart=always
LimitNOFILE=1048576
TimeoutStopSec=infinity
SendSIGKILL=no

[Install]
WantedBy=multi-user.target

Start MinIO and confirm it came up. The status output prints the API and console addresses.

shell
sudo systemctl daemon-reload
sudo systemctl enable --now minio
sudo systemctl status minio --no-pager

TLS and exposure: never plain over the internet

MinIO speaks HTTP on port 9000 by default, and that must never be what the internet reaches. Every access key and every object would cross the wire in clear text. Put TLS in front, and the cleanest way on a single box is a reverse proxy that gets a certificate automatically. Caddy does this in a few lines: it fetches and renews a Let's Encrypt certificate for your hostname and forwards to MinIO on localhost. Point an A record for s3.YOUR_DOMAIN at the server first.

Install Caddy from its official repository.

shell
sudo apt-get install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt-get update
sudo apt-get install -y caddy

Configure Caddy to terminate TLS and proxy to MinIO. Replace s3.YOUR_DOMAIN with your real hostname. Caddy handles the certificate on first request.

/etc/caddy/Caddyfile
s3.YOUR_DOMAIN {
	reverse_proxy 127.0.0.1:9000
}

Reload Caddy, then open only 80 and 443 to the world. Port 9000 stays on localhost, reachable only through the proxy.

shell
sudo systemctl reload caddy
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp

If you would rather not run a proxy, MinIO reads its own certificate straight from a certs directory: drop public.crt and private.key into /etc/minio/certs and add --certs-dir /etc/minio/certs to MINIO_OPTS. Either way the rule holds: the S3 endpoint is HTTPS only.

The console is a different matter. It is an admin surface, and admin surfaces do not belong on the public internet at all. It is already bound to 127.0.0.1:9001, so reach it over an SSH tunnel ("ssh -L 9001:127.0.0.1:9001 you@server") or, better, put it behind a private VPN the way the WireGuard guide describes and browse to it over the tunnel. Never proxy the console to a public hostname.

Buckets, users and least-privilege policies

With TLS in front, point the mc client at the server using the root credentials, then stop using those root credentials for anything else. The root user is for administration; every application gets its own scoped key. Set up the alias first.

Register the server with mc under the alias "local". Use the root user and the password from the environment file. Replace s3.YOUR_DOMAIN with your hostname.

shell
mc alias set local https://s3.YOUR_DOMAIN admin REPLACE_WITH_A_LONG_RANDOM_SECRET
mc admin info local

Create a bucket and turn on versioning. Versioning keeps the previous copy of every object when it is overwritten or deleted, so a bad sync or a mistaken delete is recoverable. It pairs with backups rather than replacing them: it protects against overwrites inside this store, while an offsite copy still protects against losing the store itself.

shell
mc mb local/backups
mc version enable local/backups

Write a bucket-scoped policy that grants read and write on just this one bucket and nothing else. This JSON lets a holder list, upload, download and delete objects in the backups bucket only.

/tmp/backups-rw.json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["s3:ListBucket", "s3:GetBucketLocation"],
      "Resource": ["arn:aws:s3:::backups"]
    },
    {
      "Effect": "Allow",
      "Action": [
        "s3:PutObject",
        "s3:GetObject",
        "s3:DeleteObject",
        "s3:ListMultipartUploadParts",
        "s3:AbortMultipartUpload"
      ],
      "Resource": ["arn:aws:s3:::backups/*"]
    }
  ]
}

Load the policy, create a dedicated user for the application, and attach the policy to that user. Give the user a long random secret key of its own. Now this key can touch the backups bucket and is powerless everywhere else.

shell
mc admin policy create local backups-rw /tmp/backups-rw.json
mc admin user add local restic-app REPLACE_WITH_ANOTHER_LONG_SECRET
mc admin policy attach local backups-rw --user restic-app

One key per application is the habit that pays off later. When a service is retired or a key leaks, you disable that one user and nothing else is affected, no shared secret to rotate across every app at once. For a backup target you can go further and drop s3:DeleteObject from the policy, so a compromised server can add new backups but never erase old ones, the append-only pattern the backup guide recommends.

Putting data in: rclone, the AWS CLI and restic

Because the endpoint is plain S3, every S3 tool works against it once you set the endpoint URL and the access keys. Three cover almost everything: rclone for syncing files and folders, the AWS CLI or any SDK for scripting, and restic for the backup case this guide is built around.

Configure an rclone remote for the box. Save this block into rclone's config file, or run "rclone config" and answer the prompts. Fill in the access key and secret from the restic-app user you created.

~/.config/rclone/rclone.conf
[minio]
type = s3
provider = Minio
access_key_id = restic-app
secret_access_key = REPLACE_WITH_ANOTHER_LONG_SECRET
endpoint = https://s3.YOUR_DOMAIN

List the bucket and copy a folder up to it with rclone.

shell
rclone ls minio:backups
rclone copy /var/www/uploads minio:backups/uploads

The AWS CLI and every SDK reach the same store by overriding the endpoint. Export the keys, then pass --endpoint-url. This is the exact pattern an application config uses: set endpoint_url to your MinIO hostname and the rest is standard S3.

shell
export AWS_ACCESS_KEY_ID="restic-app"
export AWS_SECRET_ACCESS_KEY="REPLACE_WITH_ANOTHER_LONG_SECRET"
aws --endpoint-url https://s3.YOUR_DOMAIN s3 ls s3://backups
aws --endpoint-url https://s3.YOUR_DOMAIN s3 cp report.pdf s3://backups/reports/report.pdf

The worked example: point restic at the bucket as an encrypted backup repository. This ties into the server backup strategy guide, where MinIO on a second box is the offsite target. restic encrypts client-side, so the objects that land in the bucket are already ciphertext.

shell
export RESTIC_REPOSITORY="s3:https://s3.YOUR_DOMAIN/backups/web01"
export AWS_ACCESS_KEY_ID="restic-app"
export AWS_SECRET_ACCESS_KEY="REPLACE_WITH_ANOTHER_LONG_SECRET"
export RESTIC_PASSWORD_FILE="/root/.restic-password"
restic init
restic backup /etc /srv /var/www

For sharing a single object without handing out a key, generate a presigned URL. This one is valid for 24 hours and lets anyone with the link download that object over HTTPS, then expires. It is the object-storage way to share a file: no account, no permanent access.

shell
mc share download --expire 24h local/backups/reports/report.pdf

Operating it: monitoring, healing and capacity

A store you never look at is a store that surprises you. Two numbers matter day to day: whether every drive is healthy, and how full you are. mc reports both, and MinIO exposes Prometheus metrics for the dashboard.

Check cluster and drive health at a glance. "mc admin info" shows each drive's state and the space used; a drive that has dropped out shows here first.

shell
mc admin info local
mc du local/backups

MinIO publishes Prometheus metrics on a cluster endpoint. Generate a ready-made scrape job and paste it into your Prometheus config, the setup the self-hosted monitoring guide walks through.

shell
mc admin prometheus generate local

On a multi-drive erasure-coded box, MinIO scrubs objects in the background and heals automatically onto a replaced drive, so most of the time there is nothing to do. To trigger an on-demand heal scan and watch its progress, run this. On a single-drive setup there is no redundancy for MinIO to heal, which is the whole reason that layout needs RAID underneath.

shell
mc admin heal -r local

Watch capacity with room to spare. An object store that fills up stops accepting writes, and on an erasure-coded set you want headroom for a heal to rebuild into after a drive swap. Alert at around 80% used rather than waiting for full.

The reminder that outlives every command here: object storage is not a backup by itself. A bucket with versioning on protects you from overwrites and deletes inside this store, but the store is one machine in one rack. The plan is versioning plus a second copy somewhere else, and the server backup strategy guide covers building that second copy properly.

Which tool for which job

One box running MinIO covers a lot, real cloud S3 covers the cases it cannot, and sometimes plain files are the honest answer. Match the job to the tool.

Use case One-box MinIO Real cloud S3 Plain filesystem
Egress-heavy media or downloads Strong fit, allowance-based traffic Works, egress adds up Fine if one server serves it
Backup target for restic or Veeam Strong fit Works, watch restore egress rsync or SFTP is simpler
Cross-zone eleven-nines durability Not on one box, add offsite Built in No
Shared folder between two servers Overkill Overkill rsync or NFS, simpler
Presigned URLs and S3 API Yes Yes No, no API
Effectively unlimited scale Bounded by your drives Yes No

The short version

Run MinIO when you have an egress-heavy, S3-shaped workload and want it on hardware with an included traffic allowance instead of per-gigabyte cloud egress. Put it on a machine with many drive bays, give MinIO four or more drives so its erasure coding is your redundancy, and never expose the plain API or the console to the internet: TLS in front, console on the VPN. Hand each app its own bucket-scoped key, turn on versioning, and remember the store is still one failure domain, so keep an offsite copy. Harden the box first with the getting-your-server-online guide.

Continue reading

Need help choosing?

Our experts can help you find the perfect server for your needs.

Contact us »