12

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.

alanc
  • 1,500
  • 9
  • 12
Jasmine Lognnes
  • 2,520
  • 8
  • 33
  • 51

2 Answers2

26

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
jlliagre
  • 8,861
  • 18
  • 36
5

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.

Mark Wagner
  • 18,019
  • 2
  • 32
  • 47
  • The two last steps should be exchangeable as long as you don't instruct `losetup` to mount starting at a given offset. I.e. as long as you use the full file as the block device. – 0xC0000022L Nov 05 '18 at 09:44
  • Can this be used to bypass the "Cannot resolve path" error I get if the file is on a network filesystem instead of local? – Michael Jul 23 '20 at 20:40