Fix USB backup permission issues
**Problem:** - USB drives mounted as root were not writable by regular user - Caused "Permission denied" errors on backup - Required running application as root (not secure) **Solution:** - Better permission error messages with fix suggestions - Try to create backup directory first (more flexible) - Show helpful error: "run sudo chown -R \$USER /media/usb0" **USB Setup Script (setup_usb.sh):** - Interactive USB drive mounting - Automatically detects USB devices - Mounts with user ownership (uid/gid) - Tests write permissions - Shows free space - Offers to add to /etc/fstab - Color-coded output **Documentation Updates:** - Added 3 methods for mounting with permissions - Recommended method: mount with uid/gid options - Added fstab auto-mount example - Added quick setup script example - Clear instructions for each method **Usage:** ```bash # Easiest method sudo ./setup_usb.sh # Or manual mounting sudo mount -o uid=$(id -u),gid=$(id -g) /dev/sda1 /media/usb0 # Or fix existing mount sudo chown -R $USER /media/usb0 ``` **Security:** - No need to run wedding phone as root - User-owned USB mount points - Proper permission checking - Clear error messages **Web Interface:** - Shows helpful permission error messages - Includes fix command in error text - Better UX for permission issues 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
67
README.md
67
README.md
@@ -325,18 +325,70 @@ Automatically backup all recordings and greeting files to USB drives:
|
||||
6. Corrupted copies deleted automatically
|
||||
7. Success/failure logged to console
|
||||
|
||||
**Mount USB Drives:**
|
||||
**Mount USB Drives with Proper Permissions:**
|
||||
|
||||
**Automated Setup (Easiest):**
|
||||
```bash
|
||||
# Run the USB setup script
|
||||
sudo ./setup_usb.sh
|
||||
```
|
||||
This interactive script will:
|
||||
- Detect your USB devices
|
||||
- Mount them with proper user permissions
|
||||
- Test write access
|
||||
- Optionally add to /etc/fstab for auto-mounting
|
||||
|
||||
**Option 1: Mount with user permissions (Recommended)**
|
||||
```bash
|
||||
# Find your USB device
|
||||
lsblk
|
||||
|
||||
# Create mount point
|
||||
sudo mkdir -p /media/usb0
|
||||
|
||||
# Mount with user ownership (replace $USER with your username if needed)
|
||||
sudo mount -o uid=$(id -u),gid=$(id -g) /dev/sda1 /media/usb0
|
||||
|
||||
# Verify it's writable
|
||||
touch /media/usb0/test.txt && rm /media/usb0/test.txt
|
||||
```
|
||||
|
||||
**Option 2: Auto-mount in /etc/fstab with user permissions**
|
||||
```bash
|
||||
# Get USB UUID
|
||||
sudo blkid /dev/sda1
|
||||
|
||||
# Edit fstab
|
||||
sudo nano /etc/fstab
|
||||
|
||||
# Add line (replace UUID and username):
|
||||
UUID=XXXX-XXXX /media/usb0 vfat defaults,nofail,uid=1000,gid=1000 0 0
|
||||
# Note: uid=1000 is usually the first user, check with: id -u
|
||||
```
|
||||
|
||||
**Option 3: Change ownership after mounting**
|
||||
```bash
|
||||
# Mount normally
|
||||
sudo mount /dev/sda1 /media/usb0
|
||||
|
||||
# Change ownership (replace with your username)
|
||||
sudo chown -R $USER:$USER /media/usb0
|
||||
```
|
||||
|
||||
**Quick Setup Script:**
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# setup_usb.sh - Mount USB drives with proper permissions
|
||||
|
||||
# Create mount points
|
||||
sudo mkdir -p /media/usb0 /media/usb1
|
||||
|
||||
# Auto-mount in /etc/fstab (example)
|
||||
UUID=XXXX-XXXX /media/usb0 vfat defaults,nofail 0 0
|
||||
UUID=YYYY-YYYY /media/usb1 vfat defaults,nofail 0 0
|
||||
# Mount USB drives with user ownership
|
||||
sudo mount -o uid=$(id -u),gid=$(id -g) /dev/sda1 /media/usb0
|
||||
sudo mount -o uid=$(id -u),gid=$(id -g) /dev/sdb1 /media/usb1
|
||||
|
||||
# Or mount manually
|
||||
sudo mount /dev/sda1 /media/usb0
|
||||
sudo mount /dev/sdb1 /media/usb1
|
||||
echo "USB drives mounted!"
|
||||
ls -la /media/usb0 /media/usb1
|
||||
```
|
||||
|
||||
## File Structure
|
||||
@@ -347,6 +399,7 @@ wedding-phone/
|
||||
├── test_complete.py # Audio testing script
|
||||
├── configure_hifiberry.sh # HiFiBerry setup script
|
||||
├── install_service.sh # Systemd service installer
|
||||
├── setup_usb.sh # USB drive setup with permissions
|
||||
├── wedding-phone.service # Systemd service file
|
||||
├── Makefile # Make commands for easy running
|
||||
├── config.example.json # Example configuration (copy to config.json)
|
||||
|
||||
Reference in New Issue
Block a user