搜索

15.5. 在升级后创建回滚引导条目

download PDF

要在升级后将操作系统升级恢复到系统以前的状态,请使用回滚引导条目。如果您发现了一个升级环境的问题,例如与内部软件不兼容,这也很有用。

要准备回滚引导条目,请使用快照环境。

先决条件

流程

  1. 将快照与原始卷合并:

    # lvconvert --merge rhel/root_snapshot_before_changes
      Logical volume rhel/root_snapshot_before_changes contains a filesystem in use.
      Delaying merge since snapshot is open.
      Merging of thin snapshot rhel/root_snapshot_before_changes will occur on next activation of rhel/root.
    警告

    合并快照后,您必须继续此流程中所有剩余步骤,以防止数据丢失。

  2. 为合并的快照创建一个回滚引导条目:

    # boom create --backup --title "RHEL Rollback" --rootlv rhel/root
    Created entry with boot_id 1e6d298:
      title RHEL Rollback
      machine-id f9f6209866c743739757658d1a4850b2
      version 3.10.0-1160.118.1.el7.x86_64
      linux /vmlinuz-3.10.0-1160.118.1.el7.x86_64.boom0
      initrd /initramfs-3.10.0-1160.118.1.el7.x86_64.img.boom0
      options root=/dev/rhel/root ro rd.lvm.lv=rhel/root
      grub_users $grub_users
      grub_arg --unrestricted
      grub_class kernel
  3. 重启机器以恢复操作系统状态:

    # reboot
    • 系统重启后,从 GRUB 屏幕中选择 RHEL Rollback 引导条目。
    • root 逻辑卷处于活跃状态时,系统会自动启动快照合并操作。

      重要

      当合并操作启动时,快照卷将不再可用。在成功引导 RHEL Rollback 引导条目后,Root LV 快照引导条目 将无法正常工作。合并快照逻辑卷会破坏 Root LV 快照,并恢复原始卷之前的状态。

  4. 完成合并操作后,删除未使用的条目并恢复原始引导条目:

    1. /boot 文件系统中删除未使用的 Red Hat Enterprise Linux 8 引导条目,并重建 grub.cfg 文件以使更改生效:

      # rm -f /boot/loader/entries/*.el8*
      # rm -f /boot/*.el8*
      # grub2-mkconfig -o /boot/grub2/grub.cfg
      Generating grub configuration file ...
      Found linux image: /boot/vmlinuz-3.10.0-1160.118.1.el7.x86_64.boom0
      ....
      done
    2. 恢复原始的 Red Hat Enterprise Linux 引导条目:

      # new-kernel-pkg --update $(uname -r)
  5. 成功回滚到系统后,删除 boom 快照和回滚引导条目:

    # boom list -o+title
    BootID  Version                      Name                            RootDevice                             Title
    a49fb09 3.10.0-1160.118.1.el7.x86_64 Red Hat Enterprise Linux Server /dev/mapper/rhel-root                  Red Hat Enterprise Linux (3.10.0-1160.118.1.el7.x86_64) 8.9 (Ootpa)
    1bb11e4 3.10.0-1160.el7.x86_64       Red Hat Enterprise Linux Server /dev/mapper/rhel-root                  Red Hat Enterprise Linux (3.10.0-1160.el7.x86_64) 8.9 (Ootpa)
    e0252ad 3.10.0-1160.118.1.el7.x86_64 Red Hat Enterprise Linux Server /dev/rhel/root_snapshot_before_changes Root LV snapshot before changes
    1e6d298 3.10.0-1160.118.1.el7.x86_64 Red Hat Enterprise Linux Server /dev/rhel/root                         RHEL Rollback
    # boom delete e0252ad
    Deleted 1 entry
    # boom delete 1e6d298
    Deleted 1 entry

其他资源

  • boom(1) 手册页
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.