I'm about to make risky changes. How do I create a rollback point?

Quick Linux Tip #46:

Try: sudo lvcreate --snapshot --name pre_upgrade_snap --size 10G /dev/ubuntu-vg/root

Info: LVM snapshots capture the filesystem state at creation time. They use copy-on-write storage, recording changed blocks after the snapshot is created. A snapshot can later be merged to roll back changes.

Examples:

  • $ sudo lvcreate -s -n snap1 -L 5G /dev/vg0/mysql  # Create MySQL snapshot
  • $ sudo lvremove /dev/vg0/snap1  # Discard snapshot without merging
  • $ sudo btrfs subvolume snapshot /home /home.snap  # Btrfs alternative

Note: Requires LVM or Btrfs. Copy-on-write introduces a slight write penalty. Ensure the snapshot has enough space for changed blocks, or it can become invalid. Merging a root filesystem snapshot may require a reboot depending on how the root volume is mounted. Perfect before major upgrades.




LinuxTeck.com
linuxteck@ubuntu:~$ sudo lvcreate -s -n upgrade_snap -L 10G /dev/ubuntu-vg/root
  Using default stripesize 64.00 KiB.
  Logical volume "upgrade_snap" created.

linuxteck@ubuntu:~$ sudo lvs
  LV           VG        Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root         ubuntu-vg  -wi-ao---- 100.00g
  upgrade_snap ubuntu-vg  swi-a-s---  10.00g      root   0.05

linuxteck@ubuntu:~$ sudo lvconvert --merge /dev/ubuntu-vg/upgrade_snap
  Merging of volume ubuntu-vg/upgrade_snap started.
linuxteck@ubuntu:~$

PREVIOUS ARTICLE Quick Linux Tip #45: My Windows files have wrong encoding on Linux. How do I fix them all? NEXT ARTICLE Quick Linux Tip #47: I deleted a file 5 minutes ago and there's no backup. Can I recover?
About John Britto

John Britto Founder & Chief-Editor @LinuxTeck. A Computer Geek and Linux Intellectual having more than 20+ years of experience in Linux and Open Source technologies.

View all posts by John Britto →

Leave a Reply

Your email address will not be published.