Jump to content

How to test whether a drive uses Block level or File level storage?

Poet129
Go to solution Solved by Poet129,

This works:

from timeit import timeit
from os import remove
def allwrite():
    TestFile = open("TestFile", "wb")
    Data = b'\x00' * 512000 * 20
    TestFile.write(Data)
    TestFile.close()
def allread():
    TestFile = open("TestFile", "rb")
    Data = TestFile.read()
    TestFile.close()
def partread():
    TestFile = open("TestFile", "rb")
    Data = TestFile.read(512000)
    TestFile.close()
if __name__ == '__main__':
    a = timeit(allwrite, number=1)
    b = timeit(allread, number=1)
    c = timeit(partread, number=1)
    if (c < b):
        print("Your File System's Stucture is Block Based.")
    else:
        print("Your File System's Stucture is File Based.")
    remove("TestFile")

 

29 minutes ago, Poet129 said:

Is there a way to test whether a drive uses Block level or File level storage... preferably automated?

Can you attach it to a virtual machine like a physical disk, put a file system on it? Then it is block storage. Can you attach it like a network drive to read/write individual files? Then it is file storage. A physical disk is block storage, but you typically put a file system on it to be able to treat it like file storage.

 

https://blog.scaleway.com/understanding-the-different-types-of-storage/

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
Share on other sites

Link to post
Share on other sites

This works:

from timeit import timeit
from os import remove
def allwrite():
    TestFile = open("TestFile", "wb")
    Data = b'\x00' * 512000 * 20
    TestFile.write(Data)
    TestFile.close()
def allread():
    TestFile = open("TestFile", "rb")
    Data = TestFile.read()
    TestFile.close()
def partread():
    TestFile = open("TestFile", "rb")
    Data = TestFile.read(512000)
    TestFile.close()
if __name__ == '__main__':
    a = timeit(allwrite, number=1)
    b = timeit(allread, number=1)
    c = timeit(partread, number=1)
    if (c < b):
        print("Your File System's Stucture is Block Based.")
    else:
        print("Your File System's Stucture is File Based.")
    remove("TestFile")

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×