Digg this topic Add to my del.icio.us Submit to SlashDot 3 Pages V   1 2 3 >  
Reply to this topicStart new topic
> ImDisk commandline script to create/mount RamDisk, from regular Windows OS
bilou_gateux
post Jun 17 2007, 02:02 PM
Post #1


Advanced Member
***

Group: Advanced user
Posts: 68
Joined: 1-August 06
Member No.: 97


France


I have created the smallest possible image file (4M) formated as NTFS and compressed called RD32.img.
RD32.img is then cab'ed with this command:
makecab /D CompressionType=LZX /D CompressionMemory=21 /D Cabinet=ON /D Compress=ON RD32.img
File size after cab compression about 146Kb

I use this script to install and mount this RamDisk and extend it to 64M. the RD32.img is prefilled with some predefined dirs like \Temp
CODE
imdiskinst -y
regedit /S RD32.reg
:# this folder already exist on regular Windows install and is compressed with NTFS file system.
:# comments these 2 lines below
if not exist %SystemRoot%\system32\dllcache md %SystemRoot%\system32\dllcache
compact /C /S:%SystemRoot%\system32\dllcache
extrac32 /Y /E /L %SystemRoot%\system32\dllcache RD32.cab
net start imdisk
dosdev -r Z: \Device\ImDisk0
imdisk -e -s 60M -m Z:


RD32.reg
CODE
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\ImDisk\Parameters]
"Flags0"=dword:00000200
"FileName0"="\\SystemRoot\\system32\\dllcache\\rd32.img"
"LoadDevices"=dword:00000001


If i check from the imdisk cpl, I have:
Image file: Virtual memory, from \SystemRoot\rd32.img Size 64MB Properties: Read/write
Z: isn't shown in the Drive column and FileSystem isn't detected although i can access from Windows Explorer to the Z: drive formated as NTFS compressed. Clicking the Refresh button doesn't change anything.
Go to the top of the page
 
+Quote Post
Olof Lagerkvist
post Jun 17 2007, 04:23 PM
Post #2


Advanced Member
***

Group: Developer
Posts: 120
Joined: 27-April 07
From: Borås, Sweden
Member No.: 6,234


Sweden


Interesting, this was about what I had in mind when I wrote the auto-loading code in the driver. It has been there for a long time now but never really been used to anything useful so it is good to see this being used now. (IMG:http://www.boot-land.net/forums/style_emoticons/default/thumbsup.gif)
QUOTE (bilou_gateux @ Jun 17 2007, 04:02 PM) *
If i check from the imdisk cpl, I have:
Image file: Virtual memory, from \SystemRoot\rd32.img Size 64MB Properties: Read/write
Z: isn't shown in the Drive column and FileSystem isn't detected although i can access from Windows Explorer to the Z: drive formated as NTFS compressed. Clicking the Refresh button doesn't change anything.

That is correct from the driver's point of view even if it might look misleading to the user... The ImDisk driver does not "know" in this case that the drive has a driveletter because the drive was not created from a user mode tool that told it anything about a drive letter... (IMG:http://www.boot-land.net/forums/style_emoticons/default/ermm.gif)

It can't know that you have assigned a drive letter from another program so from the driver's point of view the drive does not have an assigned drive letter. Unfortunately this also means that it cannot check which filesystem it is formatted with because the function for checking filesystem needs a drive letter path... (IMG:http://www.boot-land.net/forums/style_emoticons/default/dubbio.gif)

Unfortunately the design of the driver/GUI components was not really made with this special situation in mind. Basically you have the same situation in Windows when you for example use Disk Management to remove the drive letter for a harddisk partition on your computer and then use dosdev -r to manually assign a drive letter to it again. That new drive letter will be immediately usable and will turn up in Windows Explorer but the Disk Management will still say that the partition does not have a drive letter.
Go to the top of the page
 
+Quote Post
bilou_gateux
post Sep 4 2007, 08:29 AM
Post #3


Advanced Member
***

Group: Advanced user
Posts: 68
Joined: 1-August 06
Member No.: 97


France


Olof,

Another question related to command line:

when i use these switches:
imdisk -a -m H: -F \device\Harddisk0\Partition2\temp\blank.img
error message:
Error creating virtual disk:
The volume does not contain a recognized file system. Please make sure that all required file system drivers are loaded and that the volume is not corrupted.

I can successfully mount the same image from the control panel applet. Image is already formated with NTFS filesystem.

next purpose is to mount this image at startup with registry imdisk parameters:
CODE
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ImDisk\Parameters]
"Flags0"=dword:00000800
"FileName0"="\\device\\Harddisk0\\Partition2\\temp\\blank.img"
"LoadDevices"=dword:00000001


Is the FileName0 data value syntax correct?
Go to the top of the page
 
+Quote Post
Olof Lagerkvist
post Sep 4 2007, 11:16 AM
Post #4


Advanced Member
***

Group: Developer
Posts: 120
Joined: 27-April 07
From: Borås, Sweden
Member No.: 6,234


Sweden


Hello,

QUOTE (bilou_gateux @ Sep 4 2007, 10:29 AM) *
when i use these switches:
imdisk -a -m H: -F \device\Harddisk0\Partition2\temp\blank.img
error message:
Error creating virtual disk:
The volume does not contain a recognized file system. Please make sure that all required file system drivers are loaded and that the volume is not corrupted.

I can successfully mount the same image from the control panel applet. Image is already formated with NTFS filesystem.

First of all, the error message does not mean that the image does not contain a valid filesystem, it means that \Device\Harddisk0\Partition2 does not contain a valid filesystem. If you try -f and the drive letter path instead of -F and native path it will probably work from the command line too.

I would think that your problem is that the partition with the image file is not really \Device\Harddisk0\Partition2, but something else. Keep in mind that harddisks are numbered from 0 and that partitions are numbered from 1 (partition 0 means the entire disk) and also that an extended partition gets a partition number itself, and the following numbers are the actual logical drives within the extended partition.

I would suggest one of the following:
* Check with a tool such as SysInternals winobj which disk volume object the object \Device\Harddisk0\Partition2 is linked to and compare that to which volume the drive letter under \GLOBAL?? is linked to. You should be able to find out that way.
* Switch to using the disk volume object, such as \Device\HarddiskVolume2 or something like that. You can use the winobj tool to find out which object the drive letter object is linked to or you can use my dosdev command line tool, for example
CODE
dosdev -q E:

This will give you the device object the drive letter is linked to.
* Switch to using drive letter even in the native path, if the image file is E:\temp\blank.img you can use \??\E:\temp\blank.img as a native path.

QUOTE (bilou_gateux @ Sep 4 2007, 10:29 AM) *
next purpose is to mount this image at startup with registry imdisk parameters:
Is the FileName0 data value syntax correct?

Yes.
Go to the top of the page
 
+Quote Post
bilou_gateux
post Sep 4 2007, 01:28 PM
Post #5


Advanced Member
***

Group: Advanced user
Posts: 68
Joined: 1-August 06
Member No.: 97


France


As usual, thanks for your fast answer.
Even big company like m$ft can't give us a good support as you.

1st partition is Boot/System partition protected by Enhanced Write Filter.
2nd partition is a type 45 partition for EWF type disk overlay (Microsoft Shared computer Toolkit). Not formated with a known filesystem.
The 3rd one is my DATA partition with temp dir.

I was sure i was doing something wrong but were unable to find my error. (IMG:http://www.boot-land.net/forums/style_emoticons/default/thumbdown.gif)

Command line runs fine using switch:
-F \device\Harddisk0\Partition3\temp\blank.img
Go to the top of the page
 
+Quote Post
jaclaz
post Sep 4 2007, 02:15 PM
Post #6


Finder
***

Group: Advanced user
Posts: 1,581
Joined: 14-July 06
Member No.: 2


Italy


[OUT OF TOPIC] (but not much) (IMG:http://www.boot-land.net/forums/style_emoticons/default/wink.gif) :

The DSFOK toolkit has a handy tool to check drive names:
QUOTE
6) vlm

vlm scans the volumes of a computer and reports detailed info.

Found volumes: (sample output)

\\.\Volume{ac837e60-551d-11d9-9a3c-806d6172696f}
Label: (none), File System: FAT32 4995/2000 MB
Symbolic Link: \Device\HarddiskVolume1


This batch (though slow) might help in identifying volumes/driveletters:
CODE
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
SET /A Counter=0
For /F "skip=4 tokens=* delims=" %%I IN ('vlm.exe') DO (
SET /A Counter=!Counter!+1
SET line=%%I
IF !Counter!==1 SET Number=%%I
SET Number=!Number:.=?!
IF !Counter!==2 SET Label=%%I
IF !Counter!==3 SET Symb=%%I
IF !Counter!==3 (
SET /A Counter=0
For %%A IN (C D E F G H I J K L M N O P Q R S T U V X Y Z) DO (
SET VOL=%%A:
FOR /F %%B IN ('Mountvol !VOL! /L ^|FIND "!Number!"') DO (
ECHO.
ECHO !VOL! %%B
ECHO !VOL! !Label!
ECHO !VOL! !Symb!
)
)
)
)


How can one find the other names like
\device\Harddiskx\Partitiony\ ??

(IMG:http://www.boot-land.net/forums/style_emoticons/default/unsure.gif)

jaclaz
Go to the top of the page
 
+Quote Post
MedEvil
post Sep 4 2007, 02:47 PM
Post #7


Advanced Member
***

Group: .script developer
Posts: 1,803
Joined: 29-December 06
Member No.: 2,192



QUOTE (jaclaz @ Sep 4 2007, 04:15 PM) *
How can one find the other names like
\device\Harddiskx\Partitiony\ ??

If you're using Windows, why not simply read the registry?

(IMG:http://www.boot-land.net/forums/style_emoticons/default/cheers.gif)
Go to the top of the page
 
+Quote Post
jaclaz
post Sep 4 2007, 04:08 PM
Post #8


Finder
***

Group: Advanced user
Posts: 1,581
Joined: 14-July 06
Member No.: 2


Italy


QUOTE (Medevil)
If you're using Windows, why not simply read the registry?

Sure,
but WHERE in the Registry? (IMG:http://www.boot-land.net/forums/style_emoticons/default/unsure.gif)

The only way I found was using DMDIAG.EXE:
http://technet2.microsoft.com/windowsserve...3.mspx?mfr=true

jaclaz
Go to the top of the page
 
+Quote Post
MedEvil
post Sep 4 2007, 04:18 PM
Post #9


Advanced Member
***

Group: .script developer
Posts: 1,803
Joined: 29-December 06
Member No.: 2,192



QUOTE (jaclaz @ Sep 4 2007, 06:08 PM) *
Sure,
but WHERE in the Registry?

Depending on what you want in hklm\System\MountedDevices or hklm\system\currentcontrolset.
With hklm\System\MountedDevices you find the DriveLetter, DriveName and most importantly the VolumeID.
And with the VolumeID you can search the registry for all other informations Windows has on that Device.

(IMG:http://www.boot-land.net/forums/style_emoticons/default/cheers.gif)
Go to the top of the page
 
+Quote Post
jaclaz
post Sep 4 2007, 04:59 PM
Post #10


Finder
***

Group: Advanced user
Posts: 1,581
Joined: 14-July 06
Member No.: 2


Italy


@Medevil

As far as I know in Mounted Devices you get only drive letters and VolumeID. (and "coupling" them is not that easy)

And in currentcontrolset I don't know where and what to look for.

QUOTE (Medevil)
And with the VolumeID you can search the registry for all other informations Windows has on that Device.

The point is that as far as I know with the VolumeId one can "search for all other informations" but cannot find:
1) the arcpath link
2) the \Device\HarddiskVolumen symlink
3) the \device\Harddiskx\Partitiony\ symlink

Does that mean that you also don't know how to do it? (IMG:http://www.boot-land.net/forums/style_emoticons/default/confused1.gif)

In other words, WHERE? means that I would like to get informations about WHERE and HOW to find it, not generic references to the Registry, to a Registry hive or the advice to search for it. (IMG:http://www.boot-land.net/forums/style_emoticons/default/frusty.gif)

jaclaz
Go to the top of the page
 
+Quote Post

3 Pages V   1 2 3 >
Fast ReplyReply to this topicStart new topic

Members Who Viewed Topic Today ()

 

RSS Lo-Fi Version Time is now: 27th February 2008 - 05:07 PM

MKPortal ©2003-2006 mkportal.it