ZFS Can ZFS disks be cloned with dd?

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
 
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?
 
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.
 
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.
 
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.
 
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.
 
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.

Hello Olli,
So, we have a slow disk on one of office laptop, and we decided to clone it to new attached disk on same laptop (using dd).

So, long story short, the cloning process finished with no error. And ‘gpart show’ also shows identical output for old and new disks.

So, when i booted the laptop from new disk, UEFI tried to boot from every existing partition on new disk but failed. It made me thinking if there is something wrong with zfs/zpool on new disk, so i booted the laptop with live cd. And when issued ‘zpool import’, it only displays the pool on old disk and not new disk ..

in your response, you mentioned that ‘zpool export’ needs to be run before taking clone ? Could it be the reason that why zroot is not getting listed for new disk ?
Should i redo my steps ?
Thanks.
 
So, we have a slow disk on one of office laptop, and we decided to clone it to new attached disk on same laptop (using dd).

I have done this few times but not with dd. ZFS has a functions send / receive -
  1. connected both drives to computer
  2. manually created partition table (including new ZFS and UEFI boot) on new drive using gpart
  3. wrote UEFi boot loader on new drive
  4. using zfs send and zfs receive transferred old ZFS partition to new drive
  5. also had to adjust root mount point on new drive
Trere is another way, I have also tried and happen to like:
  1. partitioned and prepared the disk as in previous description
  2. added new ZFS partition as a mirror to existing partition using zpool attach
  3. allowed ZFS to resilver new disk
  4. now I had a working system with mirrored disks
  5. disconnected old disk and removed old device from mirror
  6. happy :)
Actually I am using ZFS mirror all the time on desktop computer, but not on laptop (because there is no room for two drives).
 
Back
Top