Monday, April 6, 2009

Playing around with ZFS File system using Virtual Disk created from Sun xVM VirtualBox - Creating a zpool and adding storage to it

ZFS organizes physical devices into logical pools called storage pools. Both individual disks and array logical unit numbers (LUNs) visible to the operating system may be included in a ZFS pools. ZFS can be based on other less traditional storage structures as well.

Ideal way to practice and play around with ZFS is to install OpenSolaris as a Guest OS on VMware or using Sun xVM VirtualBox. My examples would be all based on Sun xVM VirtualBox. Its pretty easy and straight forward to add as many virtual disk as you like. I wont cover that stuff here. So this can be an ideal practice ground. You don't really have to run down a hardware store and get some inexpensive disks to play around with ZFS.

In my scenario, i have created in all 9 different virtual disks. Below are the details:

root@opensolaris:~# format
Searching for disks...done


AVAILABLE DISK SELECTIONS:
0. c3d0 DEFAULT cyl 3668 alt 2 hd 128 sec 32
/pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
1. c3d1 VBOX HAR-ca698f65-ae2b945-0001-5.82GB
/pci@0,0/pci-ide@1,1/ide@0/cmdk@1,0
2. c4d1 VBOX HAR-fdacd661-6e2e166-0001-2.00GB
/pci@0,0/pci-ide@1,1/ide@1/cmdk@1,0
3. c5t0d0 ATA-VBOX HARDDISK-1.0-2.00GB
/pci@0,0/pci8086,2829@d/disk@0,0
4. c5t1d0 ATA-VBOX HARDDISK-1.0-2.00GB
/pci@0,0/pci8086,2829@d/disk@1,0
5. c5t2d0 ATA-VBOX HARDDISK-1.0-2.00GB
/pci@0,0/pci8086,2829@d/disk@2,0
6. c5t3d0 ATA-VBOX HARDDISK-1.0-2.00GB
/pci@0,0/pci8086,2829@d/disk@3,0
7. c5t4d0 ATA-VBOX HARDDISK-1.0-4.00GB
/pci@0,0/pci8086,2829@d/disk@4,0
8. c5t5d0 ATA-VBOX HARDDISK-1.0-3.11GB
/pci@0,0/pci8086,2829@d/disk@5,0
Specify disk (enter its number): ^C
root@opensolaris:~#


Disk 0 - is my boot disk and i wont be touching this at all.
Disk 1 - 5.82 GB disk.
Disk 2 - 2.00 GB disk.
Disk 3 - 2.00 GB disk
Disk 4 - 2.00 GB disk
Disk 5 - 2.00 GB disk
Disk 6 - 2.00 GB disk
Disk 7 - 4.00 GB disk
Disk 8 - 3.11 GB disk

All the 2.00 GB one's i would be using extensively for creating MIRROR and RAID-Z zfs volumes. Rest of them would be for other purposes.

1. ZFS Pool

Lets first begin by creating a ZFS pool named "zpooldata". We would be using disk 2 and disk 7 for this, for now. So here's how we do it:

root@opensolaris:~# zpool create zpooldata c4d1 c5t4d0

the command executes successfully and i have a new zpool created zpooldata with 5.9 GB of available storage to use.

root@opensolaris:~# df -h
Filesystem Size Used Avail Use% Mounted on
rpool/ROOT/opensolaris
6.2G 2.3G 3.9G 37% /
swap 540M 324K 539M 1% /etc/svc/volatile
/usr/lib/libc/libc_hwcap3.so.1
6.2G 2.3G 3.9G 37% /lib/libc.so.1
swap 539M 12K 539M 1% /tmp
swap 539M 44K 539M 1% /var/run
rpool/export 3.9G 19K 3.9G 1% /export
rpool/export/home 3.9G 19K 3.9G 1% /export/home
rpool/export/home/vishal
3.9G 22M 3.9G 1% /export/home/vishal
rpool 3.9G 72K 3.9G 1% /rpool
zpooldata 5.9G 18K 5.9G 1% /zpooldata
root@opensolaris:~#


plain and simple, just one command and its done.

Now lets just go ahead and add Disk 8 to our zpool to get some extra storage. Here's how we do it.

root@opensolaris:~# zpool add zpooldata c5t5d0
root@opensolaris:~# df -h
Filesystem Size Used Avail Use% Mounted on
rpool/ROOT/opensolaris
6.1G 2.3G 3.9G 37% /
swap 540M 324K 540M 1% /etc/svc/volatile
/usr/lib/libc/libc_hwcap3.so.1
6.1G 2.3G 3.9G 37% /lib/libc.so.1
swap 540M 12K 540M 1% /tmp
swap 540M 44K 540M 1% /var/run
rpool/export 3.9G 19K 3.9G 1% /export
rpool/export/home 3.9G 19K 3.9G 1% /export/home
rpool/export/home/vishal
3.9G 31M 3.9G 1% /export/home/vishal
rpool 3.9G 72K 3.9G 1% /rpool
zpooldata 9.0G 18K 9.0G 1% /zpooldata

root@opensolaris:~# zpool status

pool: zpooldata
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
zpooldata ONLINE 0 0 0
c4d1 ONLINE 0 0 0
c5t4d0 ONLINE 0 0 0
c5t5d0 ONLINE 0 0 0

errors: No known data errors
root@opensolaris:~#


As of this writing, there is no provision to remove a disk from an existing zpool. I heard this feature is coming up in the future releases. However, what you could do is, to create a zpool with hotspares and then those hotspares could be removed as and when need arises. I will cover this in the next post.

0 comments:

BLOG Maintained by - Vishal Sharma | GetQuickStart