Wait to Mount Until Process Not Busy

The name of the pictureThe name of the pictureThe name of the pictureClash 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?







share|improve this question






















  • 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










  • 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














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?







share|improve this question






















  • 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










  • 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












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?







share|improve this question














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?









share|improve this question













share|improve this question




share|improve this question








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 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










  • 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










  • 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










  • 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















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














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













































































Popular posts from this blog

Peggy Mitchell

The Forum (Inglewood, California)

Palaiologos