From b83d90241281d25cb23e4ca7195d9dd6ad6fd6b78984c826261f34b3c7f366f3 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Fri, 9 Feb 2018 07:23:55 +0000 Subject: [PATCH] Accepting request 574126 from home:michael-chang:branches:Base:System - Fix disappeared snapshot menu entry (bsc#1078481) * 80_suse_btrfs_snapshot OBS-URL: https://build.opensuse.org/request/show/574126 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=290 --- 80_suse_btrfs_snapshot | 18 +++++++++++++++--- grub2.changes | 6 ++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/80_suse_btrfs_snapshot b/80_suse_btrfs_snapshot index 9826426..11eb75f 100644 --- a/80_suse_btrfs_snapshot +++ b/80_suse_btrfs_snapshot @@ -1,10 +1,22 @@ #! /bin/sh set -e +SNAPSHOTS="/.snapshots" if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ] && - [ "x${GRUB_FS}" = "xbtrfs" ] ; then + [ "x${GRUB_FS}" = "xbtrfs" ] && + [ -f "${SNAPSHOTS}/grub-snapshot.cfg" ]; then + SNAPSHOT_RID=`btrfs inspect-internal rootid ${SNAPSHOTS}` + ROOT_RID=`btrfs inspect-internal rootid /` + if [ -n "${SNAPSHOT_RID}" -a "${SNAPSHOT_RID}" != "${ROOT_RID}" ]; then + SNAPSHOT_SUBVOL=`btrfs inspect-internal subvolid-resolve ${SNAPSHOT_RID} /` + ROOT_SUBVOL=`btrfs inspect-internal subvolid-resolve ${ROOT_RID} /` + INODE=`stat -c '%i' ${SNAPSHOTS}` + if [ "x${INODE}" = "x256" -a "x${ROOT_SUBVOL}${SNAPSHOTS}" != "x${SNAPSHOT_SUBVOL}" ]; then + echo "btrfs-mount-subvol (\$root) ${SNAPSHOTS} ${SNAPSHOT_SUBVOL}" + fi + fi cat <