Jump to content











Photo
- - - - -

How to get UUID of an ImDisk mounted drive image?


  • Please log in to reply
57 replies to this topic

#1 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 09 April 2014 - 11:13 AM

I have used imdisk to create a ramdisk with a backing file, it is mounted as U: on my Win8 system.

 

How can I get the volume UUID of the U: volume?

 

Neither mountvol or diskpart recognise the U: volume. It is not listed in HKLM\System\MountedDevices

 

Thanks

Steve



#2 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 09 April 2014 - 12:15 PM

Hi Steve6375,

 

Using MS windows API, I was not able to get a UUID either for ImDisk volume.

 

Regards,

Erwan



#3 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 09 April 2014 - 12:20 PM

I have used imdisk to create a ramdisk with a backing file, it is mounted as U: on my Win8 system.

 

How can I get the volume UUID of the U: volume?

 

Neither mountvol or diskpart recognise the U: volume. It is not listed in HKLM\System\MountedDevices

 

Thanks

Steve

IMDISK does not deal with some NT disk related subsystems.

 

See also:

http://reboot.pro/to...disk-in-win-2k/

http://reboot.pro/to...emount-ramdisk/

 

If you need a UUID, you will need to use another driver with more "low level" integration, I believe. (firadisk shoudl be fine):

 

 

You will probably find the U: drive letter under:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\

but there is no UUID.

 

 

:duff:

Wonko



#4 Olof Lagerkvist

Olof Lagerkvist

    Gold Member

  • Developer
  • 1448 posts
  • Location:Borås, Sweden
  •  
    Sweden

Posted 09 April 2014 - 12:23 PM

ImDisk does not interact with Volume Mount Manager, so no UUIDs or similar Volume Mount Manager specific metadata are created for ImDisk volumes. ImDisk instead calls DefineDosDevice/DeviceIoControl etc directly to define drive letters and mount points.

#5 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 09 April 2014 - 12:33 PM

OK, thanks for the replies.



#6 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 09 April 2014 - 05:05 PM

I found a solution! ImDisk outputs the Volume serial number when it formats the volume.

 

Note: `find "Serial Number" imdisk.log`  uses backquotes NOT forward quotes.

imdisk -a -s %MYSIZE%m -m %SPAREVOL% -f %MYIMG% -p "/FS:%MYFMT% /Q /Y" > imdisk.log
if errorlevel 1 type imdisk.log & echo imdisk operation failed! & pause & goto :EOF
:: get serial number UUID of volume just formatted
for /F "usebackq tokens=5" %%A in (`find "Serial Number" imdisk.log`) do set UUID=%%A
echo UUID=%UUID%


#7 Olof Lagerkvist

Olof Lagerkvist

    Gold Member

  • Developer
  • 1448 posts
  • Location:Borås, Sweden
  •  
    Sweden

Posted 09 April 2014 - 05:15 PM



 

I found a solution! ImDisk outputs the Volume serial number when it formats the volume.

 

Note: `find "Serial Number" imdisk.log`  uses backquotes NOT forward quotes.

imdisk -a -s %MYSIZE%m -m %SPAREVOL% -f %MYIMG% -p "/FS:%MYFMT% /Q /Y" > imdisk.log
if errorlevel 1 type imdisk.log & echo imdisk operation failed! & pause & goto :EOF
:: get serial number UUID of volume just formatted
for /F "usebackq tokens=5" %%A in (`find "Serial Number" imdisk.log`) do set UUID=%%A
echo UUID=%UUID%

 

 

I don't know if I am just missing something here, but this would surely not give you a UUID? It just gives you the 32 bit volume serial number that format.com assigns when it formats the volume? That is not in any way related to the 128 bit UUID/GUID that for instance mountvol and similar use when you assign drive letters or mount points.

 

A volume UUID/GUID is created in the interaction between disk driver and volume mount manager and is persistent for a specific volume. It does not change when the same volume is mounted again on the same machine, but on another machine the same volume could get a completely different UUID/GUID when mounted there. The UUID/GUID does however not change when you reformat the volume with a different filesystem. A volume serial number on the other hand, is assigned during the creation of the filesystem and it could change when you reformat the volume with another filesystem. But if you bring a volume to another machine and mount it there, you will always see the exact same volume serial number as on other machines where you have mounted the same volume.

 

If the serial number is what you actually wanted, you can get that for any volume using the "vol" command.

vol C:


#8 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 09 April 2014 - 05:18 PM

Hi

No I wanted this volume serial number (I think) - it is the same one used by grub4dos/syslinux/linux to identify partitions. Yes, VOL works too!



#9 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 10 April 2014 - 10:14 AM

Just for the record, the volume Serial number (as seen by vol or dir command) is ONLY accurate for FAT volumes.

 

The NTFS filesystem provides a longer Serial Number of which vol returns only the first (please read as last) part.

 

It can be read fine directly in the bootsector, 8 bytes at offset 0x48 for NTFS, 4 bytes at offset 0x43 for FAT32, 4 bytes at offset 0x27 for FAT16.

Example:

VOL command for a NTFS volume returns serial F897-57AC, real volume serial (as seen in a hex editor) AC 57 97 F8 65 97 F8 00 

See:

http://thestarman.pc.../mbr/NTFSBR.htm

 

:duff:

Wonko



#10 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 10 April 2014 - 11:04 AM

Thanks! I havent got round to testing NTFS yet.

 

Anyway that you can think of to easily get the NTFS serial number of an ImDisk volume?



#11 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 10 April 2014 - 11:46 AM

Thanks! I havent got round to testing NTFS yet.

 

Anyway that you can think of to easily get the NTFS serial number of an ImDisk volume?

Can't you directly read the RAW bootsector bytes?

 

Among the Windows command line commands you can use :

fsutil fsinfo ntfsinfo <volume>

please note how the output of 

fsutil fsinfo volumeinfo <volume>

will be the "short" serial.

 

WMI (at least on XP) returns also the "short" serial only:

wmic logicaldisk get name,volumeserialnumber

:duff:

Wonko



#12 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 10 April 2014 - 12:33 PM

I think direct read of the ramdisk first sector is going to be the only way. I need to just get the bytes into the correct format.

I need something that will work on a ramdrive and not a 'proper' disk though...



#13 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 10 April 2014 - 12:55 PM

I think direct read of the ramdisk first sector is going to be the only way. I need to just get the bytes into the correct format.
I need something that will work on a ramdrive and not a 'proper' disk though...

The Volume serial number is *something* attached to the volume (i.e. the whatever you access with a drive letter under windows), it does not make any difference whether it is a Ramdisk or not and if it is an Imdisk ramdisk or not, as long as it is formatted to NTFS, you just need to reverse the order.
 
Now, imagine ;) that you are using grub4dos, as an example:

uuid (hd1,0)
uuid (hd1,0) : UUID is CEC0A632C0A62127
Filesystem type is ntfs, partition type is 0x07
cat --hex --skip=0x48 --length=8 (hd1,0)0+1
00000048: 27 21 A6 C0 32 A6 C0 CE

This might do:
 
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
IF %1.==. ECHO Missing drive letter&GOTO :EOF

FOR /F "tokens=10,11,12,13,14,15,16,17 delims=- " %%A IN ('secinspect -dsec \\.\%1 0 1 ^| FIND "0x0040"') DO (
FOR %%? IN (%%H %%G %%F %%E %%D %%C %%B %%A) DO CALL :do_hex 0x%%?
)



VOL %1
SET Serial= Real volume serial: %Serial%
ECHO %Serial%
GOTO :EOF

:do_hex
SET /A dec=%1
CMD /C EXIT /B %dec%
SET "Serial=%Serial%%=ExitCode:~-2%"
GOTO :EOF
(making use of MS own SECINSPECT.EXE):
http://thestarman.pc...efs.htm#SecInsp
Script is made complex because the tool uses small letters instead of capitals in hex numbers (talking of "standards" :whistling:)
 
:duff:
Wonko

#14 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 10 April 2014 - 07:10 PM

Thanks a million for that crazy script!!!  It works!! :clap: You have saved me a lot of head scratching! I still haven't worked out how it works yet!

Anyway it's brilliant! Thanks!



#15 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 10 April 2014 - 07:18 PM

Thanks a million for that crazy script!!!  It works!! :clap: You have saved me a lot of head scratching! I still haven't worked out how it works yet!

Anyway it's brilliant! Thanks!

The "trick" is something that you can only learn once you have become a member of  the batch scripters club (and learned the secret handshake), but you may become a member honoris causa, so:

http://reboot.pro/to...eccmd/?p=136708

http://www.robvander...e.com/ntset.php

all credits go to "SmartGenius" :worship: and to Rob van der Woude :). (and to the Starman :thumbsup: for the reference to SECINSPECT.EXE, which I believe it is one of the least known MS utilities)

 

:duff:

Wonko



#16 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 11 April 2014 - 10:57 AM

Quick question

 

For a FAT serial number I currently use the VOL command. Is the words 'Serial Number'  displayed on Italian Windows?



#17 Olof Lagerkvist

Olof Lagerkvist

    Gold Member

  • Developer
  • 1448 posts
  • Location:Borås, Sweden
  •  
    Sweden

Posted 11 April 2014 - 11:04 AM



Quick question

 

For a FAT serial number I currently use the VOL command. Is the words 'Serial Number'  displayed on Italian Windows?

 

 

Output from "vol" on a Swedish Windows 7 box here:

C:\Users\ololag>vol C:

 Volymen i enhet C har etiketten OS

 Volymens serienummer är 78BD-5EBA

So, the answer to a question similar to yours is "no". The term "serial number" gets translated into the language used in Windows.



#18 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 3041 posts
  • Location:Nantes - France
  •  
    France

Posted 11 April 2014 - 11:25 AM

and in French 

C:\>vol e:
 Le volume dans le lecteur E s'appelle NONAME
 Le numéro de série du volume est 1122-3344

so from one langage to another, the only common character would be the "-" I guess.



#19 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 11 April 2014 - 11:40 AM

Thanks, I can't even count words!

 

does ImDisk always use English messages when formatting a ramdisk or is the local Windows used?

 

e.g.

imdisk -a -s 40m -m U:  -p "/FS:FAT32 /Q /Y"

 

F:\MakePartImage>imdisk -a -s 40m -m U: -p "/FS:FAT32 /Q /Y"
Creating device...
Created device 1: U: -> VM image
Formatting disk...
The type of the file system is FAT32.
QuickFormatting 38.1 MB
Volume dismounted.  All opened handles to this volume are now invalid.
Initializing the File Allocation Table (FAT)...
Format complete.
      34.1 MB total disk space.
      34.1 MB are available.

          512 bytes in each allocation unit.
       69,932 allocation units available on disk.

           32 bits in each FAT entry.

Volume Serial Number is 8E8D-2433
Notifying applications...
Done.



#20 Olof Lagerkvist

Olof Lagerkvist

    Gold Member

  • Developer
  • 1448 posts
  • Location:Borås, Sweden
  •  
    Sweden

Posted 11 April 2014 - 11:54 AM

Thanks, I can't even count words!
 
does ImDisk always use English messages when formatting a ramdisk or is the local Windows used?


In practice, no. ImDisk itself only prints English messages. But what you see there is output from format.com which imdisk.exe calls to format the volume and messages from format.com are localised.

#21 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 11 April 2014 - 12:28 PM

OK, thanks, I will have to use a secinspect script for FAT32 Serial number too then.



#22 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 11 April 2014 - 12:29 PM

@Steve

Two things.

To parse correctly the output of VOL and Format (internationally) you can use something like:

@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
IF %1.==. ECHO Missing drive letter&GOTO :EOF
FOR /F "tokens=* delims=" %%? IN ('VOL %1 ^| FIND "-"') DO CALL :do_serial %%?
ECHO Serial is: %Serial%
GOTO :EOF

:do_serial
IF %2.==. SET Serial=%1&GOTO :EOF
SHIFT
GOTO :do_serial
GOTO :EOF

(we take advantage of the fact that the serial has "minus" or "hyphen" and is always last token in the output line)

About FORMAT, if invoked directly (JFYI) there is an issue with some international versions (including French) see here:

http://reboot.pro/to...ional-format-y/

but I believe that if it is invloked through IMDISK the /y remains the same everywhere :unsure:

 

:duff:

Wonko



#23 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 11 April 2014 - 01:48 PM

Thanks, but as I can't be sure that some language doesn't hyphenate any text output by VOL, I have now used secinspect for both NTFS and FAT32.

cheers

Steve



#24 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 11 April 2014 - 02:25 PM

Thanks, but as I can't be sure that some language doesn't hyphenate any text output by VOL, I have now used secinspect for both NTFS and FAT32.

cheers

Steve

Yep, but, just for the record, one could use FINDSTR instead of FIND, this:

VOL E:|findstr /R /C:"[0-9A-F][0-9A-F][0-9A-F][0-9A-F]\-[0-9A-F][0-9A-F][0-9A-F][0-9A-F]$"

is pretty much "restrictive".

 

:duff:

Wonko



#25 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 11 April 2014 - 02:26 PM

nice :good:






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users