Ubuntu 16.04 - Using Files To Test ZFS

It's good to practice using a tool before actually "going live" with it. Sometimes we don't have disks/computers lying around to be able to set up a dev ZFS RAID array to experiment with, so this tutorial is simply here to show you how to get started with ZFS using files to act as virtual disks.

Don't use this for anything other than testing/playing.


Install ZFS if you haven't already.

sudo apt update
sudo apt install zfsutils-linux -y
sudo modprobe zfs

Now lets create our fake disks, which we will build our ZFS pool out of. These will be sparse files that can grow up to 10G each. If you need to create a RAIDz, then go ahead and add at least one more file to the list.

truncate --size 10G disk1.img disk2.img

Now create the pool out of your disks.

sudo zpool create pool1 \
`pwd`/disk1.img \

If that was successful, you should be able to execute the following command:

sudo zpool list

and get the following output...

pool1  19.9G  68.5K  19.9G         -     0%     0%  1.00x  ONLINE  -  

Now use the ZFS cheatsheet to play your pool in any way that you see fit, such as creating datasets, snapshots, etc.

When you are done testing, delete your datasets and pool with:

sudo zfs destroy -r pool1
sudo zpool destroy pool1




Stuart is a software developer with a passion for Linux and open source projects.

comments powered by Disqus
We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites. More info.