ZFS Can ZFS disks be cloned with dd?

blackhaz

Active Member

Reaction score: 29
Messages: 112

Hi All,

I apologize for the naive question, but I couldn't find any answers. I have an image of a ZFS root/boot disk, obtained via dd from the master server. Need to create many identical servers, also with ZFS root/boot. On UFS I'd obviously use dd to do that. Is there any workaround to quickly achieve that with ZFS?

Max
 

Bobi B.

Well-Known Member

Reaction score: 142
Messages: 335

If you can create a ZFS with a vdev on top of a file, I see no reason that wouldn't work if you dd this image over a hard disk, as long it is as large or larger than original one, and as long it is a mirrored vdev, at most.

PS: But I bet there are better ways to do the same, perhaps with zfs send and zfs receive?
 
OP
OP
blackhaz

blackhaz

Active Member

Reaction score: 29
Messages: 112

I am looking for a solution similar to just dd'ing the whole boot disk to an image file and then dd'ing it to a new disk, popping the disk into a new machine and booting it up. It would be, unfortunately, too time consuming to set up a full ZFS target.
 

olli@

Well-Known Member
Developer

Reaction score: 277
Messages: 315

Sorry, this is not an answer to your question, but …
On UFS I'd obviously use dd to do that.
I don't think that's obvious. I normally use either find(1)+cpio(1) (with the -p option) or dump(8)+restore(8) – Both ways are usually faster because they don't copy the empty space of the file system, unlike dd(1). For similar reasons I would try to avoid using dd for ZFS. But of course, if the file system is nearly full (i.e. there's almost no empty space), dd(1) is probably faster.
 
OP
OP
blackhaz

blackhaz

Active Member

Reaction score: 29
Messages: 112

I don't care about speed. The disk is just 16 GB or so, so dd finishes in acceptable amount of time in my case. I understand there are drawbacks but it's easy, especially as disks are cloned and units are assembled in a remote place. It would be very difficult to instruct setting up FreeBSD ZFS target machines.
 

olli@

Well-Known Member
Developer

Reaction score: 277
Messages: 315

I don't care about speed. The disk is just 16 GB or so, so dd finishes in acceptable amount of time in my case. I understand there are drawbacks but it's easy, especially as disks are cloned and units are assembled in a remote place. It would be very difficult to instruct setting up FreeBSD ZFS target machines.
Ok, in that case I think dd(1) should work fine, provided that you copy the complete device (i.e. disk) that covers your ZFS storage pool. Make sure to zpool export the pool before taking the copy. Also, it's probably a good idea to give each copy a new GUID ( zpool reguid), because all pools should have unique GUIDs in order to avoid confusion, just in case a disk is swapped into another machine.
 
Top