Create root filesystem snapshots with LVM

From ArchWiki
Revision as of 06:05, 27 April 2013 by Freejack (Talk | contribs) (Created page with "This article will show you how to setup LVM snapshot creation during system start. Such snapshots can be used for full system backups with mini...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This article will show you how to setup LVM snapshot creation during system start. Such snapshots can be used for full system backups with minimal downtime.


Prerequisites

A system with LVM root and systemd.


Setup

During system start a clean snapshot of the root volume is created using a new service. Create /etc/systemd/system/mk-lvm-snapshots.service containing:

[Unit]
Description=make LVM snapshots
Requires=local-fs-pre.target
DefaultDependencies=no
Conflicts=shutdown.target
After=local-fs-pre.target
Before=local-fs.target

[Install]
WantedBy=make-snapshots.target

[Service]
Type=oneshot
ExecStart=/usr/sbin/lvcreate -L10G -n snap-root -s lvmvolume/root

Adapt the lvcreate command to match your root volume group and volume name.