Tuesday, October 20, 2009

[Level 2] Solaris 10 Technical Conference ( 2009/10/25,11/13,12/4 ) -- Basic ZFS hands-on lab

The following is my lab file, please refer to it. 

Wish this helps.

regards,
Stanley Huang


****************************************************************************************************

The purpose of this lab is to let you have basic ZFS administration skill. And then you will have the following capabilities.
Lab 1:
* create ZFS pool.
* check ZFS pool status.
* set ZFS pool properties.
* destroy ZFS pool.
Lab 2:
* create ZFS filesystem.
* check ZFS filesystem status.
* set ZFS filesystem properties.
* destroy ZFS filesystem.




Lab 1:
1. prepare files with command mkfile.
# mkdir -p /labs/ZFS/files;
# cd /labs/ZFS/files;
# mkfile 128m f1 f2 f3 f4 f5 f6 f7 f8 f9;

2. create ZFS pool.
# zpool create mypool mirror `pwd`/f1 `pwd`/f2 spare `pwd`/f3;
# zpool create myraidz raidz `pwd`/f4 `pwd`/f5 `pwd`/f6 spare `pwd`/f7;

3. list ZFS pools, and check pool status.
# zpool list;
---------------------------------------------------
# zpool list mypool;
NAME      SIZE   USED  AVAIL    CAP  HEALTH  ALTROOT
mypool    123M  77.5K   123M     0%  ONLINE  -
myraidz   370M   149K   370M     0%  ONLINE  -
---------------------------------------------------

# zpool status mypool;
---------------------------------------------------
  pool: mypool
 state: ONLINE
 scrub: none requested
config:

    NAME        STATE     READ WRITE CKSUM
    mypool      ONLINE       0     0     0
      /temp/f1  ONLINE       0     0     0
      /temp/f2  ONLINE       0     0     0
    spares
      /temp/f3  AVAIL  
---------------------------------------------------

# zpool status myraidz;
------------------------------------------------
  pool: myraidz
 state: ONLINE
 scrub: none requested
config:

    NAME          STATE     READ WRITE CKSUM
    myraidz       ONLINE       0     0     0
      raidz1      ONLINE       0     0     0
        /temp/f4  ONLINE       0     0     0
        /temp/f5  ONLINE       0     0     0
        /temp/f6  ONLINE       0     0     0
    spares
      /temp/f7    AVAIL  

errors: No known data errors
------------------------------------------------

4. list zpool properties.
# zpool get all mypool;
--------------------------------------------------
NAME    PROPERTY       VALUE       SOURCE
mypool  size           246M        -
mypool  used           76K         -
mypool  available      246M        -
mypool  capacity       0%          -
mypool  altroot        -           default
mypool  health         ONLINE      -
mypool  guid           9946812783950608926  default
mypool  version        14          default
mypool  bootfs         -           default
mypool  delegation     on          default
mypool  autoreplace    off         default
mypool  cachefile      -           default
mypool  failmode       wait        default
mypool  listsnapshots  off         default
--------------------------------------------------

5. change mypool pool property 'autoreplace'.
# zpool set autoreplace=on mypool;

6. export pool.
# zpool export mypool;

7. import pool.
# zpool import -d ./ mypool;

8. destroy pool.
# zpool destroy mypool;
# zpool destroy myraidz;



Lab 2:
1. create ZFS filesystem.
# zfs create mypool/myfs1;
# zfs create -p mypool/myfs1/myfs2/myfs3;

2. list ZFS filesystemsA.
# zfs list mypool/myfs1;
# zfs list -r mypool;

3. list zpool properties.
# zfs get all mypool/myfs1;
PS. Partial sample properties.
------------------------------------------------------------------
NAME          PROPERTY              VALUE                  SOURCE
mypool/myfs1  compressratio         1.00x                  -
mypool/myfs1  mountpoint            /mypool/myfs1          default
mypool/myfs1  compression           off                    default
mypool/myfs1  copies                1                      default
...
------------------------------------------------------------------

4. change mypool filesystem properties.
# zfs set mountpoint=/mnt/mypool mypool;

5. change myfs1 filesystem properties.
# zfs set compression=on mypool/myfs1;
# zfs set copies=2 mypool/myfs1/myfs2;

6. list properties.
# zfs get -r mountpoint mypool;
--------------------------------------------------------------------------------
NAME                      PROPERTY    VALUE                          SOURCE
mypool                    mountpoint  /mnt/mypool                    local
mypool/myfs1              mountpoint  /mnt/mypool/myfs1              inherited from mypool
mypool/myfs1/myfs2        mountpoint  /mnt/mypool/myfs1/myfs2        inherited from mypool
mypool/myfs1/myfs2/myfs3  mountpoint  /mnt/mypool/myfs1/myfs2/myfs3  inherited from mypool
--------------------------------------------------------------------------------

# zfs get -r compression mypool;
--------------------------------------------------------------------------------
NAME                      PROPERTY     VALUE     SOURCE
mypool                    compression  off       default
mypool/myfs1              compression  on        local
mypool/myfs1/myfs2        compression  on        inherited from mypool/myfs1
mypool/myfs1/myfs2/myfs3  compression  on        inherited from mypool/myfs1
--------------------------------------------------------------------------------

# zfs get -r compressratio mypool;
--------------------------------------------------------------------------------
NAME                      PROPERTY       VALUE  SOURCE
mypool                    compressratio  1.00x  -
mypool/myfs1              compressratio  1.00x  -
mypool/myfs1/myfs2        compressratio  1.00x  -
mypool/myfs1/myfs2/myfs3  compressratio  1.00x  -
--------------------------------------------------------------------------------

# zfs get -r copies mypool;
--------------------------------------------------------------------------------
NAME                      PROPERTY  VALUE   SOURCE
mypool                    copies    1       default
mypool/myfs1              copies    1       default
mypool/myfs1/myfs2        copies    2       local
mypool/myfs1/myfs2/myfs3  copies    2       inherited from mypool/myfs1/myfs2
--------------------------------------------------------------------------------

7. reset properties default values.
# zfs inherit -r mountpoint mypool;
# zfs inherit -r compression mypool;
# zfs inherit -r copies mypool;

8. destroy all ZFS filesystem.
# zfs destroy mypool/myfs1/myfs2/myfs3;
# zfs destroy -r mypool/myfs1;