Sunday, October 23, 2011

Solaris ZFS

what is ZFS ? 

ZFS is a UNIX file system like NTFS and FAT in windows, It's used widely in Solaris and its transactional file system which ensures that any sequence of operations is either entirely committed or entirely ignored. This mechanism ensures that the ZFS file system can never be corrupted through loss of power or a system crash.


ZFS Features 

➊  Support up to 256 quadrillion zettabytes, (zettabytes = 1024 Exabytes = 1024 petabytes = 1024 Terabyte = 1024 Gigabyte = 1024 Megabyte ), quadrillion is 10^15.

➋ support snapshots, snapshots is a read only copy of file system.

➌ file system grow dynamically as disk is added 

➍ File systems may span multiple physical disks 

➎ ZFS is transactionl file system

➏ ZFS file systems are auto-mounted

➐ ZFS file systems support quota and reservation

➑ provides web-based managment tool.

System Recommendation 

➊  One GB or more of memory is recommended.
➋  Run ZFS on a system that runs a 64-bit kernel
➌ Approximately 64 KB of memory is consumed per mounted ZFS file system.
➍ Set up one  pool using whole disks per system

Tutorial Requremens 

➊ 1GB RAM
➋ three hard disks ( You can use Virtual Box as a free tool to follow this tutorial step by step click here to learn Virtual BOX )
➌ Solaris 10 operating system

 Tutorial information 
in this tutorial we will 
➊ create a zpool ( assume zpool is a container or repository that will hold ZFS file systems).
➋ create ZFS file system,set quota and reservation.
➌ Mirror ZFS file system ( RAID 0 , RAID 1 , RAIDZ)
➍ create snapshot of file system.
➏ create clones


 Create and configure ZFS 

Zpool Creation, zpool is a container or repository that will hold ZFS file systems

➊ create zpool.
 zfs create test_pool c0d1 
 
where c0d1 is the logical device name of the second hard disk (use format command to view hard disk name ), "test_pool" is the name of the pool.

➋ at the command prompt show test-pool information
 zpool list 
output :-
NAME SIZE ALLOC FREE CAP HEALTH ALTROOT
 test_pool 3.97G 95.5K 3.97G 0% ONLINE - 
Now you have a pool which will contain you zfs filesystem.

ZFS file system creation

➊ to create zfs file system at the ok prompt type 
 zfs create test_pool/home1 
➋ to create a second zfs file system at the ok prompt type
 zfs create test_pool/home2 
➌ show zfs file system status and informatio 
 zfs list 
output :-
NAME USED AVAIL REFER MOUNTPOINT
test_pool 130K 3.91G 22K /test_pool 
test_pool/home1 21K 3.91G 21K /test_pool/home1
 test_pool/home2 21K 3.91G 21K /test_pool/home2 
now as you can see we have one pool called test_pool and its size equal to the of the second hard disk size and we have two zfs file system home1 and home 2 which they share the test-pool size.

if you don't want home1 file system to exceed 2GB set the quota property as following

Quota property

➊ You can use the quota property to set a limit on the amount of disk space a file system can use, to set quota to 2GB at the ok prompt type
 zfs set quota=2g test_pool/home1 
➋ show quota information
 zfs get -r quota test_pool/home1 
output :- 
NAME PROPERTY VALUE SOURCE test_pool/home1 quota 2G local 
➌ to clear quota property
 zfs set quota=none test_pool/home1 

ٌReservation property
➊ you can use the reservation property to guarantee that a specified amount of disk space is reserved to a file system, at the ok prompt type
zfs set reservation=3g test_pool/home2 
➋ to clear reservation property
 zfs set reservation=none test_pool/home1 

Remove ZFS file system 
➊ to remove ZFS file system, at the command prompt type:- 
 zfs destroy test_pool/home1 
➋ to remove ZFS pool, at the command prompt type:-
 zpool destroy test_pool 

 Mirror ZFS file system 

Extend the ZFS file system space ( RAID 0 )
assume you have a zfs file system and the file system is approximately fully and you want to add a disk space to.
Note:- create a pool if you have destoryed it.
 zfs add test_pool c1d0 
(where c0d1 is the logical device name of the third hard disk, use format command to get your hard disk name.

Mirror pool ( RAID 1 )

A RAID 1 creates an exact copy (or mirror) of a set of data on two or more disks.
➊ case 1 :- at the time of ZFS file system creation
Note:- Destroy all previous pool.
 zpool create test_poll mirror c0d1 c1d0 
 ( where c0d1 and c1d0 are hard disk logical device names)
➋ list pool information
 zpool status  
output:- 
pool: test_pool  
  state: ONLINE  
  scrub: none requested  
 config:  
     NAME    STATE   READ WRITE CKSUM  
     test_pool  ONLINE    0   0   0  
      mirror-0 ONLINE    0   0   0  
       c0d1  ONLINE    0   0   0  
       c1d0  ONLINE    0   0   0  
 errors: No known data errors
➌ remove disk from mirror 
 zpool detach test_pool c1d0  
 ( this will remove c1d0 from pool)

Case 2 :- if you have a pool and you want to create RAID 1 ( Mirror ) at the ok prompt type :-
Note ;- destroy  previous pool.
➊ create a pool
 zpool create test_pool c0d1   
➋ create RAID 1 ( Mirror)
 zpool attach test_pool c0d1 c1d0  
 ( where c1d0 is the new disk)

➌ remove disk from mirror 
 zpool detach test_pool c1d0  

RAIDZ

➊ Destroy previous pool 
 zpool destory test_pool  
➋ create a pool with RAIDZ
 zpool create test_pool raidz c0d1 c1d0 c2d0   

↬  ZFS snapshot

snapshot is a read only copy of file system that is used for redundancy and backup assues. 
Note :- to be not confused destroy prevous pool and create a new pool and zfs file system home1, home2, home3.
Steps to create a snapshot:- 
➊  list all pervious snapshot 
 zfs list -t snapshot   
output :- 
 no datasets available  
➋ create snapshot
 zfs snapshot test_pool/home3@snapshot_name  
➌ list snapshot configuration
 zfs list -t snapshot  
output:- 
NAME              USED AVAIL REFER MOUNTPOINT  
 test_pool/home3@snapshot_name   0   -  21K -  
Steps to delete a snapshot
 zfs destroy test_pool/home3@snapshot_name   
Steps to Rename a snapshot
 zfs rename test_pool/home3@snapshot_name test_pool/home3@new_snapshot_name  
Restore snapshot

if you accidentally delete files or folders and you want to restore it from snapshot :- 
 zfs reollback test_pool/home3@snapshot_name   
where the "test_pool/home3@snapshot_name" is the name of the snapshot.

 ZFS Clones 

ZFS clones is a writable copy of file system, ZFS clone linked to snapshot you must create a snapshot then create a clone.

steps to create snapshot :- 
➊ Create pool 
➋ create snapshot 
➌ create clone 
 fs clone test_pool/home3@snapshot_name test_pool/home5  
 this command will create new zfs file system home5,   


0 comments:

Post a Comment

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | coupon codes