Overview
At some point you may need to move your ZFS pool between systems. Or perhaps you want to do a clean install of your operating system, but preserving your ZFS pool. To do this, you need to take steps to ensure the new or upgraded system recognises your existing ZFS pool.
This article will show you how to use the command line to safely move your ZFS pool.
The following assumptions are made regarding your setup:-
- Your computer or server has ZFS on Linux installed.
- You have an existing ZFS pool you would like to use on a new or upgraded system.
Backup your data!!
Please make sure you have a full backup of your data before moving your ZFS pool.
This article is a useful guide, but we cannot take any responsibility if anything goes wrong.
Check the ZFS pool status
Let's check the status of the ZFS pool.
sudo zpool status
pool: DUMPSTER
state: ONLINE
scan: none requested
config:
NAME STATE READ WRITE CKSUM
DUMPSTER ONLINE 0 0 0
raidz1-0 ONLINE 0 0 0
sdb ONLINE 0 0 0
sdc ONLINE 0 0 0
sdd ONLINE 0 0 0
sde ONLINE 0 0 0
sdf ONLINE 0 0 0
sdg ONLINE 0 0 0
errors: No known data errors
Any identified issues should be corrected before continuing.
Save the ZFS pool configuration
We need to save the configuration details of our ZFS pool to a some files for future reference.
sudo zpool status > zpool_status.txt
sudo zfs list -o all > zfs_list.txt
sudo zdb > zdb.txt
Just in case...
Make sure these configuration files are stored outside of the ZFS pool.
Export the ZFS pool
We need to unmount all filesystems in the ZFS pool, write any cache data to disk and make the pool unavailable for use on the current system.
We do this by exporting the ZFS pool. Make sure you replace DUMPSTER with the name of your ZFS pool.
sudo zpool export DUMPSTER
The pool 'DUMPSTER' has been exported. All associated filesystems have been unmounted.
If the pool will not export, check that no users or devices are connected to the pool and try again.
Prepare your new system
You can now power down your server and disconnect your physical ZFS hard drives.
Once disconnected, you can safely move the drives to your new system or upgrade your current system.
Import the ZFS pool
Connect all your ZFS drives to your new or upgraded system and ensure ZFS on Linux is installed.
List available ZFS pools
We now need to scan all drives for ZFS pool signatures.
The following command does not actually start an import. It only lists available ZFS pools.
sudo zpool import
pool: DUMPSTER
id: 1234567890987654321
state: ONLINE
action: The pool can be imported using its name or numeric identifier.
config:
NAME STATE READ WRITE CKSUM
DUMPSTER ONLINE 0 0 0
raidz1-0 ONLINE 0 0 0
sdb ONLINE 0 0 0
sdc ONLINE 0 0 0
sdd ONLINE 0 0 0
sde ONLINE 0 0 0
sdf ONLINE 0 0 0
sdg ONLINE 0 0 0
Mount the ZFS pool
We can now mount all filesystems and make the ZFS pool available.
The -d /dev/disk/by-id option ensures the imported drives are listed by their serial ids, making it much easier to identify problem drives in the future.
sudo zpool import -d /dev/disk/by-id DUMPSTER
The pool 'DUMPSTER' is imported and available. All filesystems under this are now mounted.
Check that it has worked
sudo zpool status
pool: DUMPSTER
state: ONLINE
scan: none requested
config:
NAME STATE READ WRITE CKSUM
DUMPSTER ONLINE 0 0 0
raidz1-0 ONLINE 0 0 0
ata-WD-W12345678 ONLINE 0 0 0
ata-WD-W09876543 ONLINE 0 0 0
ata-WD-W67543213 ONLINE 0 0 0
ata-WD-W99123545 ONLINE 0 0 0
ata-WD-W65432987 ONLINE 0 0 0
ata-WD-W76725635 ONLINE 0 0 0
errors: No known data errors
The ZFS pool should be mounted and online.