Reputation: 45
I have a script which produces information regarding missing volumes, but I can't make use output to mount them back. Could you please help me?
#!/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
Upvotes: 0
Views: 329
Reputation: 1081
Try putting the findmnt
command in parameter execution scope -
#!/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
Upvotes: 1