With the introduction of OCFS2 1.4 within Oracle VM 2.2, Oracle VM 2.2 has the ability to thin provision your files within your OCFS2 filesystem via the use of the sparse files. One might ask, what exactly is a sparse file? A sparse file is a file that attempts to use filesystem space more efficiently by effectively only using the space required to fit actual data. For example, imagine I have a System.img file within my Oracle VM repository that is 6.2GB in size as seen here:

[root@ovm]# ls -llh System.img
-rw-r--r-- 1 root root 6.2G Apr 14 09:18 System.img

If I did not have the sparse file feature within my Oracle VM 2.2 operating system, the  System.img file would actually take up 6.2GB of allocated space away from my OVS repository. However, with the introduction of sparse files to OCFS2 1.4, the actual data contained within  my System.img  was only 3.3GB as shown below. A total savings of 47% of actual diskspace!

[root@ovm]# ls -lsh System.img
3.3G -rw-r--r-- 1 root root 6.2G Apr 14 09:18 System.img

Now that we understand the huge advantages of enabling sparse files, I will show you how to enable sparse files for your Oracle VM 2.2 environment.

The first step will be to verify if your existing environment with your OCFS2 filesystem currently has sparse files enabled:

[root@ovm]# tunefs.ocfs2 -q -Q “All Features: %M %H %O\n” <source>
All Features: backup-super strict-journal-super sparse inline-data unwritten

It is particularly important to notice that one of the features under the ‘All Features’ is labeled sparse. If sparse is not shown as an option, we must then ‘Power Off’ all virtual machines running via the Oracle VM Manager, and unmount the OCFS2 filesystem from all our Oracle VM Servers. Once our OCFS2 filesystem is umounted on all your Oracle VM Servers, we will use the command ocfs2.tunefs to enable sparse files.

[root@ovm]# tunefs.ocfs2 -–fs-features=sparse <source>

After tuning the OCFS2 filesystem to support sparse, we must remount the OVS repository. Once the OVS repository is remounted, we are able to take advanatage of sparse files for our future virtual machines and virtual machine templates.

But what about our existing files within our OCFS2 filesystem? Can we not convert those to use sparse files? The answer is yes!

The simple solution is to copy the files with no sparse enabled into a file with sparse support using
--sparse option.

Example:
[root@ovm]#cp -rv --sparse=always <source> <target>

Advertisements