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
- Mount CephFS Root: The Nextcloud server mounts the entire CephFS tree locally.
- Symlink Bridge: Subvolume paths (with UUIDs) are mapped to clean usernames (e.g.,
/mnt/ceph/student_001). - 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-commonAuthentication
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 0bash
sudo mkdir -p /mnt/ceph_students
sudo mount -a2.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>&13. Nextcloud Configuration
- Log in to Nextcloud as Admin.
- Enable External storage support in Apps.
- Go to Administration -> External Storage.
- Add a new Local storage mount:
- Folder Name: Lab Storage
- Configuration:
/mnt/student_links/$user - Available for:
Studentsgroup
Dynamic Paths
The $user variable automatically maps the logged-in Nextcloud username to the corresponding directory in /mnt/student_links/.
4. Verification
- Log in as
student_001. - Locate the Lab Storage folder.
- Upload a file; it now physically resides on the Ceph cluster with a 10GB quota enforced.