Jump to content











Photo
- - - - -

Folder as a mount point


  • Please log in to reply
4 replies to this topic

#1 Sophia

Sophia

    Member

  • Members
  • 85 posts
  •  
    Netherlands

Posted 13 April 2011 - 03:24 PM

Today I decided to try out using a folder instead of a drive letter as a mount point - the feature is really cool and can be very handy. I will briefly recap what I tried and what happened...

First, I tried to mount the drive to "C:\VD", a folder location which didn't exist and I got an error:

Error creating mount point: The system cannot find the file specified.
Warning: The device is created without a mount point.


I found this a bit confusing, so I decided to create the "VD" folder on C: and see what would happen then. Perhaps its just me, but I was really surprised when this worked out without errors. So here comes my first question:

Why does the path to which I am trying to mount the virtual drive has to already exist? Again, maybe it is just me and my ignorance, but this sounds a bit paradoxical. The immediate question I had was what happened to the previous contents of the "VD" folder? Did they get deleted, or temporary hidden until the virtual drive junction is removed?

I could have found out the latter myself, but I couldn't figure out a way to undo what I created. When I called "imdisk -d -u 0" it removed to the virtual drive device, but by the looks of it has left the junction. Is this a bug and the junction should have been removed with the removal of the virtual drive, or is this the intended behaviour, in which case how can I manually remove the junction? What worked for me is just deleting the "VD" folder, but now I am not even sure what I actually deleted - the junction, the previous folder, or maybe both?

The reason I started experementing with this feature is that I wanted a way to "prepare" the virtual drive image, without making it visible as a drive in My Computer, so I have a couple more questions on this subject:

Is it ok to specify formatting options (-p parameter) with folder as a mount point, or will it not work? I didn't want to just try it out, in case I format my C: by mistake :happy_dance:

When I first got the error because the path was invalid, here is the full log of what happened:

Creating device...
Error creating mount point: The system cannot find the file specified.
Warning: The device is created without a mount point.
Created device 0: -> VM image
Done.


Does that mean that the virtual drive was created after all and could be accessed via "\Device\ImDisk0\Partition0\..." or something like that? If so, could you tell me more how to actually do it. I noticed that ImDisk can, using the "-F" parameter, use "NT-style" paths and access the file system even if a device does not have a mount point. Could you briefly tell me how it actually works, or maybe give me a link where I can find out more about this. How many of the standard Windows API functions can work with the "NT-style" path? For example do functions like CreateFile or FindFirst support it?

Ultimately, what I am looking for a is easy and convenient way to prepare the virtual drive image, without exposing it to the user as a drive, before it is ready.

#2 Olof Lagerkvist

Olof Lagerkvist

    Gold Member

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

Posted 13 April 2011 - 05:34 PM

Today I decided to try out using a folder instead of a drive letter as a mount point - the feature is really cool and can be very handy. I will briefly recap what I tried and what happened...

First, I tried to mount the drive to "C:\VD", a folder location which didn't exist and I got an error:

Error creating mount point: The system cannot find the file specified.
Warning: The device is created without a mount point.


I found this a bit confusing, so I decided to create the "VD" folder on C: and see what would happen then. Perhaps its just me, but I was really surprised when this worked out without errors. So here comes my first question:

Why does the path to which I am trying to mount the virtual drive has to already exist? Again, maybe it is just me and my ignorance, but this sounds a bit paradoxical. The immediate question I had was what happened to the previous contents of the "VD" folder? Did they get deleted, or temporary hidden until the virtual drive junction is removed?


Most of the above are more or less general questions about Windows reparse points and not ImDisk specific. Short explanation: Yes, the subdirectory needs to already exist and it needs to be empty. If you remove the subdirectory you actually just remove the empty directory and the link to the target filesystem but nothing at the target filesystem is touched.

For other "Volume Mount Manager-participating" disk drivers in Windows you use the mountvol command to create and remove subdirectory mount points as well as drive letter mount points. ImDisk does essentially the same thing with its own disk device objects as targets when you specify a subdirectory as mount point.

You can read more about reparse points in general and specifically junction-style reparse points on many places on the Internet. Here are a few to start with:
http://msdn.microsof...a363940(v=VS.85).aspx
http://msdn.microsof...y/aa365511.aspx
http://msdn.microsof...a364595(v=VS.85).aspx
http://support.microsoft.com/kb/205524

I could have found out the latter myself, but I couldn't figure out a way to undo what I created. When I called "imdisk -d -u 0" it removed to the virtual drive device, but by the looks of it has left the junction. Is this a bug and the junction should have been removed with the removal of the virtual drive, or is this the intended behaviour, in which case how can I manually remove the junction? What worked for me is just deleting the "VD" folder, but now I am not even sure what I actually deleted - the junction, the previous folder, or maybe both?

The reason I started experementing with this feature is that I wanted a way to "prepare" the virtual drive image, without making it visible as a drive in My Computer, so I have a couple more questions on this subject:

Is it ok to specify formatting options (-p parameter) with folder as a mount point, or will it not work? I didn't want to just try it out, in case I format my C: by mistake :)


Unfortunately both format and chkdsk commands in Windows require a drive letter as mount point. They can be used for other disk devices mounted to subdirectories if that disk device is registered through Volume Mount Manager though, but that will not work for ImDisk drives. But you can create a temporary drive letter just during the format process using for example my dosdev tool, more about that a bit further down in this post. (There have been a few threads about this particular matter before here, so you could search the forum archive too.)

When I first got the error because the path was invalid, here is the full log of what happened:

Creating device...
Error creating mount point: The system cannot find the file specified.
Warning: The device is created without a mount point.
Created device 0: -> VM image
Done.


First the virtual disk device is created. Then the control program tries to create a subdirectory reparse point to point to the newly created device and that fails because the directory does not exist. It then displays a warning message to tell you that the virtual disk device was created successfully but you did not get a mount point for it. That is exactly like you would not have specified any -m parameter at all. You can remove the virtual disk again if you use the command:
imdisk -d -u 0

Otherwise you can manually create a mount point. I have two different tools for this on my website, one for drive letters and one for subdirectory mount points, so:
dosdev -r R: \Device\ImDisk0
This creates drive letter R for ImDisk device nummber 0.
junc C:\VM \Device\ImDisk0\
This creates a subdirectory mountpoint by linking C:\VM to ImDisk device number 0.

You should specify the mountpoint when you are later removing the virtual disk:
imdisk -d -m C:\VM
Otherwise if you use -u 0 the mount point will be left pointing to a non-existing device object. There is unfortunately no way for ImDisk to know which subdirectory mount points have been created for the disk you are about to remove. On the other hand, it could sometimes be useful to leave a subdirectory pointing to a removed ImDisk device. Next time you create an ImDisk drive with the same device number the mount point will automatically work again. This could be useful if you for example auto-create virtual disk at system startup and similar things.

Does that mean that the virtual drive was created after all and could be accessed via "\Device\ImDisk0\Partition0\..." or something like that? If so, could you tell me more how to actually do it. I noticed that ImDisk can, using the "-F" parameter, use "NT-style" paths and access the file system even if a device does not have a mount point. Could you briefly tell me how it actually works, or maybe give me a link where I can find out more about this. How many of the standard Windows API functions can work with the "NT-style" path? For example do functions like CreateFile or FindFirst support it?


You are mixing a few things up here. The -F parameter and NT-style native paths are about the image file that ImDisk uses to create the virtual disk, it has nothing to do with any mount point it would create for it.

#3 Sophia

Sophia

    Member

  • Members
  • 85 posts
  •  
    Netherlands

Posted 13 April 2011 - 06:00 PM

Thank you very much for answering all the questions with so much detail and for the links, Olof.

I am sorry if the some of the questions were already asked here before - next time I will check previous forum posts more thoroughly. :)

#4 Sophia

Sophia

    Member

  • Members
  • 85 posts
  •  
    Netherlands

Posted 13 April 2011 - 06:12 PM

I tried what you suggested and with your explanation now everything makes sense and works flawlessly. My apologies for suggesting that there might be something wrong with ImDisk - next time I will start with the assumption that I am doing something wrong :)

#5 Olof Lagerkvist

Olof Lagerkvist

    Gold Member

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

Posted 13 April 2011 - 06:22 PM

I am just glad to hear that you find it useful. :)
:cheers:




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users