You are not logged in.

#1 2013-03-21 12:32:35

Ovion
Member
Registered: 2013-02-24
Posts: 78

[Done] LVM-snapshot as a backup before update

Hi,
I was thinking about using an LVM on a new machine. I don't need an LVM there, but I had the idea of using snapshots to kind of "backup" the system before a "pacman -Syu", so in case the update breaks something (very rare, but better safe than sorry) and I don't have the time to deal with that now, then I can just rollback and do the update later. This of course doesn't replace a usual backup, but for the purpose to undo a system update it should be enough.

Does this idea make sense? And is it possible to rollback the systempartition without a live system (I'm afraid that not, but maybe I'm wrong)?

Thanks in advance!

Last edited by Ovion (2013-03-22 14:03:34)

Offline

#2 2013-03-22 02:03:05

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,132

Re: [Done] LVM-snapshot as a backup before update

I would like to know how to do this, too, and also I would like to use lvm snapshots for ordinary back ups. The wiki seems to have this as a "to be filled in later" section but I want it to come to a wiki near me soon! (Because I am impatient and, yes, I know it is a community effort. I'm only saying what I _want_, not what I expect.)

If I had any real sense of how it might work, I would see if I could figure it out and update the wiki. However, every time I start reading about it, I seem to get lost again and end up getting even more confused. Probably need some more time and to find some good documentation...


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#3 2013-03-22 14:03:06

Ovion
Member
Registered: 2013-02-24
Posts: 78

Re: [Done] LVM-snapshot as a backup before update

Backups seem to be quite easy: just creating the snapshot and afterwards mounting it (e.g. at /mnt), from there you can do a backup with dd while your system continues running. Every change in your system will be caught in the snapshot, preventing inconsistencies. (Haven't tried that yet, though.)
That's why I finally chose to use lvm independant from the given scenario.

Last edited by Ovion (2013-03-22 14:04:20)

Offline

#4 2013-03-22 14:22:08

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: [Done] LVM-snapshot as a backup before update

This is how all my systems are setup, though I primarily do it for the rollback capability. I have only done that once though, and it was years ago (it was also unnecessary, as it turned out to be an XFCE .cache issue sad)

One thing to keep in mind is the recent issues with LVM. Don't be fooled by the thread title, it's happening to people who aren't using LUKS as well.

I was spared those problems, but I've had issues just with snapshots since ~ the same time. I also discovered just yesterday that dmeventd is consuming 100% CPU constantly when I have active snapshots.

@cfr: This is the resource I used to learn LVM+ss.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#5 2013-03-22 21:44:00

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,132

Re: [Done] LVM-snapshot as a backup before update

Thanks for the info and link. I'm not planning to implement this until the issues with lvm etc. are somewhat resolved. I already use lvm on luks and I don't want to introduce the snapshots as those seem implicated in the bug.

Just a question: as described above, Ovion said:

Every change in your system will be caught in the snapshot...

But I thought that the snapshot was the frozen-at-an-instant which you backed up and that the regular stuff continued to change. Have I misunderstood?


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#6 2013-03-27 13:24:28

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: [Done] LVM-snapshot as a backup before update

As I understand it, a snapshot begins as an empty container. When a "call" is made to write to the source, the original data is copied to the snapshot then the changes are written to the source (hence copy-on-write). Neither the snapshot nor the source are frozen/static.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#7 2013-04-15 01:06:56

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,132

Re: [Done] LVM-snapshot as a backup before update

But it is frozen in the sense of what's copied there is just what exists to begin with, right? The new changes are only written to the regular partitions.

I'm still not confident I understand this. For example, why is a hook necessary in the initramfs if the snapshot is created, used and removed? Why would something which no longer exists interfere with booting?


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#8 2013-04-15 04:00:10

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [Done] LVM-snapshot as a backup before update

I don't know about the required hook in the initramfs, but I knwo that when you create a snapshot, it isn't actually writing anything, it is simply tracking the extents that are in use by the original volume.  So because it is using the same extents it is not taking any space until a write/change occurs to the original, at which point the original extent is allotted tot he snapshot and a new extent is used in the original onto which the changes are written.

If what you are referring to as a HOOK is actually the "dm-snapshot" in the wiki, that is the module that is necessary to use snapshots.  I am not sure if it is pulled in by the lvm hook these days, but it certainly wasn't before, so if you wanted to boot from a snapshot they simply wouldn't be available if you didn't have that module.

Offline

Board footer

Powered by FluxBB