0

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?

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.