Search This Blog

Showing posts with label zpool mount. Show all posts
Showing posts with label zpool mount. Show all posts

Tuesday, 19 October 2010

Importing and exporting zpool

For migrating Zpool from one system to other, below are the steps. 
Here, we use two systems ( white and black) as source and destination hosts. 
1. Creating a zpool named testpool on white using 5 disks. 

root@white # zpool create -f testpool  /dev/dsk/c4t6005076305FFC08C000000000000100Ad0  /dev/dsk/c4t6005076305FFC08C000000000000100Bd0  /dev/dsk/c4t6005076305FFC08C0000000000001012d0 /dev/dsk/c4t6005076305FFC08C0000000000001013d0  /dev/dsk/c4t6005076305FFC08C0000000000001014d0 
2. Creating a zfs volume named testfs
root@white # zfs create testpool/testfs

3. Making an 8GB file for testing purpose.
root@white # cd /testpool/testfs 
root@white # df . 
Filesystem             size   used  avail capacity  Mounted on 
testpool/testfs        9.8G    24K   9.8G     1%    /testpool/testfs 
root@white # mkfile 9G testfile 
root@white # df -h|grep testpool 
testpool               9.8G    25K   782M     1%    /testpool 
testpool/testfs        9.8G   9.0G   782M    93%    /testpool/testfs 
4. Now we can export the zpool from white. Its mandatory to free up all zpool devices related to testpool.
root@white # zpool export testpool

Once the zpool is exported, it disappears from df output of source server (white)

root@white # df -h|grep testpool

Below are the steps to export the filesystem to destination host (here, black). W assume that all the five disks are accessible from both hosts.

1. To list all the importable zpool and corresponding statutes apply below command. 
root@black #zpool import 
  pool: testpool 
    id: 15485920734056515199 
 state: ONLINE 
action: The pool can be imported using its name or numeric identifier. 
config: 
        testpool                                 ONLINE 
          c4t6005076305FFC08C000000000000100Ad0  ONLINE 
          c4t6005076305FFC08C000000000000100Bd0  ONLINE 
          c4t6005076305FFC08C0000000000001012d0  ONLINE 
          c4t6005076305FFC08C0000000000001013d0  ONLINE 
          c4t6005076305FFC08C0000000000001014d0  ONLINE 
Above output shows that, all the disks related to test pool is available and it can be imported. 
2. Now it can be imported.
root@black # zpool import testpool
3. Verifying imported zpool file file created from white server
root@black# df -h|grep testpool 
testpool               9.8G    25K   782M     1%    /testpool 
testpool/testfs        9.8G   9.0G   782M    93%    /testpool/testfs 
4. Example for exporting a zpool volume with different name. Here the testpool of white is exporting as testpool1 in black
root@black # zpool import testpool testpool1 
root@white # df -h|grep testpool 
testpool1              9.8G    25K   782M     1%    /testpool1 
testpool1/testfs       9.8G   9.0G   782M    93%    /testpool1/testfs 
5. Example for importing/recovering a destroyed zpool.

root@white # zpool destroy testpool1 
The zpool testpool1 is destroyed by above command for testing purpose. For listing the destroyed zpool, –D option must be used.

root@white # zpool import -D 
  pool: testpool1 
    id: 15485920734056515199 
 state: ONLINE (DESTROYED) 
action: The pool can be imported using its name or numeric identifier. 
        The pool was destroyed, but can be imported using the '-Df' flags. 
config: 
        testpool1                                ONLINE 
          c4t6005076305FFC08C000000000000100Ad0  ONLINE 
          c4t6005076305FFC08C000000000000100Bd0  ONLINE 
          c4t6005076305FFC08C0000000000001012d0  ONLINE 
          c4t6005076305FFC08C0000000000001013d0  ONLINE 
          c4t6005076305FFC08C0000000000001014d0  ONLINE 

Below is the command for importing/recovering a deleted zpool. Notice the option –D and –f with import command.

root@white # zpool import -Df testpool1 
root@white # df -h|grep testpool 
testpool1              9.8G    25K   782M     1%    /testpool1 
testpool1/testfs       9.8G   9.0G   782M    93%    /testpool1/testfs

Monday, 16 August 2010

Solaris zfs raw device

Here I am creating a zfs raw device for using as raw partition for Sybase database.
The list of available zpool.

bash-3.00# zpool list
NAME     SIZE   USED  AVAIL    CAP  HEALTH  ALTROOT
dbpool   19.9G  1.32G  18.6G     6%  ONLINE  -

Creating a test volume of 10MB. (Notice the -V option with zfs command, which create a tree for corresponding device under /dev/zvol. This is option is required only when you want to appear this device under /dev/zvol)

bash-3.00# zfs create -V 10M dbpool/test
Creating UFS file system for the created device
bash-3.00# newfs /dev/zvol/rdsk/dbpool/test
newfs: construct a new file system /dev/zvol/rdsk/dbpool/test: (y/n)? y
Warning: 4130 sector(s) in last cylinder unallocated
/dev/zvol/rdsk/dbpool/test:      20446 sectors in 4 cylinders of 48 tracks, 128 sectors
        10.0MB in 1 cyl groups (14 c/g, 42.00MB/g, 20160 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32,

Now the newly created zfs volume is available in below list

bash-3.00# zfs list
NAME              USED  AVAIL  REFER  MOUNTPOINT
dbpool            1.33G  18.2G    21K  legacy
dbpool/apps         24K  10.0G    24K  /app
dbpool/lotus      1.32G  18.2G  1.32G  /opt/lotus
dbpool/notesdata    21K  18.2G    21K  /notesdata
dbpool/noteslogs    21K  18.2G    21K  /noteslogs
dbpool/test         10M  18.2G    24K  -

Its ready to mount it now.
bash-3.00# mount /dev/zvol/dsk/dbpool/test /mnt
bash-3.00# df -h |grep dbpool
dbpool/lotus             20G   1.3G    18G     7%    /opt/lotus
dbpool/notesdata         20G    21K    18G     1%    /notesdata
dbpool/noteslogs         20G    21K    18G     1%    /noteslogs
dbpool/apps              10G    24K    10G     1%    /app
/dev/zvol/dsk/dbpool/test   7.5M   1.0M   5.7M    16%    /mnt

Below is the path for zfs raw device and block device.

Block Device=/dev/zvol/dsk/dbpool/test
Raw Device=/dev/zvol/rdsk/dbpool/test


Ref:
Solaris 10 ZFS Essentials