Automount Snapshot

Summary: I present a method for transparently auto-creating lvm snapshots on use.

1) The problem

I'm using rsync to transfer a backup area to another computer. The problem is that if the backup area changes during rsync then rsync complains bitterly and returns nasty error codes making me thing it has failed.

2) The normal solution

The "normal" solution (for those who run Linux Logical Volume Manager, that is) is to create a "snapshot"

The problem with the "normal" solution is that someone has to manage the snapshots -- and I don't like coupling the thing which performs the backup with the rest of the system. That increases system complexity.

3) My "hack"

So, I realized that I could use the automounter (autofs) to do what I needed. If the map for an automounter mount point is executable it is called as a script and can return what to link. Eureka!

So my solution was to create an automounter executable map that creates the snapshot and returns it based on the request. In other words, you add the following to your automount master file:

/mnt/path /etc/autofs/auto.snapshot-storage

now when you execute

ls /mnt/path/something

Then the text "something" is passed to /etc/autofs/auto.snapshot-storage , and that script creates a snapshot partition /dev/storage/something-snap based on the partition /dev/storage/something and returns it to be mounted.

If one previously existed that previous one gets removed.

This mount will exist as long as some process keeps /mnt/path/something open. After nothing touches it for a while (how long is controled by the regular automounter timeout) then it will automatically be unmounted. When it's next mounted it will be generated again.


Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.