【问题标题】:How to mount not presented in fstabfstab 中未显示的如何挂载
【发布时间】:2021-06-19 06:03:30
【问题描述】:

我有一个脚本可以生成有关丢失卷的信息,但我无法使用输出将它们挂载回来。你能帮帮我吗?

#!/bin/bash
mountpoints=( $(awk '$1 !~ /^#/ && $2 ~ /^[/]/ {print $2}' /etc/fstab) )
for mount in ${mountpoints[@]}; do
   if ! findmnt "$mount" &> /dev/null; then
      echo "$mount is declared in fstab but not mounted"
   fi
done

【问题讨论】:

  • 你不能只做mount "$mount"吗?
  • mount -a ?

标签: bash mount volumes


【解决方案1】:

尝试将findmnt命令放入参数执行范围-

#!/bin/bash
mountpoints=( $(awk '$1 !~ /^#/ && $2 ~ /^[/]/ {print $2}' /etc/fstab) )
for mount in ${mountpoints[@]}; do
if ! $(findmnt "$mount") &> /dev/null; then
  echo "$mount is declared in fstab but not mounted"
fi
done

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-06-26
    • 1970-01-01
    • 2014-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-28
    • 1970-01-01
    相关资源
    最近更新 更多