0

Is there a proper way of writing a ZFS dataset, in my case which is an ext4 ubuntu filesystem, to a blank SSD? The data looks like this is that's at all helpful

tank/filesystems/ubuntu_1604/(/etc, /boot, /var, and so on)
tank/filesystems/centos_7/(/etc, /boot /var, and so on)

I was thinking maybe I could just do an exact bit copy with dd, but I don't know how that would work with ZFS's duplication.

dd if=/filesystems/ubuntu_1604/ of=/dev/sdb bs=1m

Has anyone ever done this?

Brando__
  • 412
  • 1
  • 3
  • 11
  • Is that a zvol or a file system? Big difference here. And do you want the resultant SSD to have a ZFS pool, or some other file system? – user Jun 07 '17 at 09:04
  • I ended up finding an alternative to what I was trying to do in the above question. But to answer your question, the resultant SSD /dev/sdb was intended to be an ext4 root file system. The tank zpool you see above is a file system that is mounted at /filesystems (on the host machine's ext4 root) – Brando__ Jun 08 '17 at 00:00
  • Care to share what you did? I was going to reply and suggest that when you want to copy/store the data in the ZFS context, you should use ZFS send/receive. If you want to maintain it in the context of a set of files that are independent of the filesystem, I'd suggest rsync. If you want to store and potentially recreate the low-level block devices, that's a job for dd. – ljwobker Dec 27 '17 at 16:55
  • I'm the horrible person who says "I fixed it" without saying what I did. I don't even remember what I was trying to accomplish anymore. I'm terribly sorry – Brando__ Jan 01 '18 at 08:18

1 Answers1

1

Create a snapshot of your dataset and use zfs send to write its content to your device. There might be an issue with the garbage that would follow the actual data when reading it though. In such case, you need to record the size of the data stream to limit the read to the payload.

Unless you want to write the whole pool, dd is unsuitable for two reasons:

  • You need to have the pool exported to use dd otherwise the output would be unusable. You have no access to individual datasets with an exported zpool.

  • Zpools are stored in devices (disks, partitions...) but datasets are stored in a shared zpools. There is no one to one relationship between a dataset and the underlyin devices.

jlliagre
  • 8,861
  • 18
  • 36
  • I've only ever used zfs send to copy to other zfs file systems. This will work to just whatever block storage device I attach? – Brando__ Jun 06 '17 at 07:26
  • 1
    You recreate the dataset when you run `zfs receive` but you can just store the data stream to a file or a raw device. In the latter case, there might be an issue with the garbage that would follow the actual data when reading it though. In such case, you need to record the size of the data stream to limit the read to the payload. – jlliagre Jun 06 '17 at 07:54