How to use a file as a zpool?

If I do

dd if=/dev/zero of=/tank/test/zpool bs=1M count=100

how can I treat the file /tank/test/zpool as a vdev, so I can use it as a zpool?

It is for zfs testing purposes only.


Solution 1:

There is no need to create a loop device, you can simply use the file itself as a vdev:

zpool create test /tank/test/zpool

Solution 2:

Create a loop device backed by the file.

dd if=/dev/zero of=/tmp/foo bs=1M count=128
losetup /dev/loop0 /tmp/foo
zpool create tank /dev/loop0

(The minimum disk size of 128 MB.)

Oops, didn't notice the Solaris tag. My instructions were for Linux. Instead of losetup you can use lofiadm under Solaris.