ZFSonUSB is a shell script that helps you import and export a ZFS pool that resides on external disks
Note that when you export (unmount) your ZFS pool, zfsonusb
will also power-off the disks so that you can safely unplug your USB cable from your PC.
The most important thing, is to have already created the pool using the name of the attached /dev/disk/by-id/
USB external Disks. So instead of using the common name of the partition e.g. sda1
, you should refer to your pool with the name which contains the serial number of the drive. This serial number will not change no matter what machine the drive is connected to and it will always be the same as the serial number on the paper label affixed to the drive.
To install ZFSonUSB, just run the following commands in a terminal
# Move you prompt to your home folder
$ cd
# Clone this repository
$ git clone https://github.com/synergops/.zfsonusb.git
# Copy the conf file to your home folder
$ cp .zfsonusb/.zfsonusb.conf .
$ cp .zfsonusb/.rsync-home-excludes.txt .
# Copy the executable in to your system binaries
$ sudo cp .zfsonusb/zfsonusb /usr/bin/zfsonusb
After the installation you can use it in terminal
zfsonusb {import|export|list|backup|help}
Options:
import : Import the ZFS pool and mount datasets
export : Unmount the ZFS pool and power off external disks
list : List available disks in /dev/disk/by-id
backup : Backup your home folder to the ZFS pool
help : Show this help message
Once you install it, you need to initialize the conf
with the appropriate settings
Steps to use the script for the first time:
-
List available disks in
/dev/disk/by-id
:zfsonusb list
-
After identifying the disks, edit the
.zfsonusb.conf
file to include under the DISKS array the disk paths that correspond to the pool you have previously created.Example
.zfsonusb.conf
:ZFS_POOL_NAME="zones" DISKS=( "/dev/disk/by-id/usb-ST9XXXXXXXXXXX-0:0-part1" "/dev/disk/by-id/usb-TOSHIBA_XXXXXXXXXXXXX-0:1-part1" )
Set the
BACKUP_SOURCE
andBACKUP_DESTINATION
in the.zfsonusb.conf
file to the desired values.Edit the
.rsync-home-excludes.txt
file to exclude the files and directories that you do not want to backup. All lines starting with a # are ignored by rsync, i.e. those directories will be backed up. The syntax doesn't support comments at the end of a line yet. At the start there is a section with directories that are probably not worth backing up. Uncomment those lines to exclude them as well. -
After configuring the
.zfsonusb.conf
file, you can:- Import your ZFS pool:
zfsonusb import
- Backup your home folder to the ZFS pool:
zfsonusb backup
- Export your ZFS pool and power off disks:
zfsonusb export
- Import your ZFS pool:
If you have found this tool useful and saved you time, any donations are welcomed: