Solaris tip of the week: file-based ZFS for development and test environments
Have you ever wanted to experiment with zfs, but didn't have a storage
array on hand?
No worries - use files instead of disks to build your zfs test
configuration.
With this approach, you can construct complex zfs configurations consisting of large numbers of 'pseudo-disks' to test a zfs configuration, recovery scenario, hot sparing, or to familiarize yourself with the zfs feature set - file system creation, snapshots, clones ...
zfs storage pools can be constructed from whole disks, disk slices, or individual files. Use files (created using the 'mkfile' command) to build your zfs mirror, raidz or raidz2 test configurations.
For example, to create a zfs mirror using files instead of devices:
- Create two 100 megabyte files
# (cd /export; mkfile 100m file1 file2)
- Add the files to a zfs pool as a mirrored pair
# zpool create mymirror mirror /export/file1 /export/file2
Similarly for raidz
# (cd /export; mkfile 100m raidz1 raidz2 raidz3)
# zpool create myraidz raidz /export/raidz1 /export/raidz2 /export/raidz3
And raidz2
# (cd /export; mkfile 100m raidz21 raidz22 raidz23 raidz24)
# zpool create myraidz2 raidz2 /export/raidz21 /export/raidz22 /export/raidz23 /export/raidz24
Add a hot spare to raidz2:
# mkfile 100m /export/hotspare
# zpool add myraidz2 spare /export/hotspare
Display your pools
# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
mymirror 95.5M 111K 95.4M 0% ONLINE -
myraidz 286M 155K 286M 0% ONLINE -
myraidz2 382M 288K 382M 0% ONLINE -
Enjoy experimenting with zfs !
With this approach, you can construct complex zfs configurations consisting of large numbers of 'pseudo-disks' to test a zfs configuration, recovery scenario, hot sparing, or to familiarize yourself with the zfs feature set - file system creation, snapshots, clones ...
zfs storage pools can be constructed from whole disks, disk slices, or individual files. Use files (created using the 'mkfile' command) to build your zfs mirror, raidz or raidz2 test configurations.
For example, to create a zfs mirror using files instead of devices:
- Create two 100 megabyte files
# (cd /export; mkfile 100m file1 file2)
- Add the files to a zfs pool as a mirrored pair
# zpool create mymirror mirror /export/file1 /export/file2
Similarly for raidz
# (cd /export; mkfile 100m raidz1 raidz2 raidz3)
# zpool create myraidz raidz /export/raidz1 /export/raidz2 /export/raidz3
And raidz2
# (cd /export; mkfile 100m raidz21 raidz22 raidz23 raidz24)
# zpool create myraidz2 raidz2 /export/raidz21 /export/raidz22 /export/raidz23 /export/raidz24
Add a hot spare to raidz2:
# mkfile 100m /export/hotspare
# zpool add myraidz2 spare /export/hotspare
Display your pools
# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
mymirror 95.5M 111K 95.4M 0% ONLINE -
myraidz 286M 155K 286M 0% ONLINE -
myraidz2 382M 288K 382M 0% ONLINE -
Enjoy experimenting with zfs !