Why image size > size of the disk from which it is created?

USB Image Tool support forum
Post Reply
rliuap
Posts: 11
Joined: Sat Apr 07, 2012 8:35 am

Why image size > size of the disk from which it is created?

Post by rliuap »

I created an image form a USB drive whose total disk size is 1,998,743,040 bytes (not the volume size; got from a WMI call to Win32-DiskDrive). The image size is 2,003,795,968 bytes (not the size on disk; got by checking the file's properties in Windows Explorer). As you can see, the image size is 5,016,928 bytes (5MB) bigger than the disk size. Why??

If the image file is an exact bit-mapped image sector by sector, it shoud be exactly the same size as the disk from which the image is created. I repeated testing this with several drives of different sizes and all the image files are a few MB bigger than the disks from which they are created! You can verify this your self. Just create an image using any USb drives you have. Take a note on the disk size and image file size, you will be puzzled like me!

Further more, if I restore these larger image files back to the same disks from which they were created, most of times it restored images back to the drives with no errors. But a few times, I got the error saying "the image file is too large for selected usb device".

This seems saying that an image file created from a drive may not always be resored to the drive from which the image was created!?

Can anyone explain this?
Alex
Site Admin
Posts: 272
Joined: Fri Jul 29, 2011 11:59 pm

Re: Why image size > size of the disk from which it is creat

Post by Alex »

In device mode, the raw image file (not imz or gz) are 1:1 copies of the total physical space available on that drive. I tested this program several times in the past, before I released each version and did it right noew again. In my case the image size is exact the same size, USB Image Tool shows as device size. I don't know what you mean by "WMI call", maybe it returns not the physical disk size, but just the volume size of the DiskDrive.
rliuap
Posts: 11
Joined: Sat Apr 07, 2012 8:35 am

Re: Why image size > size of the disk from which it is creat

Post by rliuap »

WMI means Windows Management Instrument. It is a Windows subsystem built into all Windows (since XP). Win32_DiskDrive is a class of WMI, with which you can get disk drives' information. Googling "Win32_DiskDrive" or "WMI Code Creator"(an MS tool) you will find the information about it. Here is the WMI Win32_DiskDrive' output generated by WMI Code Creator for the drive in question:

Win32_DiskDrive instance
-----------------------------------
BytesPerSector: 512
Caption: Kingston DataTraveler G3 USB Device
Description: Disk drive
DeviceID: \\.\PHYSICALDRIVE3
Index: 3
Partitions: 1
PNPDeviceID: USBSTOR\DISK&VEN_KINGSTON&PROD_DATATRAVELER_G3&REV_1.00\1010071931161&0 <<<<This is the serial#
SectorsPerTrack: 63
Signature: 1
Size: 1998743040 <<<<<=========================================WMI size
TotalCylinders: 243
TotalHeads: 255
TotalSectors: 3903795
TotalTracks: 61965
TracksPerCylinder: 255
---------------------------------------------------------

Note the size 1998743040, it equals the ToatlSectors (3903795) times 512, that is, 3903795 x 512 = 1,998,743,040. It could not be wrong, could it? But the size of the image file that I created from this drive is 2,003,795,968 that is 5,052,928 bytes bigger than the drive size.

I also noticed that your program shows a different disk size for the same drive (note that the two outputs has the same serial number :1010071931161, so they are done against the same drive), that is 1:1 to the image file size I created, as you said, as shown below:

USB Image Tool 1.58
COPYRIGHT 2006-2011 Alexander Beug
http://www.alexpage.de

- Device ---------------------
Name : Kingston DataTraveler G3 USB Device
Number : 3268
Identifier : USBSTOR\DISK&VEN_KINGSTON&PROD_DATATRAVELER_G3&REV_1.00\101
Path : \\?\usbstor#disk&ven_kingston&prod_datatraveler_g3&rev_1.00
Size : 2003795968 Bytes <<<<<=========================================Your size
Serial : 1010071931161 <<<<<<<<<<<<<<<<<<<<<<<<<<<< same serial#
Location : DataTraveler G3

- Volume ---------------------
Path : E:\
Name :
File system: FAT
Size : 2003533824 Bytes
Free : 2003533824 Bytes
-------------------------------------------------------------------------

My question now is: how do you get your device size? Is your size based on total sectors (= C x H x T)? Where can I get that size to double verify your size is right and WMI size is wrong?
Alex
Site Admin
Posts: 272
Joined: Fri Jul 29, 2011 11:59 pm

Re: Why image size > size of the disk from which it is creat

Post by Alex »

I'm opening a handle on the Device and use Windows API functions to determine the device size, in detail it's DeviceIoControl and IOCTL_DISK_GET_LENGTH_INFO. Additionally, the file size results in a read operation, that reads all bytes from that device, until Windows tells, there are no more bytes to read. The information from WMI can't be right, because even the volume on the device has a larger size in bytes than the device, reported by WMI. You should get the same information, when you right-click the drive in Windows explorer.
Alex
Site Admin
Posts: 272
Joined: Fri Jul 29, 2011 11:59 pm

Re: Why image size > size of the disk from which it is creat

Post by Alex »

Just checked the WMI Code Creator myself. Looks like a useful tool, but it reports the wrong sizes in that case. Some of my flash drives are reported to small, some are reported to large. Additionally I googled that issue and found that MSDN Social discussion (I'm guessing by the nickname, that it was started by you? rlui ms=Microsoft, ap=Alexpage)

http://social.msdn.microsoft.com/Forums ... 294a6298d9
rliuap
Posts: 11
Joined: Sat Apr 07, 2012 8:35 am

Re: Why image size > size of the disk from which it is creat

Post by rliuap »

Thanks for verifying that! I believe you are right and WMI is wrong!

Yes, I posted the question on MS social network. I have been puzzled by that for months. Now I am sure WMI is wrong becuase the method you use is more trustable.

I raised this question becuase I want to verify if the image file will fit in the target drive before restoring the image to the drive. I then noticed the image size is always larger than the disk size (derived from WMI) from which the image was created. Now I know the WMI size is not reliable at all. I think I am going to get rid of the WMI and use you program to verify the size instead.

However, one time I noticed that even with your program, I got an output that showed volume size > device size. I will try to repeat that and post that output here.
Post Reply