我在这里运行 RHEL 7 和 bash。似乎命令替换不适用于 umount 命令。但是,对于其他命令,它确实可以正常工作。例如:
[root@localhost ~]# msg=$(umount /u01)
umount: /u01: target is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
[root@localhost ~]# echo "$msg"
- nothing here -
[root@localhost ~]# msg=$(mountpoint /u01)
[root@localhost ~]# echo "$msg"
/u01 is a mountpoint
我可能做的是先使用挂载点,然后如果挂载点存在则卸载。然后检查 umount 状态 - 如果有错误我猜设备一定很忙。