Showing posts with label TechConfiguration. Show all posts
Showing posts with label TechConfiguration. Show all posts

Friday, April 25, 2014

ZFS filesystem

What is it?

Deduplication is the process of eliminating duplicate copies of data. Dedup is generally either file-level, block-level, or byte-level. Chunks of data -- files, blocks, or byte ranges -- are checksummed using some hash function that uniquely identifies data with very high probability. When using a secure hash like SHA256, the probability of a hash collision is about 2\^-256 = 10\^-77 or, in more familiar notation, 0.00000000000000000000000000000000000000000000000000000000000000000000000000001. For reference, this is 50 orders of magnitude less likely than an undetected, uncorrected ECC memory error on the most reliable hardware you can buy.

Chunks of data are remembered in a table of some sort that maps the data's checksum to its storage location and reference count. When you store another copy of existing data, instead of allocating new space on disk, the dedup code just increments the reference count on the existing data. When data is highly replicated, which is typical of backup servers, virtual machine images, and source code repositories, deduplication can reduce space consumption not just by percentages, but by multiples.


Installing zfs on Ubuntu server 12.04

sudo apt-get -y install python-software-properties
sudo add-apt-repository ppa:zfs-native/stable
sudo apt-get update
sudo apt-cache search zfs
sudo apt-get install ubuntu-zfs

Note: this might take some time as it compiles the kernel module for your kernel

Run the zfs commands to make sure it works
sudo zfs
sudo zpool

There is no extra configuration for ZFS running on Ubuntu

zpool command configure zfs storage pools
zfs command configure zfs filesystem
zpool list shows the total bytes of storage available in the pool. 
zfs list shows the total bytes of storage available to the filesystem, after
redundancy is taken into account. 
du shows the total bytes of storage used by a directory, after compression
and dedupe is taken into account. 
"ls -l" shows the total bytes of storage currently used to store a file,
after compression, dedupe, thin-provisioning, sparseness, etc.

Link for reference:
https://blogs.oracle.com/bonwick/entry/zfs_dedup

Linux lvm - Logical Volume Manager

The Linux Logical Volume Manager (LVM) is a mechanism for virtualizing disks. It can create "virtual" disk partitions out of one or more physical hard drives, allowing you to grow, shrink, or move those partitions from drive to drive as your needs change.

The coolest part of Logical Volume Management is the ability to resize disks without powering off the machine or even interrupting service. Disks can be added and the volume groups can be extended onto the disks. This can be used in conjunction with software or hardware RAID as well.


Physical volumes your physical disks or disk partitions, such as /dev/hda or /dev/hdb1 -> combine multiple physical volumes into volume groups.

Volume groups comprised of real physical volumes -> create logical volumes which you can create/resize/remove and use. You can consider a volume group as a "virtual partition" which is comprised of an arbitary number of physical volumes. Ex: (VG1 = /dev/sda1 + /dev/sdb3 + /dev/sdc1)

logical volumes are the volumes that you'll ultimately end up mounting upon your system. They can be added, removed, and resized on the fly. Since these are contained in the volume groups they can be bigger than any single physical volume you might have. (ie. 4x5Gb drives can be combined into one 20Gb volume group, and you can then create two 10Gb logical volumes.)

PVLM: Physical volumes -> Volume group -> Logical volume -> Mount on filesystem 

Create Physiscal volumes

pvcreate /dev/sda1
pvcreate /dev/sdb
pvcreate /dev/sdc2

Display attributes of a physical volume
pvdisplay
pvs

Create Volume group

vgreate datavg /dev/sda1 /dev/sdb
add more physical volume to volume group
vgextend datavg /dev/sdc2

Display Volume group information
vgdisplay
vgs

Create Logical volume

lvcreate -n backup --size 500G datavg
Create Logical volume name backup size 500GB on datavg Volume group

Display Logical volume information
lvdisplay
lvs

Mount logical volume into filesystem

mkfs.ext4 /dev/datavg/backup
mkdir /srv/backup
mount /dev/datavg/backup /srv/backup
Append /etc/fstab
/dev/datavg/backup /srv/backup    ext4    defaults        0       2

Configuration file located at /etc/lvm/backup/datavg

Resize Logical volume when system online

#extend 200GB available on free space of /dev/datavg/backup
lvextend -L +200G /dev/datavg/backup

#extend the size by the amount of free space on physical volume /dev/sdc2

lvextend  /dev/datavg/backup  /dev/sdc2
resize2fs -p /dev/datavg/backup

Watch the resize process going on with df -h