diff --git a/README.md b/README.md index 13f41c5..6234673 100644 --- a/README.md +++ b/README.md @@ -97,22 +97,91 @@ A lightweight Linux VM running permanently on Proxmox, pre-configured to access - No dependency on internet connectivity - Keeps file ownership intact when writing to the NFS share +### Recommended OS — Alpine Linux + +Alpine Linux is the ideal choice for a permanently-running, lightweight emergency VM. It's the same base image used by many Docker containers, and its footprint is minimal: + +- Base install is around **130MB** of disk space +- RAM usage at idle is typically **50-100MB** +- Uses **musl libc** and **busybox** instead of heavier GNU equivalents +- Uses **OpenRC** instead of systemd +- Package manager (`apk`) is fast and simple + +### LXC Container vs Full VM + +Since everything is on Proxmox, Alpine works particularly well as an **LXC container** rather than a full VM, reducing overhead even further: + +| | LXC Container | Full VM | +|---|---|---| +| RAM at idle | ~20-30MB | ~100MB+ | +| Disk footprint | Minimal | Larger | +| Boot time | Seconds | 10-30 seconds | +| NFS support | Yes, with minor config | Yes, standard | +| SSH access | Identical | Identical | +| Proxmox snapshots | Very fast | Slightly slower | + +> **Note:** Use a **privileged** LXC container for NFS mounts — unprivileged containers can have issues mounting NFS shares. + +Proxmox has Alpine available as a built-in LXC template (Datacenter → Node → local storage → CT Templates). + +### Proxmox LXC Suggested Specs + +- **RAM:** 512MB (it will rarely use more than 50MB, but this gives headroom) +- **Disk:** 4GB (more than sufficient) +- **Privileged container:** Yes (required for NFS) + +### Alpine Package Installation + +```bash +apk update && apk upgrade + +apk add nfs-utils # NFS client support +apk add rsync # File transfers +apk add openssh # SSH server +apk add tmux # Terminal multiplexer +apk add mc # Midnight Commander +apk add shadow # Needed for usermod on Alpine +``` + +Total footprint including all packages will remain well under 300MB. + +### Alpine-Specific Configuration + +**Enable and start NFS services:** +```bash +rc-update add rpcbind +rc-update add nfsmount +rc-service rpcbind start +rc-service nfsmount start +``` + +**Enable SSH:** +```bash +ssh-keygen -A +rc-update add sshd +rc-service sshd start +``` + +**Note:** Alpine uses `ash` (via busybox) as its default shell rather than `bash`. The startup scripts in this guide use `#!/bin/ash` accordingly. If you prefer bash, install it with: +```bash +apk add bash +``` + ### VM Setup Checklist -1. Install a minimal Debian/Ubuntu server (no desktop environment required) -2. Set the local user's UID to match `www-data` on the Nextcloud server (UID 33): +1. Create Alpine LXC container in Proxmox using the built-in template +2. Install required packages (see above) +3. Set the local user's UID to match `www-data` on the Nextcloud server (UID 33): ```bash - sudo usermod -u 33 your-username + usermod -u 33 your-username ``` -3. Install required tools: - ```bash - sudo apt install nfs-common rsync mc tmux openssh-server - ``` -4. Add the NFS mount to `/etc/fstab`: +4. Configure NFS services (see above) +5. Add the NFS mount to `/etc/fstab`: ``` nas-server:/share /mnt/nextcloud nfs _netdev,auto 0 0 ``` -5. Take a Proxmox snapshot of the VM once configured, so you can roll back if something goes wrong during an emergency file operation. +6. Enable and start SSH (see above) +7. Take a Proxmox snapshot once configured, so you can roll back if something goes wrong during an emergency file operation. --- @@ -149,7 +218,7 @@ mc also has a built-in SFTP client (F9 → Left/Right → SFTP link), allowing y ### tmux — Terminal Multiplexer -tmux provides persistent terminal sessions and split-pane layouts, mimicking the two-panel feel of Midnight Commander while adding session resilience. +tmux provides persistent terminal sessions and split-pane layouts. Rather than using tmux alone to display directory listings (which are static and don't update automatically), the recommended approach is to run **mc inside tmux** — giving you live-updating two-panel file browsing alongside a persistent shell pane for rsync and other commands. #### Key Benefit If your SSH connection drops during a large file transfer, the tmux session keeps running. Reconnect and reattach with: @@ -170,25 +239,45 @@ tmux attach -t emergency | `Ctrl+b [` | Scroll mode | | `Ctrl+b d` | Detach (session keeps running) | +#### Why Not tmux Panes Alone? + +A tmux layout using `ls` or `watch ls` in each pane was considered but has drawbacks: + +- `ls` is a one-shot command — it doesn't update as files change +- `watch ls` updates automatically but locks the pane, requiring `Ctrl+C` before you can interact with it + +mc running in a tmux pane gives live directory updates and full interactivity, making it the better solution. + +#### Combined tmux + mc Layout + +``` +┌──────────────────────────────────────┐ +│ mc (two-panel, full width) │ +│ ~/staging │ /mnt/nextcloud │ +│ (live) │ (live) │ +│ │ │ +├──────────────────────────────────────┤ +│ Shell pane — rsync / occ commands │ +└──────────────────────────────────────┘ +``` + +mc accepts two path arguments (left panel and right panel), so it opens directly with your staging area and NFS mount side by side, both updating live. + #### Emergency Session Startup Script Save as `~/emergency-session.sh` on the VM: ```bash -#!/bin/bash +#!/bin/ash tmux new-session -d -s emergency -x 220 -y 50 -# Left pane - staging area -tmux send-keys -t emergency 'cd /home/user/staging && ls -lah' Enter +# Top pane - mc with staging area on left, NFS mount on right +tmux send-keys -t emergency 'mc /home/user/staging /mnt/nextcloud' Enter -# Right pane - NFS mount -tmux split-window -h -t emergency -tmux send-keys -t emergency 'cd /mnt/nextcloud && ls -lah' Enter - -# Bottom pane - command input +# Bottom pane - shell for rsync and other commands tmux split-window -v -t emergency -tmux resize-pane -t emergency -y 10 -tmux send-keys -t emergency 'echo "Ready for commands"' Enter +tmux resize-pane -t emergency -y 8 +tmux send-keys -t emergency 'echo "Command pane ready"' Enter tmux attach -t emergency ``` @@ -197,18 +286,6 @@ tmux attach -t emergency chmod +x ~/emergency-session.sh ``` -This creates the following layout: - -``` -┌──────────────────┬──────────────────┐ -│ ~/staging │ /mnt/nextcloud │ -│ │ │ -│ │ │ -├──────────────────┴──────────────────┤ -│ Command pane (rsync / scp) │ -└─────────────────────────────────────┘ -``` - --- ## Part 4 — Transferring Files with rsync