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 <