Skip to content

Deploying MinIO object storage on AlmaLinux 9 (production-ready)

Stand up a hardened MinIO S3-compatible object store on AlmaLinux 9 — single-node multi-drive, TLS on console + API, systemd hardening, IAM policy skeleton.

You’ve been asked to provide an S3-compatible bucket for the application team. The quick path is a single wget of the minio binary, a minio server /data invocation in a screen session, and a Slack message with the access key. Three months later, the data directory has filled to 98%, the console is reachable on 0.0.0.0:9001 with the default credentials in someone’s terminal history, the API speaks plain HTTP because no certificate was ever installed, and the first time anyone tries to use it for actual backups they discover the underlying filesystem was created with ext4 defaults and is logging EIO on heads.

What’s happening

A MinIO deployment that is actually production-ready needs more than a single binary on a single drive. Object storage that holds backups, application artefacts, or customer data needs a real IAM policy model (not a shared root credential), TLS on both the API and the console listeners (S3 clients refuse plain HTTP on most defaults), capacity headroom with an alert before the volume fills (MinIO rejects writes at high utilisation and the failure mode is silent for the caller), a periodic data scrub via mc admin heal so bit-rot does not become a restore problem, and at least one verified restore exercise per quarter. Single-node multi-drive (SNMD) is the canonical entry shape — it gives erasure coding across local drives without the operational complexity of a multi-node distributed cluster. None of these are individually critical. They compound — skip them and the bucket becomes the most expensive way the team has ever lost a file.

How to verify

After install, the listeners should look like this:

ss -lntp | grep -E ':(9000|9001|443)\b'
# 127.0.0.1:9001  minio   (console, behind nginx)
# 0.0.0.0:9000    minio   (S3 API, TLS)
# 0.0.0.0:443     nginx   (console proxy)

The S3 API on :9000 must terminate TLS. The console on :9001 must be 127.0.0.1 and reached through nginx. Cluster and drive health:

mc admin info local
# Drives: 4/4 OK
# Pools:  1
# Used:   ...

A scrub of object metadata across drives:

mc admin heal -r local
# No unhealed items.

If the API answers on plain http:// or the console is bound to 0.0.0.0, the deployment is not production-ready regardless of what the smoke test returned.

The fix

Save the script below as /root/setup-minio-almalinux9.sh, then run it. It performs the full installer flow on a fresh AlmaLinux 9.x VM with four data drives presented as /dev/vdb through /dev/vde: base update + EPEL, kernel tuning, file limits, SSH hardening with root key preserved, fail2ban for SSH, dnf-automatic.timer for security updates, XFS on each data drive with noatime, MinIO RPM from the upstream repository, a minio system user, a /etc/default/minio environment file with the root credential generated locally, a systemd unit with LimitNOFILE=64000, nginx in front of the console with Let’s Encrypt TLS, a second Let’s Encrypt cert applied to the S3 API listener itself, the mc client bootstrapped with an alias, and a starter IAM policy that the application team can clone instead of using root.

#!/usr/bin/env bash
set -euo pipefail

### AlmaLinux 9.x MinIO single-node multi-drive installer
### Keeps root SSH key login enabled
### Disables SSH password login
### Enables automatic security updates
### Installs and configures MinIO + nginx + Let's Encrypt
### No local backups; assumes VM-level backup
### Reboot remains manual

if [[ "$(id -u)" -ne 0 ]]; then
  echo "Run as root."
  exit 1
fi

: "${MINIO_DOMAIN_API:=s3.example.com}"
: "${MINIO_DOMAIN_CONSOLE:=minio.example.com}"
: "${LE_EMAIL:=ops@example.com}"
: "${MINIO_DATA_DRIVES:=/dev/vdb /dev/vdc /dev/vdd /dev/vde}"

echo
echo "========================================"
echo "MinIO AlmaLinux 9.x Setup"
echo "========================================"
echo

echo "==> Updating base OS"
dnf -y update
dnf -y install epel-release
dnf -y update

echo "==> Installing base packages"
dnf -y install \
  vim curl wget ca-certificates gnupg2 chrony fail2ban \
  dnf-automatic policycoreutils-python-utils lsof tcpdump \
  bind-utils yum-utils tar gzip unzip iproute net-tools \
  xfsprogs nginx

echo "==> Enabling time sync"
systemctl enable --now chronyd
timedatectl set-ntp true

echo "==> Applying kernel/network tuning"
cat > /etc/sysctl.d/99-minio.conf <<'SYSCTL'
net.core.somaxconn = 4096
net.core.netdev_max_backlog = 250000
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_fin_timeout = 15
net.ipv4.ip_local_port_range = 10240 65535

vm.swappiness = 10
vm.dirty_ratio = 20
vm.dirty_background_ratio = 5

kernel.dmesg_restrict = 1
kernel.kptr_restrict = 2
fs.file-max = 2097152
SYSCTL

sysctl --system

echo "==> Setting file limits"
cat > /etc/security/limits.d/99-minio.conf <<'LIMITS'
* soft nofile 64000
* hard nofile 64000
root soft nofile 64000
root hard nofile 64000
minio-user soft nofile 64000
minio-user hard nofile 64000
LIMITS

echo "==> Hardening SSH while keeping root SSH key login enabled"
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak.$(date +%F-%H%M%S)

set_sshd_option() {
  local key="$1" value="$2"
  if grep -qE "^[#[:space:]]*${key}[[:space:]]+" /etc/ssh/sshd_config; then
    sed -i "s|^[#[:space:]]*${key}[[:space:]].*|${key} ${value}|" /etc/ssh/sshd_config
  else
    echo "${key} ${value}" >> /etc/ssh/sshd_config
  fi
}

set_sshd_option PermitRootLogin prohibit-password
set_sshd_option PasswordAuthentication no
set_sshd_option PubkeyAuthentication yes
set_sshd_option KbdInteractiveAuthentication no
set_sshd_option X11Forwarding no
set_sshd_option ClientAliveInterval 300
set_sshd_option ClientAliveCountMax 2
set_sshd_option MaxAuthTries 4

sshd -t
systemctl restart sshd

echo "==> Configuring fail2ban for SSH"
mkdir -p /etc/fail2ban/jail.d
cat > /etc/fail2ban/jail.d/sshd.local <<'FAIL2BAN'
[sshd]
enabled = true
port = ssh
backend = systemd
maxretry = 4
findtime = 10m
bantime = 1h
FAIL2BAN
systemctl enable --now fail2ban

echo "==> Configuring automatic security updates"
cat > /etc/dnf/automatic.conf <<'DNFAUTO'
[commands]
upgrade_type = security
random_sleep = 900
network_online_timeout = 60
download_updates = yes
apply_updates = yes

[emitters]
emit_via = stdio

[base]
debuglevel = 1
DNFAUTO
systemctl enable --now dnf-automatic.timer

echo "==> Preparing data drives (XFS, noatime)"
mkdir -p /mnt/minio
idx=1
for dev in $MINIO_DATA_DRIVES; do
  if [[ ! -b "$dev" ]]; then
    echo "Drive $dev not present. Aborting."
    exit 1
  fi
  if ! blkid "$dev" | grep -q 'TYPE="xfs"'; then
    mkfs.xfs -f -L "minio${idx}" "$dev"
  fi
  uuid="$(blkid -s UUID -o value "$dev")"
  mountpoint="/mnt/minio/disk${idx}"
  mkdir -p "$mountpoint"
  if ! grep -q "$uuid" /etc/fstab; then
    echo "UUID=${uuid}  ${mountpoint}  xfs  defaults,noatime,nofail  0  0" >> /etc/fstab
  fi
  mount "$mountpoint"
  idx=$((idx + 1))
done

echo "==> Creating minio-user"
if ! id minio-user >/dev/null 2>&1; then
  groupadd -r minio-user
  useradd -M -r -g minio-user -s /sbin/nologin minio-user
fi
chown -R minio-user:minio-user /mnt/minio

echo "==> Adding MinIO repository"
cat > /etc/yum.repos.d/minio.repo <<'MINIOREPO'
[minio-stable]
name=MinIO Stable Repository
baseurl=https://dl.min.io/server/minio/release/linux-amd64/
gpgcheck=0
enabled=1
MINIOREPO

dnf -y install minio mc || {
  echo "Falling back to direct RPM download"
  curl -fsSLo /tmp/minio.rpm https://dl.min.io/server/minio/release/linux-amd64/minio.rpm
  curl -fsSLo /usr/local/bin/mc https://dl.min.io/client/mc/release/linux-amd64/mc
  chmod +x /usr/local/bin/mc
  dnf -y install /tmp/minio.rpm
}

echo "==> Writing MinIO environment"
mkdir -p /etc/minio /etc/default
ROOT_USER="admin-$(openssl rand -hex 4)"
ROOT_PASS="$(openssl rand -base64 24 | tr -d '=+/')"

cat > /etc/default/minio <<MINIOENV
MINIO_VOLUMES="/mnt/minio/disk{1...4}"
MINIO_OPTS="--address :9000 --console-address 127.0.0.1:9001 --certs-dir /etc/minio/certs"
MINIO_ROOT_USER=${ROOT_USER}
MINIO_ROOT_PASSWORD=${ROOT_PASS}
MINIO_SERVER_URL=https://${MINIO_DOMAIN_API}
MINIO_BROWSER_REDIRECT_URL=https://${MINIO_DOMAIN_CONSOLE}
MINIOENV
chmod 640 /etc/default/minio
chown root:minio-user /etc/default/minio

echo "==> Setting systemd limits for MinIO"
mkdir -p /etc/systemd/system/minio.service.d
cat > /etc/systemd/system/minio.service.d/override.conf <<'MINIOLIM'
[Service]
LimitNOFILE=64000
MINIOLIM
systemctl daemon-reload

echo "==> Issuing Let's Encrypt certs"
dnf -y install certbot python3-certbot-nginx

cat > /etc/nginx/conf.d/minio.conf <<NGINXCONF
server {
    listen 80;
    server_name ${MINIO_DOMAIN_CONSOLE} ${MINIO_DOMAIN_API};
    location / { return 404; }
}
NGINXCONF
systemctl enable --now nginx
nginx -t && systemctl reload nginx

certbot certonly --nginx -n --agree-tos -m "${LE_EMAIL}" \
  -d "${MINIO_DOMAIN_CONSOLE}" -d "${MINIO_DOMAIN_API}"

mkdir -p /etc/minio/certs
cp -L /etc/letsencrypt/live/${MINIO_DOMAIN_API}/fullchain.pem /etc/minio/certs/public.crt
cp -L /etc/letsencrypt/live/${MINIO_DOMAIN_API}/privkey.pem /etc/minio/certs/private.key
chown -R minio-user:minio-user /etc/minio
chmod 640 /etc/minio/certs/private.key

cat > /etc/letsencrypt/renewal-hooks/deploy/minio-reload.sh <<'RENEW'
#!/usr/bin/env bash
cp -L /etc/letsencrypt/live/*/fullchain.pem /etc/minio/certs/public.crt
cp -L /etc/letsencrypt/live/*/privkey.pem /etc/minio/certs/private.key
chown minio-user:minio-user /etc/minio/certs/*
chmod 640 /etc/minio/certs/private.key
systemctl reload minio || true
systemctl reload nginx || true
RENEW
chmod +x /etc/letsencrypt/renewal-hooks/deploy/minio-reload.sh

echo "==> Writing nginx site for console (localhost-bound)"
cat > /etc/nginx/conf.d/minio.conf <<NGINXCONF
server {
    listen 80;
    server_name ${MINIO_DOMAIN_CONSOLE};
    return 301 https://\$host\$request_uri;
}

server {
    listen 443 ssl http2;
    server_name ${MINIO_DOMAIN_CONSOLE};

    ssl_certificate     /etc/letsencrypt/live/${MINIO_DOMAIN_API}/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/${MINIO_DOMAIN_API}/privkey.pem;

    add_header Strict-Transport-Security "max-age=31536000" always;

    client_max_body_size 0;
    proxy_buffering off;
    proxy_request_buffering off;

    location / {
        proxy_pass http://127.0.0.1:9001;
        proxy_set_header Host \$host;
        proxy_set_header X-Real-IP \$remote_addr;
        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto \$scheme;
        proxy_http_version 1.1;
        proxy_set_header Upgrade \$http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}
NGINXCONF

nginx -t && systemctl reload nginx

echo "==> Starting MinIO"
systemctl enable --now minio

echo "==> Waiting for MinIO API to listen on :9000"
for i in {1..30}; do
  if ss -lntp | grep -q ':9000'; then break; fi
  sleep 1
done

echo "==> Bootstrapping mc alias"
mkdir -p /root/.mc
mc alias set local "https://${MINIO_DOMAIN_API}" "${ROOT_USER}" "${ROOT_PASS}"

echo "==> Writing starter IAM policy"
cat > /root/app-readwrite.json <<'IAM'
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["s3:ListBucket", "s3:GetBucketLocation"],
      "Resource": ["arn:aws:s3:::app-data"]
    },
    {
      "Effect": "Allow",
      "Action": ["s3:GetObject", "s3:PutObject", "s3:DeleteObject"],
      "Resource": ["arn:aws:s3:::app-data/*"]
    }
  ]
}
IAM

mc admin policy create local app-readwrite /root/app-readwrite.json || true

echo
echo "========================================"
echo "DONE"
echo "========================================"
echo
echo "Services:"
systemctl is-active minio nginx chronyd fail2ban || true
echo
echo "Listeners:"
ss -lntp | grep -E ':(80|443|9000|9001)\b' || true
echo
echo "Drive health:"
mc admin info local || true
echo
echo "Console URL: https://${MINIO_DOMAIN_CONSOLE}"
echo "S3 API URL:  https://${MINIO_DOMAIN_API}"
echo "Root user:   ${ROOT_USER}"
echo "Root pass:   ${ROOT_PASS}"
echo
echo "Next: create a service user (mc admin user add local <name> <pass>),"
echo "attach the app-readwrite policy, and create the first bucket."

Make it executable and run it:

chmod 700 /root/setup-minio-almalinux9.sh
MINIO_DOMAIN_API=s3.example.com \
MINIO_DOMAIN_CONSOLE=minio.example.com \
LE_EMAIL=ops@example.com \
/root/setup-minio-almalinux9.sh

After it finishes, log in to the console with the printed root credentials, create a service user, attach the app-readwrite policy, and create the first bucket with mc mb local/app-data. The root credential is not for application use — it is for break-glass and for managing service users.

Run MinIO inside a Stack Harbor-managed environment with capacity alerting, scheduled mc admin heal, and quarterly restore drills: Managed Cloud Ops →.