You are on page 1of 13

SFR - STERIA - BTSYS - SUN - ZFS - INTRODUCTION -

REF: SUN-ZFS-02 - A

ZFS usual tasks

 Presentation :...................................................................................................................................2
 Creating a Pool "Prod".......................................................................................................................4
 Add a disc in a Pool:..........................................................................................................................4
 View the status of a Pool....................................................................................................................5
 Destroying a Pool..............................................................................................................................5
 Deport and import a POOL.................................................................................................................6
 See list of pools that can be imported:.......................................................................6
 To import the POOL PROD:...............................................................................................6
 Import POOL PROD by renaming PROD2:..................................................................6
 To deport POOL PROD:.......................................................................................................6
 Creating a FS:...................................................................................................................................7
 Add mirror disks to the pool:...............................................................................................................8
 Limit the FS (here 10G).....................................................................................................................8
 Book 2 gigabytes at FS:.....................................................................................................................8
 Creating a Snapshot and Rollback:.....................................................................................................9
 Clone FS:.......................................................................................................................................10
 View properties for a zFS:................................................................................................................10
 FSCK in ZFS:.................................................................................................................................10
 To replace a disk:............................................................................................................................11
 Creating a RAID-Z:..........................................................................................................................12
 Useful links :...................................................................................................................................13
- End of document -.................................................................................................................................13

Adel GACEM July 10. 08


SFR - STERIA - BTSYS - SUN - ZFS - INTRODUCTION -
REF: SUN-ZFS-02 - A

 Presentation :

Adel GACEM July 10. 08


SFR - STERIA - BTSYS - SUN - ZFS - INTRODUCTION -
REF: SUN-ZFS-02 - A

ZFS classic Manager

Adel GACEM July 10. 08


SFR - STERIA - BTSYS - SUN - ZFS - INTRODUCTION -
REF: SUN-ZFS-02 - A

 Creating a Pool "Prod"

o Simple:

# Zpool create Prod c2d0 c3d0

o Mirroring:

# Zpool create Prod mirror c2d0 c3d0

Cautions: On the SAN (except special request), it is not necessary to


mirrorer. This is handled at the storage arrays.

 Add a disc in a Pool:

# Zpool add [f] Prod c4d0

The -f option may be necessary if the disk in question was part of a


Pool zfs before.

Adel GACEM July 10. 08


SFR - STERIA - BTSYS - SUN - ZFS - INTRODUCTION -
REF: SUN-ZFS-02 - A

Warning: It is not possible to remove a pool of disk in one go


without destroying the pool. Bypasses as mirrorer the pool and then
remove the disk out of the pool does not always apply ... we will
have to check and ensure the proper way to add disk in the pool.

 View the status of a Pool

# Zpool status (or zpool status "pool_name")

For a verbose use [v]:

# Zpool status -v

Or

# Zpool status -x

To display only the Pool has problems.

 Destroying a Pool
The command does not warn and remove the Pool in seconds.

# zpool destroy "pool_name"

Use the [f] if a disk is no longer accessible.

Adel GACEM July 10. 08


SFR - STERIA - BTSYS - SUN - ZFS - INTRODUCTION -
REF: SUN-ZFS-02 - A
 Deport and import a POOL

 See list of pools that can be imported:

# Zpool import

 To import the POOL PROD:

# Zpool import PROD

The [f] can be used when the pool was being used by another
system.

 Import POOL PROD by renaming PROD2:

# Zpool import PRODPROD2

 To deport POOL PROD:

# Zpool deport PROD

 We can forcing the import of a POOL destroyed or


deported to another server:
 Show detected POOLS:

# Zpool import -D
 Import Pool:

# Zpool [f] import -D "NOM_du_POOL" or "ID_du_POOL"

Adel GACEM July 10. 08


SFR - STERIA - BTSYS - SUN - ZFS - INTRODUCTION -
REF: SUN-ZFS-02 - A
 Creating a FS:
FS "home" mount point "/ export / home"

# Zfs create Prod / home

Example:

[Root @ cascara: /] # df -h | grep Prod


Prod 36G 36G 25K 1% / prod
Prod / home 36G 36G 24K 1% / Prod / home

We change the name of the mount point:

# Zfs set mountpoint = / export / home Prod / home

[Root @ cascara: /] df -h | grep Prod


Prod 36G 36G 24K 1% / prod
Prod / home 36G 36G 24K G 1% / Export / home

Note : One should add more FS / etc / vfstab (except special


request) but the necessary information is contained in the ZFS layer
in each disk pool. Also mounting options are managed at this level
through the ZFS commands (automatic editing, ... .etc).
This facilitates the management of the vfstab file. In against part,
whether any goods FS are mounted will require:

1. Check the service status "filesystem / local"


 # Svcs filesystem / local
2. check the status of Pools:
 # Zpool status
3. Check the status of FS under zfs
 # Zfs list
4. Check if everything is mounted
 # Df -h

Adel GACEM July 10. 08


SFR - STERIA - BTSYS - SUN - ZFS - INTRODUCTION -
REF: SUN-ZFS-02 - A
 Add mirror disks to the pool:
# Zpool add Prod mirror c4d0 c5d0

 Limit the FS (here 10G)


# Zfs set quota = 10g Prod / home

[Root @ cascara: /] df -h | grep Prod


Prod 69G 69G 24K 1% / prod
Prod / home 10G 10G 24K 1% / export / home

Default FS inherits the properties of the Pool or FS in which it is


party. And without quota limit.

Check the result of "df -h / export / home" before and after assigning
a quota to MSDS.

 Book 2 gigabytes at FS:

# Zfs set Book & Prod = 5g / home

This ensures the FS minimum space of 5giga.

Warning :In the case of ZFS, though cmd "df -h" shows 10 gigabytes
of free (see example above), other FS same Pool is not limited by
default can reach the maximum limit of the Pool that blocks the rest
of the FS, where the concepts of "booking" and "quota". As of today
(see date below), SFR has chosen not to apply Quota!

 Creating a Snapshot and Rollback:

Adel GACEM July 10. 08


SFR - STERIA - BTSYS - SUN - ZFS - INTRODUCTION -
REF: SUN-ZFS-02 - A
Note: The concept of snapshot is not specific only to ZFS. But was
simplified under zfs.

# Zfs snapshot Prod / home @ snapshot_lundi

[Root @ cascara: / export / home / oracle] zfs list


NAME USED AVAIL REFER MOUNTPOINT
Prod 5.00G 63.9G 24.5K / Prod
Prod / home 45.5K 10.0G 45.5K / export / home
Prod / home @ snapshot_lundi 0 - 45.5K -

If we want to restore the FS to the image previously taken the


following command:

# Zfs rollback Prod / home @ snapshot_lundi

Note :
Before performing a rollback, you can access the data FS
mode "read-only" to the state of the snapshot, it also lets you
know if what you will eat is what is desired as the final result:

# Cd "Path of the FS" /. Zfs / snapshot / "snaphost-name"

Example:

Delete data and add in other / home after creating the snapshot.
List the contents of "/Prod/home/.zfs/snapshot/snapshot_lundi" you will find the FS with these data
in the initial state.

Adel GACEM July 10. 08


SFR - STERIA - BTSYS - SUN - ZFS - INTRODUCTION -
REF: SUN-ZFS-02 - A
 Clone FS:

Cloning is done from a snapshot.

Prod # zfs clone / home @ snapshot_lundi Prod / home_2

Cloning does not support attributes FS! Adapting the new FS cloned
your needs:

Example:

# Zfs set mountpoint = / export / home_2 Prod / home_2


...
Etc.

[Root @ cascara: /] df -h | grep Prod


Prod 69G 64G 24K 1% / prod
Prod / home 10G 10G 45K 1% / export / home
Prod / home_2 69G 64G 45K 1% / export / home_2

 View properties for a zFS:


# Zfs get -o property, value, source all "ZFS name"

Example:

# Zfs get -o property, value, source all STE0993 / users

 FSCK in ZFS:

Adel GACEM July 10. 08


SFR - STERIA - BTSYS - SUN - ZFS - INTRODUCTION -
REF: SUN-ZFS-02 - A
ZFS implements mechanisms ( "copy on write" and O_DSYNC flag)
that allows it to avoid losses of given following a crash. Data is never
lost, the state of a FS is always clean, so no need for fsck in ZFS.
Furthermore, to test the integrity of a pool at the HW command:

# Zpool scrub "Name POOL"

Scans the entire pool and generates IO POOL on all the discs.

# Zpool status -x

Watch the progress of the "scrub" or the result once finished.

 To replace a disk:

Ensure that the drive fails with OS commands.


If the disc is nothing wrong, we can remove the condition "FAILED"
displayed under "zpool status -x" with the command:

# Zpool clear "POOL" "DISK"

If the disc is defective, the steps for replacement are below:

■ Put the disc in "Offline"

# Zpool offline "Nom_du_Pool" "disk"

■ Remove the disk physically


■ Insert the new drive.

Adel GACEM July 10. 08


SFR - STERIA - BTSYS - SUN - ZFS - INTRODUCTION -
REF: SUN-ZFS-02 - A
■ Start replacement order:

# Zpool replace "Nom_du_Pool" "disk"

■ Replace the disc ONLINE status:

# Zpool online 'Nom_du_Pool "" disk "

Note :

If the new disk is not the same place as the one to replace the
replacement order is:

# Zpool replace "Pool" "Old disk" "New disk"

 Creating a RAID-Z:
There are no plans to create this type of RAID SFR but the command
is given in case of specific need:

# Zpool create "pool_name" raidz DISK_1 disk_2 disk_3


disk_4

Example:

# Zpool create "Prod2" raidz c1t0d0 c2t0d0 c3t0d0 c4t0d0

 Useful links :

Adel GACEM July 10. 08


SFR - STERIA - BTSYS - SUN - ZFS - INTRODUCTION -
REF: SUN-ZFS-02 - A

http://docs.sun.com/app/docs/doc/819-5461/

http://opensolaris.org/os/community/zfs/

- End of document -

Adel GACEM July 10. 08

You might also like