I am trying to create a shell script that does the following
- Checks if a block device has a file system on it.
- Mount filesystem.
I have something like this right now
ls -ltrh /dev/vdb
brw-rw---- 1 root disk 254, 16 Dec 15 21:09 /dev/vdb
So /dev/vdb
is my block device. And my script is something along the lines of
if TEST-COMMAND-TO-CHECK-IF-VDB-ALREADY-HAS-FILESYSTEM-FORMATTED
then
sudo mkfs.ext4 /dev/vdb
fi
fi
mount | grep /mntpoint > /dev/null && exit 0 || sudo mount /dev/vdb /mntpoint
I am trying to find out a good command for testing if dev/vdb
has filesystem formatted.