Skip to content

Nextcloud Integration

Integrating CephFS with Nextcloud provides a "Dropbox-like" experience for students. We use the External Storage app to map Nextcloud accounts to specific CephFS subvolumes.

1. Architecture

  1. Mount CephFS Root: The Nextcloud server mounts the entire CephFS tree locally.
  2. Symlink Bridge: Subvolume paths (with UUIDs) are mapped to clean usernames (e.g., /mnt/ceph/student_001).
  3. Nextcloud External Storage: Nextcloud is configured to look at /mnt/ceph/$user.

2. Server Setup

2.1 Mount CephFS

On the Nextcloud server:

bash
# Install dependencies
sudo apt install ceph-common

Authentication

Create a dedicated keyring for the Nextcloud server with access to the /volumes/students path.

fstab Configuration (Persistent):

text
# /etc/fstab
192.168.202.221,192.168.202.222:/volumes/students /mnt/ceph_students ceph name=nextcloud,secretfile=/etc/ceph/nextcloud.key,noatime,_netdev 0 0
bash
sudo mkdir -p /mnt/ceph_students
sudo mount -a

2.2 The "Linker" Script

Ceph subvolumes use complex paths like /volumes/students/student_001/uuid-string. This script creates predictable symlinks for Nextcloud.

bash
#!/bin/bash
# /usr/local/bin/nextcloud_linker.sh
CEPH_MOUNT="/mnt/ceph_students"
CLEAN_DIR="/mnt/student_links"

mkdir -p "$CLEAN_DIR"

for user_dir in "$CEPH_MOUNT"/*; do
    [ -d "$user_dir" ] || continue
    username=$(basename "$user_dir")
    # Find the UUID folder inside
    uuid_path=$(find "$user_dir" -mindepth 1 -maxdepth 1 -type d | head -n 1)

    if [ -n "$uuid_path" ]; then
        # Create/Update symlink
        ln -sfn "$uuid_path" "$CLEAN_DIR/$username"
    fi
done

# Set permissions for Nextcloud (www-data)
chown -h -R www-data:www-data "$CLEAN_DIR"

Automation

Run this script via Cron every minute to automatically link new students.

bash
* * * * * /usr/local/bin/nextcloud_linker.sh >> /var/log/nc_linker.log 2>&1

3. Nextcloud Configuration

  1. Log in to Nextcloud as Admin.
  2. Enable External storage support in Apps.
  3. Go to Administration -> External Storage.
  4. Add a new Local storage mount:
    • Folder Name: Lab Storage
    • Configuration: /mnt/student_links/$user
    • Available for: Students group

Dynamic Paths

The $user variable automatically maps the logged-in Nextcloud username to the corresponding directory in /mnt/student_links/.

4. Verification

  1. Log in as student_001.
  2. Locate the Lab Storage folder.
  3. Upload a file; it now physically resides on the Ceph cluster with a 10GB quota enforced.