$ findmnt --submounts /sysreturns info about /sys and all /sys submounts.
TARGET SOURCE FSTYPE OPTIONS
/sys /sys sysfs rw,relatime
├─/sys/fs/cgroup tmpfs tmpfs rw,nosuid,nodev,noexec,relat
│ ├─/sys/fs/cgroup/systemd cgroup cgroup rw,nosuid,nodev,noexec,relat
│ ├─/sys/fs/cgroup/cpuset cgroup cgroup rw,nosuid,nodev,noexec,relat
│ ├─/sys/fs/cgroup/ns cgroup cgroup rw,nosuid,nodev,noexec,relat
│ ├─/sys/fs/cgroup/cpu cgroup cgroup rw,nosuid,nodev,noexec,relat
│ ├─/sys/fs/cgroup/cpuacct cgroup cgroup rw,nosuid,nodev,noexec,relat
│ ├─/sys/fs/cgroup/memory cgroup cgroup rw,nosuid,nodev,noexec,relat
│ ├─/sys/fs/cgroup/devices cgroup cgroup rw,nosuid,nodev,noexec,relat
│ ├─/sys/fs/cgroup/freezer cgroup cgroup rw,nosuid,nodev,noexec,relat
│ ├─/sys/fs/cgroup/net_cls cgroup cgroup rw,nosuid,nodev,noexec,relat
│ └─/sys/fs/cgroup/blkio cgroup cgroup rw,nosuid,nodev,noexec,relat
├─/sys/kernel/security systemd-1 autofs rw,relatime,fd=22,pgrp=1,tim
├─/sys/kernel/debug systemd-1 autofs rw,relatime,fd=24,pgrp=1,tim
└─/sys/fs/fuse/connections fusectl fusectl rw,relatime
Now you can implement recursive umount in shell, something like:
for d in $(findmnt --list --submounts $MOUNTPOINT -o TARGET -n | tac); doI hope that umount(8) will support something like this ASAP.
umount $d
done