2013-09-22

This document will show procedure of cloning a system running Solaris 10 that using ZFS as root file system. The idea is to take out mirror disk from the master server (source) & use it to boot up another server (target server). Then later we fix mirroring on both source & target server.

Suppose we have 1 server named vws01 with Solaris 10 SPARC installed. There are 4 disks on vws01 configured with ZFS file system.

slot#1 : c1t0d0s0 (part of rpool)

slot#2 : c1t1d0s0 (part of datapool)

slot#3 : c1t2t0d0 (part of rpool)

slot#4 : c1t3t0d0 (part of datapool)

Remember that the device name could be different on your system, just pay attention on the concept and adapt it with your devices name.

We want to create 1 other server name which similar with the vws01. We want to utilize ZFS mirror disks to cloning this server to create cloned server. So we have some tasks to do to achive that goal, I will split the steps into two big steps :

Procedure on the source machine (the existing server)

Procedure on the target machine (the clone server we want to create)

Procedure On The Source Machine

Make sure all ZFS pools (rpool & datapool) are in healthy state.

Shutdown the source machine.

Take out 1 disk from rpool (slot#3/c1t2d0) and 1 data disk from datapool (slot#4/c1t3d0). Give the label with clear information on it, for example :

Boot the server using only 1 mirror leg for rpool (c1t0d0) & datapool (c1t1d0). During boot process its normal when we get error message like there :

Those error come from ZFS inform that even that there are some fault on the ZFS pool. We can ignore those error for a while, since both pools still accessible & we intend to fix that broken mirror soon.

After OS ready check the disk availability and the status of all pools. Solaris will only see 2 disks installed right now. You will see that both of rpool and datapool are in DEGRADED state.

Plug in replacement disks (the disks must be same size with the previous one), one disk goes to slot#3 (as c1t2d0) and the other goes to slot#4 (as c1t3d0) slot. You can plug in the disk when server running if your server support hot plug disk controller. If don’t, then please shutdown the server before insert the replacement disks.

Assume your system support hot plug disks, the next step is detach the broken mirror leg. First we need to detach the broken disk from the rpool.

After detach the missing root mirror, rpool now on ONLINE status again.

Repeat the detach process for datapool.

After detach the missing data mirror, datapool now on ONLINE status again.

Before attach replacement disk to rpool, we need to prepare the replacement disk (c1t2d0) first. We need to label the disk first (this step verified on the SPARC system, but should be applicable on x86 system too).

Then we need to copy the partition table from the online root disk (c1t0d0) to the replacement disk (c1t2d0) :

Attach the replacement disk (c1t2d0) to the rpool.

Pay attention on the format of zfs attach command :

After attached the replacement disk to rpool then we can see rpool is in the resilver (resynchronization) status.

Same as the step #9, we also need to prepare the replacement disk (c1t3d0) before attaching it to the datapool. We need to label the disk first (this step verified on the SPARC system, but should be applicable on x86 system too).

Then we need to copy the partition table from the ONLINE data disk (c1t1d0) to the replacement disk (c1t3d0) :

Attach the replacement disk (c1t3d0) to the datapool.

After attached the replacement disk to datapool, we can see datapool is in the resilver (resynchronization) status.

After resilver process on the rpool completed, we need to reinstall boot block on the new disk (c1t2d0). This is crucial step otherwise we can’t use c1t2d0 as boot media even if it contains Solaris OS installation files. For SPARC system, we reinstall boot block on the new root mirror using installboot command like this :

In x86 system we do it using installgrub command like shown below :

Procedure On The Target Machine

This procedure executed on the new server (the clone target). We will boot this new server using 2 disk we take from the source machine vws01.

Assume that target machine is on powered off state (if doesn’t please shut it down first).

Remove all attached disks from the target machine.

Unplug all network cables attached to target machine. This step is important if target machine located in the same network segment. Because we use the disk from vws01 then when it boot up the server will try to use the same IP address as “original” vws01.

Plug in the disk we got from the source machine (as explained on step #3 in the last section).

With only 2 disk attached, boot the server. Remember to set the system to boot from slot #3. Otherwise system will failed to boot since it look at default disk on slot #1.

When OS ready check disk availability & status of all ZFS pools.

In case we only see rpool then we must import the other pool before proceed to the next steps.

The next step is we need to detach unavailable disk from the rpool.

After detach the missing root mirror, rpool now on ONLINE status again.

Repeat the detach process for unavailable disk on datapool.

After detach the missing data mirror, datapool now on ONLINE status again.

At this stage we probably want to change the hostname & modify IP address for this new machine before continue fix the mirroring. In this example the new machine will use hostname vws02. To change the hostname & IP address we need to edit several files :

/etc/hosts

/etc/hostname.*

/etc/nodename

/etc/netmasks

/etc/defaultrouter

We can use the following command to change the hostname :

Reboot the server so it can pick up the new hostname.

Once the server reboot successfully, insert the replacement disks on slot#1 and slot#2. Invoke devfsadm command to let Solaris detect the new disks.

See that the new disks (c1t0d0 & c1t1d0) already recognized by Solaris.

Before fixing mirroring on rpool we need to prepare the disk first (this step verified on the SPARC system, but should be applicable on x86 system too).

Then we need to copy the partition table from the ONLINE root disk (c1t2d0) to the replacement disk (c1t0d0) :

Now we can attach replacement disk to rpool.

After attached replacement disk to rpool, check that rpool now on resilver process.

Then we can continue to fix mirroring on datapool. But before that we need to prepare the replacement disk first (c1t1d0).

Then we need to copy the partition table from the ONLINE data disk (c1t3d0) to the replacement disk (c1t1d0) :

Now we can attach replacement disk to datapool.

After attached replacement disk to datapool, check that datapool now on resilver process.

After resilver process on the rpool finished, we need to reinstall boot block on the new disk (c1t0d0s0). This is crucial step otherwise we can’t use c1t0d0 as boot media even if it contains Solaris OS installation files. For SPARC system, we reinstall boot block on the new root mirror using installboot command like this :

In x86 system we do it using installgrub command like shown below :

Reboot the target machine once more to wrap everything completely.

Plug in all network cables and check the network connectivity.

Cloning Solaris 10 Server With ZFS Mirror Disk by Tedy Tirtawidjaja

Show more