Difference between fsfreeze and lvm snapshot

fsfreezelvmsnapshotvmware

I heard recently about fsfreeze and I'm very interested in making snapshots of my VM with VMware and get a consistent state of disk using quiescence.
All my file-systems are LVM volumes, and man fsfreeze mentions:

fsfreeze is unnecessary for device-mapper devices. The device-mapper (and LVM) automatically freezes filesystem on the device when a snapshot creation is requested. For more details see the dmsetup(8) man page.

But I find fsfreeze much more easy to use than a complex LVM tool where you need to evaluate your snapshot size.

Questions

  • Is there a difference?
  • Can I still use the command for a LVM volume? Or maybe a physical LVM volume?
  • Or am I forced to use the lvm command?

Additional question for the bounty

Does the fsfreeze or lvm snapshot insure a consistent snapshot if used to backup a mysql/oracle/postgrSQL DB?

Some more information

The case here is simple but you need to understand all the concept.
VMWare is capable of taking vm snapshot pretty quickly (less than 5 seconds), and before and after that snapshot executing script to stabilize the vm state and get a consistent vm snaphot. I don't care being able to mount in read-only a lvm snapshot and I don't want to because they are limited to disk size and more-over . What I want is to fsfreeze my filesystems and snapshot the vm and release the lock.
In that case could it be possible to use fsfreeze instead of the lvm snapshot (which are more complex and disk space linked.

Best Answer

From man fsfreeze:

-f, --freeze

This option requests the specified a filesystem to be frozen from new 
modifications. When this is selected, all ongoing transactions in the filesystem 
are allowed to complete, new write system calls are halted, other calls which 
modify the filesystem are halted, and all dirty data, metadata, and log information 
are written to disk. Any process attempting to write to the frozen filesystem will 
block waiting for the filesystem to be unfrozen.

To make a backup, from a mounted file system getting random modifications all the time, freezing the I/O for the duration of the backup is only part of the job to do. That's because unless the file system is really small, or you have an extremely fast backup device, you will most certainly be unable to afford to freeze the whole file system for the entire duration of making the backup.

So, fsfreeze alone is most likely not enough to do what you want. On the other hand, LVM snapshot is exactly what is needed for this job: it takes only a few seconds to "make the backup", then you can take your time to actually copy that backup (the snapshot) to some slow backup device as the LVM snapshot will handle file system blocks getting changed during this long backup process. The only part where fsfreeze would be needed is the snapshot creation part but that part is already handled by LVM itself transparently, so, altogether, all you need to pay attention to is the LVM snapshot.

Backups made by using similar file system freeze or block device snapshot features are considered consistent enough for a well-behaved RDBMS (such as Oracle and its cousins), however, you have to ensure that all the database files get frozen/snapshot at the same point in time. If multiple file systems/LVM volumes are affected, this may neccessitate the help of the RDBMS. Oracle, for instance, provides a BACKUP MODE, which is there to implement a freeze similar to what fsfreeze does, but at the database level.

Related Question