Comparing mounted-mount points with fstab
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I took the sample script, below, off the net to check and validate mount points of system that is already up and running.
The problem:
I want to compare existing mounted-mount points which are not commented out in the /etc/fstab
and highlighting them if they are on.
Also, I would like to inquire if there is any alternative solution!
#!/bin/bash
while read ip;
do
echo "connecting to $ip";
ssh root@$ip "until mount | grep -w "/mnt/data" >/dev/null;
do echo mounting "/mnt/data"; mount "/mnt/data"; sleep 1; done &&
echo Mounted on $ip"
done < ips.txt
bash scripting mount
add a comment |Â
up vote
0
down vote
favorite
I took the sample script, below, off the net to check and validate mount points of system that is already up and running.
The problem:
I want to compare existing mounted-mount points which are not commented out in the /etc/fstab
and highlighting them if they are on.
Also, I would like to inquire if there is any alternative solution!
#!/bin/bash
while read ip;
do
echo "connecting to $ip";
ssh root@$ip "until mount | grep -w "/mnt/data" >/dev/null;
do echo mounting "/mnt/data"; mount "/mnt/data"; sleep 1; done &&
echo Mounted on $ip"
done < ips.txt
bash scripting mount
That script looks for one mount point (/mnt/data
) on a bunch of servers. That's not what you want.
â RonJohn
Sep 13 at 15:23
Do you want: the list of currently-mounted filesystems that are not "active" in /etc/fstab, or do you want: the list of "active" entries in /etc/fstab that are not mounted?
â Jeff Schaller
Sep 13 at 16:31
Linking in: unix.stackexchange.com/q/395721/117549
â Jeff Schaller
Sep 13 at 16:34
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I took the sample script, below, off the net to check and validate mount points of system that is already up and running.
The problem:
I want to compare existing mounted-mount points which are not commented out in the /etc/fstab
and highlighting them if they are on.
Also, I would like to inquire if there is any alternative solution!
#!/bin/bash
while read ip;
do
echo "connecting to $ip";
ssh root@$ip "until mount | grep -w "/mnt/data" >/dev/null;
do echo mounting "/mnt/data"; mount "/mnt/data"; sleep 1; done &&
echo Mounted on $ip"
done < ips.txt
bash scripting mount
I took the sample script, below, off the net to check and validate mount points of system that is already up and running.
The problem:
I want to compare existing mounted-mount points which are not commented out in the /etc/fstab
and highlighting them if they are on.
Also, I would like to inquire if there is any alternative solution!
#!/bin/bash
while read ip;
do
echo "connecting to $ip";
ssh root@$ip "until mount | grep -w "/mnt/data" >/dev/null;
do echo mounting "/mnt/data"; mount "/mnt/data"; sleep 1; done &&
echo Mounted on $ip"
done < ips.txt
bash scripting mount
bash scripting mount
edited Sep 13 at 16:00
Goro
5,47052460
5,47052460
asked Sep 13 at 15:18
JackyBoi
11517
11517
That script looks for one mount point (/mnt/data
) on a bunch of servers. That's not what you want.
â RonJohn
Sep 13 at 15:23
Do you want: the list of currently-mounted filesystems that are not "active" in /etc/fstab, or do you want: the list of "active" entries in /etc/fstab that are not mounted?
â Jeff Schaller
Sep 13 at 16:31
Linking in: unix.stackexchange.com/q/395721/117549
â Jeff Schaller
Sep 13 at 16:34
add a comment |Â
That script looks for one mount point (/mnt/data
) on a bunch of servers. That's not what you want.
â RonJohn
Sep 13 at 15:23
Do you want: the list of currently-mounted filesystems that are not "active" in /etc/fstab, or do you want: the list of "active" entries in /etc/fstab that are not mounted?
â Jeff Schaller
Sep 13 at 16:31
Linking in: unix.stackexchange.com/q/395721/117549
â Jeff Schaller
Sep 13 at 16:34
That script looks for one mount point (
/mnt/data
) on a bunch of servers. That's not what you want.â RonJohn
Sep 13 at 15:23
That script looks for one mount point (
/mnt/data
) on a bunch of servers. That's not what you want.â RonJohn
Sep 13 at 15:23
Do you want: the list of currently-mounted filesystems that are not "active" in /etc/fstab, or do you want: the list of "active" entries in /etc/fstab that are not mounted?
â Jeff Schaller
Sep 13 at 16:31
Do you want: the list of currently-mounted filesystems that are not "active" in /etc/fstab, or do you want: the list of "active" entries in /etc/fstab that are not mounted?
â Jeff Schaller
Sep 13 at 16:31
Linking in: unix.stackexchange.com/q/395721/117549
â Jeff Schaller
Sep 13 at 16:34
Linking in: unix.stackexchange.com/q/395721/117549
â Jeff Schaller
Sep 13 at 16:34
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
0
down vote
This appears to do the trick:
#!/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
add a comment |Â
up vote
0
down vote
Stealing borrowing DopeGhoti's awk
, you could use comm
for this:
Filesystems that are mounted but not in /etc/fstab:
comm -23 <(mount|awk 'print $3'|sort) <(awk '$1 !~ /^#/ && $2 ~ /^[/]/ print $2' /etc/fstab|sort)
Filesystems that are in /etc/fstab but not mounted:
comm -13 <(mount|awk 'print $3'|sort) <(awk '$1 !~ /^#/ && $2 ~ /^[/]/ print $2' /etc/fstab|sort)
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
This appears to do the trick:
#!/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
add a comment |Â
up vote
0
down vote
This appears to do the trick:
#!/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
add a comment |Â
up vote
0
down vote
up vote
0
down vote
This appears to do the trick:
#!/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
This appears to do the trick:
#!/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
answered Sep 13 at 15:50
DopeGhoti
41.3k55180
41.3k55180
add a comment |Â
add a comment |Â
up vote
0
down vote
Stealing borrowing DopeGhoti's awk
, you could use comm
for this:
Filesystems that are mounted but not in /etc/fstab:
comm -23 <(mount|awk 'print $3'|sort) <(awk '$1 !~ /^#/ && $2 ~ /^[/]/ print $2' /etc/fstab|sort)
Filesystems that are in /etc/fstab but not mounted:
comm -13 <(mount|awk 'print $3'|sort) <(awk '$1 !~ /^#/ && $2 ~ /^[/]/ print $2' /etc/fstab|sort)
add a comment |Â
up vote
0
down vote
Stealing borrowing DopeGhoti's awk
, you could use comm
for this:
Filesystems that are mounted but not in /etc/fstab:
comm -23 <(mount|awk 'print $3'|sort) <(awk '$1 !~ /^#/ && $2 ~ /^[/]/ print $2' /etc/fstab|sort)
Filesystems that are in /etc/fstab but not mounted:
comm -13 <(mount|awk 'print $3'|sort) <(awk '$1 !~ /^#/ && $2 ~ /^[/]/ print $2' /etc/fstab|sort)
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Stealing borrowing DopeGhoti's awk
, you could use comm
for this:
Filesystems that are mounted but not in /etc/fstab:
comm -23 <(mount|awk 'print $3'|sort) <(awk '$1 !~ /^#/ && $2 ~ /^[/]/ print $2' /etc/fstab|sort)
Filesystems that are in /etc/fstab but not mounted:
comm -13 <(mount|awk 'print $3'|sort) <(awk '$1 !~ /^#/ && $2 ~ /^[/]/ print $2' /etc/fstab|sort)
Stealing borrowing DopeGhoti's awk
, you could use comm
for this:
Filesystems that are mounted but not in /etc/fstab:
comm -23 <(mount|awk 'print $3'|sort) <(awk '$1 !~ /^#/ && $2 ~ /^[/]/ print $2' /etc/fstab|sort)
Filesystems that are in /etc/fstab but not mounted:
comm -13 <(mount|awk 'print $3'|sort) <(awk '$1 !~ /^#/ && $2 ~ /^[/]/ print $2' /etc/fstab|sort)
answered Sep 13 at 16:41
Jeff Schaller
33.1k849111
33.1k849111
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f468824%2fcomparing-mounted-mount-points-with-fstab%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
That script looks for one mount point (
/mnt/data
) on a bunch of servers. That's not what you want.â RonJohn
Sep 13 at 15:23
Do you want: the list of currently-mounted filesystems that are not "active" in /etc/fstab, or do you want: the list of "active" entries in /etc/fstab that are not mounted?
â Jeff Schaller
Sep 13 at 16:31
Linking in: unix.stackexchange.com/q/395721/117549
â Jeff Schaller
Sep 13 at 16:34