How to get the size from a block device or raw disk in Windows, if I only know the name of the device, is it "\. \ PhysicalDrive0" without the file system on it or the volume label?
I tried the following:
fd = os.open (r "\. \ PhysicalDrive0", os.O_RDONLY)
os.lseek (fd, 0, os.SEEK_END)
it works fine on Linux, but always returns "OSError: [Errno 22] Invalid Argument" on Windows.
I also tried ctypes.windll.kernel32.GetDiskFreeSpaceExW (), but it seems to work only on a disk with a file system and assigned a volume label.
What is the right way to do this for a raw disk or block device?
Thanks in advance.
source share