Cloning system

Hello,

I never done this before so could you please give me some hints ...
I would like to clone a working system to make some tests on it.
System (FreeBSD 11.1-RELEASE-p10 ) runs on root ZFS file system.

can I do this by rsync-ing everything? What should I exclude from synchronization like "/dev" ...

zpool:
Code:
# zpool status
config:
    NAME        STATE     READ WRITE CKSUM
    zroot       ONLINE       0     0     0
      mirror-0  ONLINE       0     0     0
        ada0p3  ONLINE       0     0     0
        ada1p3  ONLINE       0     0     0

Thanks in advance.
 
Why don't you use ZFS's send/receive?

Note that 11.1 will be EoL soon, make sure to plan the upgrade to 11.2.
 
Install beadm(1) which makes using BEs (boot environments) on ZFS brain dead simple. Supposing you are running RELEASE-11.1

# beadm create 11.2

That creates a snapshot of your current running system. Note that you are still running 11.1.

# beadm activate 11.2

This activates the snapshot (a clone really) for the next boot.

# reboot

Log back in. Now you can upgrade to 11.2 - run freebsd-update for the upgrade.

Reboot into your new 11.2 install. If you like what you see - carry on. Suppose worse case the system won't boot properly.
The boot loader menu allows you to go back to the previous boot environment (normally called "default"). Even if the upgrade goes smoothly - you should try this out for yourself to see it working.

At some point you should clean up any old BE snapshots. You can, for example, delete the default and rename 11.2 to the new default (or whatever naming style suits you).
 
SirDice, unitrunker, thanks! ... I will try this on my test machine tomorrow, will report here. Maybe someone will find this useful...
 
That was ease

0. - ensure dst system has enough space :)

1. - create snapshot on source ZFS:
zfs snapshot -r zroot@cloning

2. - export to a file (faster for me - internal HDD), or pipe via ssh or netcat or whatever you like
zfs send -R zroot@cloning > /path/to/image.zexport

3. - boot from Live CD/USB, install blank OS or partition disk as you like manually.

4. - Import (in my case I got already preinstalled OS so I have to import it to a live cd)
zroot - disk of my os
zbackup - my backup disk
mkdir /tmp/zroot /tmp/zbackup
zpool import -f zroot -R /tmp/zroot # you may also do not mount dst pool, I do need to make some extra changes ....
zpool import -f zbackup -R /tmp/zbackup
zfs receive -vFd zroot< /tmp/zbackup/path/to/image.zexport


5. - reboot and enjoy life
 
Last edited:
Houston - we got a problem....

Yesterday I tested method above on my test workstation - it worked fine (2 different hard drves, different BSD builds).

today I'm trying to do the same on the different machine... Receive OK, all files OK, most of the system executables works fine but if I'm trying to run say MC - i receive: core dumped - illegal insttruction.
GDB shouls only : Program received signal SIGILL ...

HELP
 
Update...
zfs send/receive was not an issue. I just reconnect cloned disks to original system and everything boots and runs ...
Weird...

Hardware config:
Machine 1 - CPU: Intel I3 / MB: HP / Ram 4GB
Machine 2 - CPU: Intel I3 / MB: Asus / Ram 4GB

Software - compiled from ports...
 
Back
Top