Skip to main content
minor text
Source Link
thanasisp
  • 8.5k
  • 2
  • 29
  • 40

I am trying to create a shell script that does the following

  1. Checks if a block device has a file system on it.
  2. 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/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 TEST-COMMAND-TO-CHECK-IF-VDB-ALREADY-HAS-FILESYSTEM-FORMATTEDtesting if dev/vdb has filesystem formatted.

I am trying to create a shell script that does the following

  1. Checks if a block device has a file system on it.
  2. 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 TEST-COMMAND-TO-CHECK-IF-VDB-ALREADY-HAS-FILESYSTEM-FORMATTED

I am trying to create a shell script that does the following

  1. Checks if a block device has a file system on it.
  2. 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.

Source Link

Need help with shell script to format filesystem on block device and mount it

I am trying to create a shell script that does the following

  1. Checks if a block device has a file system on it.
  2. 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 TEST-COMMAND-TO-CHECK-IF-VDB-ALREADY-HAS-FILESYSTEM-FORMATTED