Usage Instructions
(1) Save the Script
Save the script above as: zfs-recovery-tool.sh
Then make it executable: chmod +x zfs-recovery-tool.sh
(2) Run Interactively (Recommended)
Run it from the Live USB or single-user mode:
sudo ./zfs-recovery-tool.sh
This will show a menu:
GhostBSD ZFS Recovery Toolkit
==============================
0) Reset root password
1) Rename pool before reinstall
2) Reimport preserved pool
3) Backup datasets to external disk
4) Restore datasets from backup
5) Exit
(3) Run with Command-Line Options
You can use it non-interactively:
sudo ./zfs-recovery-tool.sh --reset-password
sudo ./zfs-recovery-tool.sh --rename-pool
sudo ./zfs-recovery-tool.sh --backup
sudo ./zfs-recovery-tool.sh --restore
(4) Create a Snapshot Before Backup
Before using the backup feature, run: zfs snapshot -r zroot@preinstall
(5) Mount External Backup Disk
Make sure your disk is mounted at /mnt/backup
:
sudo mkdir -p /mnt/backup
sudo mount /dev/da1s1 /mnt/backup
Replace /dev/da1s1
with the correct device name.
(6) View Logs
All operations are logged to: /tmp/zfs-recovery.log
You can view it with: less /tmp/zfs-recovery.log
Summary
- Use Option 0 for forgotten password recovery
- Use Option 1 to protect existing datasets during reinstall
- Use Option 2 to reimport a preserved pool
- Use Option 3 to export data to external disk
- Use Option 4 to restore data to a fresh GhostBSD install