When performing critical system upgrades on CentOS servers, LVM snapshots provide an excellent safety net. Unlike traditional backups, snapshots offer instantaneous point-in-time recovery with minimal storage overhead. The key operations we'll focus on are committing successful changes and reverting failed upgrades.
First, create a snapshot before making any changes. The size should be adequate to hold all potential changes during the upgrade process:
lvcreate -L 5G -s -n upgrade_snapshot /dev/VolGroup00/LogVol00
If the upgrade completes successfully, merge the snapshot changes back to the original volume:
lvconvert --merge /dev/VolGroup00/upgrade_snapshot
This operation will:
- Atomically merge all changes made since snapshot creation
- Automatically remove the snapshot after completion
- Require no system reboot in most cases
If the upgrade fails and you need to restore the original state:
umount /dev/VolGroup00/LogVol00
lvconvert --merge /dev/VolGroup00/upgrade_snapshot
mount /dev/VolGroup00/LogVol00 /mnt/root
Important considerations:
- The original volume must be unmounted first
- Some services may require restarting after revert
- For critical systems, a reboot is recommended
Key technical constraints to remember:
1. Snapshots operate at the block device level (entire volumes)
2. The snapshot size determines how many changes can be tracked
3. Performance impact increases as the snapshot fills up
For complex upgrades, consider staging multiple snapshots:
# Pre-package updates
lvcreate -L 2G -s -n pre_packages /dev/VolGroup00/LogVol00
# Apply package updates
yum update
# Pre-configuration changes
lvcreate -L 1G -s -n pre_config /dev/VolGroup00/LogVol00
# Modify configurations
This allows rolling back specific upgrade phases rather than the entire process.
When preparing for critical system upgrades on CentOS 5 servers, LVM snapshots provide an essential safety net. Unlike simple backups, LVM snapshots offer immediate point-in-time recovery options with minimal storage overhead.
First, create a snapshot before your upgrade procedure. The recommended size is 10-20% of the original volume:
lvcreate -L 10G -s -n rootsnap /dev/VolGroup00/LogVol00
If your upgrade succeeds and you want to permanently keep the changes:
lvconvert --merge /dev/VolGroup00/rootsnap
This command will merge the snapshot contents back into the origin volume during the next reboot. The process is atomic and guaranteed to complete even if interrupted.
To restore your system to the pre-upgrade state:
umount /dev/VolGroup00/LogVol00
lvconvert --merge /dev/VolGroup00/rootsnap
mount /dev/VolGroup00/LogVol00 /
You'll need to restart affected services. For critical system partitions, a full reboot is recommended to ensure complete filesystem consistency.
LVM snapshots operate at the block device level, making directory-specific snapshots impossible natively. However, you can work around this by:
- Creating separate LVs for critical directories
- Using logical volume stacking (thin provisioning)
- Combining LVM with filesystem-level tools like rsync
Here's a complete example for a yum-based upgrade:
# Create snapshot
lvcreate -L 15G -s -n pre_upgrade_snap /dev/VolGroup00/rootvol
# Perform upgrade
yum update kernel
yum upgrade
# Decision point
if upgrade_successful; then
lvconvert --merge /dev/VolGroup00/pre_upgrade_snap
else
umount / && lvconvert --merge /dev/VolGroup00/pre_upgrade_snap && reboot
fi
Remember that snapshots impact I/O performance. For production systems:
- Monitor COW (Copy-On-Write) operations with
iostat -x 1
- Keep snapshot duration as short as possible
- Consider using SSD-backed volume groups for better performance