mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 04:30:13 -08:00
feat: Add NAS mount check and setup script for improved backup reliability
This commit is contained in:
161
docs/nas-mount-setup-guide.md
Normal file
161
docs/nas-mount-setup-guide.md
Normal file
@@ -0,0 +1,161 @@
|
||||
# NAS Mount Setup Guide for Fedora 42
|
||||
|
||||
## Quick Setup Instructions
|
||||
|
||||
Your NAS IP: `192.168.68.51`
|
||||
Mount Point: `/mnt/share/media`
|
||||
|
||||
### Prerequisites (Already Installed)
|
||||
- `cifs-utils` - for SMB/CIFS mounting
|
||||
- `nfs-utils` - for NFS mounting
|
||||
|
||||
### Option 1: Automated Setup (Recommended)
|
||||
|
||||
Run the interactive setup script:
|
||||
```bash
|
||||
./setup-nas-mount.sh
|
||||
```
|
||||
|
||||
This script will:
|
||||
- Test both SMB and NFS connectivity
|
||||
- Guide you through the setup process
|
||||
- Create persistent mount configuration
|
||||
- Set up systemd mount units for reliable boot mounting
|
||||
|
||||
### Option 2: Manual SMB/CIFS Setup
|
||||
|
||||
1. **Test SMB shares first:**
|
||||
```bash
|
||||
# List available shares (you'll need NAS credentials)
|
||||
smbclient -L 192.168.68.51 -U your_username
|
||||
```
|
||||
|
||||
2. **Create credentials file (if using authentication):**
|
||||
```bash
|
||||
sudo tee /etc/nas-credentials << EOF
|
||||
username=your_nas_username
|
||||
password=your_nas_password
|
||||
domain=WORKGROUP
|
||||
EOF
|
||||
sudo chmod 600 /etc/nas-credentials
|
||||
```
|
||||
|
||||
3. **Test mount:**
|
||||
```bash
|
||||
# With credentials
|
||||
sudo mount -t cifs //192.168.68.51/share_name /mnt/share/media -o credentials=/etc/nas-credentials,uid=$(id -u),gid=$(id -g),iocharset=utf8
|
||||
|
||||
# Or for guest access
|
||||
sudo mount -t cifs //192.168.68.51/share_name /mnt/share/media -o guest,uid=$(id -u),gid=$(id -g),iocharset=utf8
|
||||
```
|
||||
|
||||
4. **Add to /etc/fstab for persistence:**
|
||||
```bash
|
||||
# Backup fstab first
|
||||
sudo cp /etc/fstab /etc/fstab.backup
|
||||
|
||||
# Add entry (with credentials)
|
||||
echo "//192.168.68.51/share_name /mnt/share/media cifs credentials=/etc/nas-credentials,uid=$(id -u),gid=$(id -g),iocharset=utf8,noauto,user 0 0" | sudo tee -a /etc/fstab
|
||||
|
||||
# Or for guest access
|
||||
echo "//192.168.68.51/share_name /mnt/share/media cifs guest,uid=$(id -u),gid=$(id -g),iocharset=utf8,noauto,user 0 0" | sudo tee -a /etc/fstab
|
||||
```
|
||||
|
||||
### Option 3: Manual NFS Setup
|
||||
|
||||
1. **Check available NFS exports:**
|
||||
```bash
|
||||
showmount -e 192.168.68.51
|
||||
```
|
||||
|
||||
2. **Test mount:**
|
||||
```bash
|
||||
sudo mount -t nfs 192.168.68.51:/path/to/export /mnt/share/media -o rw,hard,intr
|
||||
```
|
||||
|
||||
3. **Add to /etc/fstab:**
|
||||
```bash
|
||||
echo "192.168.68.51:/path/to/export /mnt/share/media nfs rw,hard,intr,rsize=8192,wsize=8192,timeo=14,noauto,user 0 0" | sudo tee -a /etc/fstab
|
||||
```
|
||||
|
||||
### Systemd Mount Unit (For Reliable Boot Mounting)
|
||||
|
||||
Create `/etc/systemd/system/mnt-share-media.mount`:
|
||||
|
||||
```ini
|
||||
[Unit]
|
||||
Description=Mount NAS Media Share
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Mount]
|
||||
What=//192.168.68.51/share_name
|
||||
Where=/mnt/share/media
|
||||
Type=cifs
|
||||
Options=credentials=/etc/nas-credentials,uid=1000,gid=1000,iocharset=utf8
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
Enable it:
|
||||
```bash
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable mnt-share-media.mount
|
||||
sudo systemctl start mnt-share-media.mount
|
||||
```
|
||||
|
||||
### Common Commands
|
||||
|
||||
- **Mount manually:** `sudo mount /mnt/share/media`
|
||||
- **Unmount:** `sudo umount /mnt/share/media`
|
||||
- **Check mount status:** `df -h /mnt/share/media`
|
||||
- **Test systemd mount:** `sudo systemctl start mnt-share-media.mount`
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
1. **Check connectivity:**
|
||||
```bash
|
||||
ping 192.168.68.51
|
||||
```
|
||||
|
||||
2. **Test SMB connection:**
|
||||
```bash
|
||||
nc -zv 192.168.68.51 445
|
||||
```
|
||||
|
||||
3. **Test NFS connection:**
|
||||
```bash
|
||||
nc -zv 192.168.68.51 2049
|
||||
```
|
||||
|
||||
4. **Check mount logs:**
|
||||
```bash
|
||||
journalctl -u mnt-share-media.mount
|
||||
```
|
||||
|
||||
5. **Verify fstab syntax:**
|
||||
```bash
|
||||
sudo mount -a
|
||||
```
|
||||
|
||||
### Security Notes
|
||||
|
||||
- Credentials file should have 600 permissions (readable only by root)
|
||||
- Consider using NFS over SMB for better performance on Linux
|
||||
- Use `noauto` in fstab to prevent boot delays if NAS is unavailable
|
||||
- The `user` option allows regular users to mount/unmount
|
||||
|
||||
### Integration with Your Backup Scripts
|
||||
|
||||
Your `backup-media.sh` script already references `/mnt/share/media/backups`, so once the NAS is mounted, your backups will automatically work with the NAS storage.
|
||||
|
||||
Make sure your backup script has proper error handling for when the NAS is not mounted:
|
||||
|
||||
```bash
|
||||
# Add this check to your backup scripts
|
||||
if ! mountpoint -q /mnt/share/media; then
|
||||
log_error "NAS not mounted at /mnt/share/media"
|
||||
exit 1
|
||||
fi
|
||||
```
|
||||
Reference in New Issue
Block a user