Wait to Mount Until Process Not Busy

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I am writing/reading to an SSD over NVMe. I would like to unmounts the SSD partitions and remount them after writing and before reading so as to avoid caching problems. It seems when I try to perform this operation, I get an error saying that the device is busy and it does not perform this action.
Here are the commands
/root/bin/mountfs -u
sleep 5
/root/bin/mountfs -m
sleep 10
Here is mountfs
#!/bin/bash
# Mount/unmount ext4 file systems
exit_status=1
if [ "-m" = "$1" ]
then mount -t ext4 /fsmnt/fs1
mount -t ext4 /fsmnt/fs2
mount -t ext4 /fsmnt/fs3
mount -t ext4 /fsmnt/fs4
exit_status=0
elif [ "-u" = "$1" ]
then umount /fsmnt/fs1
umount /fsmnt/fs2
umount /fsmnt/fs3
umount /fsmnt/fs4
exit_status=0
else echo "mountfs -m | -u"
fi
exit $exit_status
Is there any way in bash to programmatically wait for all reads/writes to complete, so the devices are not busy and I can successfully remount the partitions to clear NVMe Controller/OS caches?
scripting cache ssd unmounting nvme
 |Â
show 1 more comment
up vote
0
down vote
favorite
I am writing/reading to an SSD over NVMe. I would like to unmounts the SSD partitions and remount them after writing and before reading so as to avoid caching problems. It seems when I try to perform this operation, I get an error saying that the device is busy and it does not perform this action.
Here are the commands
/root/bin/mountfs -u
sleep 5
/root/bin/mountfs -m
sleep 10
Here is mountfs
#!/bin/bash
# Mount/unmount ext4 file systems
exit_status=1
if [ "-m" = "$1" ]
then mount -t ext4 /fsmnt/fs1
mount -t ext4 /fsmnt/fs2
mount -t ext4 /fsmnt/fs3
mount -t ext4 /fsmnt/fs4
exit_status=0
elif [ "-u" = "$1" ]
then umount /fsmnt/fs1
umount /fsmnt/fs2
umount /fsmnt/fs3
umount /fsmnt/fs4
exit_status=0
else echo "mountfs -m | -u"
fi
exit $exit_status
Is there any way in bash to programmatically wait for all reads/writes to complete, so the devices are not busy and I can successfully remount the partitions to clear NVMe Controller/OS caches?
scripting cache ssd unmounting nvme
Maybe a filesystem type of autofs is an option?
â Raman Sailopal
Nov 20 '17 at 15:46
does runningsynchelp you immediately unmount the filesystems?
â Jeff Schaller
Nov 20 '17 at 17:24
see also unix.stackexchange.com/a/28575/117549 as a possible way to keep writes synchronized
â Jeff Schaller
Nov 20 '17 at 17:31
I think it may have been some fpga hardware we were testing that served as a nvme bridge. seems to work fine with the card I am using
â John Frye
Nov 20 '17 at 19:46
Do you still need a solution to this, or was it bad hardware?
â Jeff Schaller
Nov 20 '17 at 20:30
 |Â
show 1 more comment
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am writing/reading to an SSD over NVMe. I would like to unmounts the SSD partitions and remount them after writing and before reading so as to avoid caching problems. It seems when I try to perform this operation, I get an error saying that the device is busy and it does not perform this action.
Here are the commands
/root/bin/mountfs -u
sleep 5
/root/bin/mountfs -m
sleep 10
Here is mountfs
#!/bin/bash
# Mount/unmount ext4 file systems
exit_status=1
if [ "-m" = "$1" ]
then mount -t ext4 /fsmnt/fs1
mount -t ext4 /fsmnt/fs2
mount -t ext4 /fsmnt/fs3
mount -t ext4 /fsmnt/fs4
exit_status=0
elif [ "-u" = "$1" ]
then umount /fsmnt/fs1
umount /fsmnt/fs2
umount /fsmnt/fs3
umount /fsmnt/fs4
exit_status=0
else echo "mountfs -m | -u"
fi
exit $exit_status
Is there any way in bash to programmatically wait for all reads/writes to complete, so the devices are not busy and I can successfully remount the partitions to clear NVMe Controller/OS caches?
scripting cache ssd unmounting nvme
I am writing/reading to an SSD over NVMe. I would like to unmounts the SSD partitions and remount them after writing and before reading so as to avoid caching problems. It seems when I try to perform this operation, I get an error saying that the device is busy and it does not perform this action.
Here are the commands
/root/bin/mountfs -u
sleep 5
/root/bin/mountfs -m
sleep 10
Here is mountfs
#!/bin/bash
# Mount/unmount ext4 file systems
exit_status=1
if [ "-m" = "$1" ]
then mount -t ext4 /fsmnt/fs1
mount -t ext4 /fsmnt/fs2
mount -t ext4 /fsmnt/fs3
mount -t ext4 /fsmnt/fs4
exit_status=0
elif [ "-u" = "$1" ]
then umount /fsmnt/fs1
umount /fsmnt/fs2
umount /fsmnt/fs3
umount /fsmnt/fs4
exit_status=0
else echo "mountfs -m | -u"
fi
exit $exit_status
Is there any way in bash to programmatically wait for all reads/writes to complete, so the devices are not busy and I can successfully remount the partitions to clear NVMe Controller/OS caches?
scripting cache ssd unmounting nvme
edited Nov 20 '17 at 17:23
Jeff Schaller
32.1k849109
32.1k849109
asked Nov 20 '17 at 15:22
John Frye
161
161
Maybe a filesystem type of autofs is an option?
â Raman Sailopal
Nov 20 '17 at 15:46
does runningsynchelp you immediately unmount the filesystems?
â Jeff Schaller
Nov 20 '17 at 17:24
see also unix.stackexchange.com/a/28575/117549 as a possible way to keep writes synchronized
â Jeff Schaller
Nov 20 '17 at 17:31
I think it may have been some fpga hardware we were testing that served as a nvme bridge. seems to work fine with the card I am using
â John Frye
Nov 20 '17 at 19:46
Do you still need a solution to this, or was it bad hardware?
â Jeff Schaller
Nov 20 '17 at 20:30
 |Â
show 1 more comment
Maybe a filesystem type of autofs is an option?
â Raman Sailopal
Nov 20 '17 at 15:46
does runningsynchelp you immediately unmount the filesystems?
â Jeff Schaller
Nov 20 '17 at 17:24
see also unix.stackexchange.com/a/28575/117549 as a possible way to keep writes synchronized
â Jeff Schaller
Nov 20 '17 at 17:31
I think it may have been some fpga hardware we were testing that served as a nvme bridge. seems to work fine with the card I am using
â John Frye
Nov 20 '17 at 19:46
Do you still need a solution to this, or was it bad hardware?
â Jeff Schaller
Nov 20 '17 at 20:30
Maybe a filesystem type of autofs is an option?
â Raman Sailopal
Nov 20 '17 at 15:46
Maybe a filesystem type of autofs is an option?
â Raman Sailopal
Nov 20 '17 at 15:46
does running
sync help you immediately unmount the filesystems?â Jeff Schaller
Nov 20 '17 at 17:24
does running
sync help you immediately unmount the filesystems?â Jeff Schaller
Nov 20 '17 at 17:24
see also unix.stackexchange.com/a/28575/117549 as a possible way to keep writes synchronized
â Jeff Schaller
Nov 20 '17 at 17:31
see also unix.stackexchange.com/a/28575/117549 as a possible way to keep writes synchronized
â Jeff Schaller
Nov 20 '17 at 17:31
I think it may have been some fpga hardware we were testing that served as a nvme bridge. seems to work fine with the card I am using
â John Frye
Nov 20 '17 at 19:46
I think it may have been some fpga hardware we were testing that served as a nvme bridge. seems to work fine with the card I am using
â John Frye
Nov 20 '17 at 19:46
Do you still need a solution to this, or was it bad hardware?
â Jeff Schaller
Nov 20 '17 at 20:30
Do you still need a solution to this, or was it bad hardware?
â Jeff Schaller
Nov 20 '17 at 20:30
 |Â
show 1 more comment
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f405799%2fwait-to-mount-until-process-not-busy%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
Maybe a filesystem type of autofs is an option?
â Raman Sailopal
Nov 20 '17 at 15:46
does running
synchelp you immediately unmount the filesystems?â Jeff Schaller
Nov 20 '17 at 17:24
see also unix.stackexchange.com/a/28575/117549 as a possible way to keep writes synchronized
â Jeff Schaller
Nov 20 '17 at 17:31
I think it may have been some fpga hardware we were testing that served as a nvme bridge. seems to work fine with the card I am using
â John Frye
Nov 20 '17 at 19:46
Do you still need a solution to this, or was it bad hardware?
â Jeff Schaller
Nov 20 '17 at 20:30