Site icon UnixArena

How to recover the OS using ZFS snapshot

Many of them are very  familiar with Solaris OS recovery on UFS root filesystem.Here we are going to see about how to recover Solaris 10 on ZFS root filesystem. Here is assumptions is we are periodically keeping root FS zfs snapshot in NAS location using zfs send feature.This can be achieved easily using small “zfs send” command. 

Note:This procedure will be applicable only if you are using zfs for root and sending the rpool snapshot periodically to NAS location.

First we will see how to recover SPARC based machines.First boot the system via network if you are already have jump-start server or boot if from OS DVD.
SPARC Based Systems:
 1) Boot system into single user mode:
ok boot net -s
or
ok boot cdrom -s

2) Mount the NFS share with the snapshots:

# mount -F nfs nfs-server:/path_to_directory /mnt

3) Recreate the root pool:

# zpool create -f -o failmode=continue -R /a -o cachefile=/etc/zfs/zpool.cache rpool mirror c1t0d0s0 c1t1d0s0
# zpool set autoreplace=on rpool

4) Restore the snapshots:

# cd /mnt
# zfs receive -Fd rpool < hostname.rpool.20120711.zfs
# zfs receive -Fd rpool < hostname.dataset.20120711.zfs

5) Verify snapshot was restored:

# zfs list

6) Create swap and dump volumes:

# zfs create -V 8g rpool/dump
# zfs set refreservation=none rpool/dump
# zfs set checksum=off rpool/dump
# zfs create -V 8g rpool/swap

7) Set pool bootfs property:

# zpool set bootfs=rpool/ROOT/dataset rpool
# zfs set canmount=noauto rpool/ROOT/dataset
# zfs set mountpoint=/ rpool/ROOT/dataset
# zfs set mountpoint=/rpool rpool

8) Install ZFS bootblk:

# installboot -F zfs /usr/platform/`uname -i`/lib/fs/zfs/bootblk /dev/rdsk/c1t0d0s0
# installboot -F zfs /usr/platform/`uname -i`/lib/fs/zfs/bootblk /dev/rdsk/c1t1d0s0

9) Reboot the system:

# umount /mnt
# init 6

Upon bootup, the system may appear to hang after printing the hostname.  The system

is creating the rpool/dump device, which can take several minutes.
10) Delete snapshot:
# zfs list |grep @
# zfs destroy -r rpool@XXXXXXXXX
 X86 Based systems
1.Boot system into single user mode:
This can be done by selecting from grub menu-Failsafe mode or boot from one of the NIC if have jumpstart start server.

2.Mount the NFS share with the snapshots:
May need to configure interface networking before mounting
 # mount -F nfs nfs-server:/path_to_directory /mnt

3.Recreate the root pool:
# zpool create -f -o failmode=continue -R /a -o cachefile=/etc/zfs/zpool.cache rpool  mirror c1t0d0s0 c1t1d0s0
# zpool set autoreplace=on rpool
4.Restore the snapshots:
 # cd /mnt
# zfs receive -Fd rpool < hostname.rpool.20120711.zfs
# zfs receive -Fd rpool < hostname.dataset.20120711.zfs

5.Verify snapshot was restored:

# zfs list

6.Create swap and dump volumes:

 # zfs create -V 8g rpool/dump
# zfs set refreservation=none rpool/dump
# zfs set checksum=off rpool/dump
# zfs create -V 8g rpool/swap

7.Set pool bootfs property:

 # zpool set bootfs=rpool/ROOT/dataset rpool
# zfs set canmount=noauto rpool/ROOT/dataset
# zfs set mountpoint=/ rpool/ROOT/dataset
# zfs set mountpoint=/rpool rpool

8.Install ZFS bootblk:

 # installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c1t0d0s0
# installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c1t1d0s0

9.Reboot the system:

 # umount /mnt
# init 6

Upon bootup, the system may appear to hang after printing the hostname.  The system is creating the rpool/dump device, which can take several minutes.


10.Delete snapshot:
# zfs list |grep @
# zfs destroy -r rpool@20120711

Thank you for reading this article.

Please leave a comment if you have any doubt ,i will get back to you as soon as possible.

Exit mobile version