Jump to content











Photo
- - - - -

Mount a disk to a share (instead of a drive letter)

imdisk mount share

  • Please log in to reply
11 replies to this topic

#1 ZEE

ZEE

    Member

  • Members
  • 98 posts
  •  
    Portugal

Posted 26 November 2012 - 08:59 PM

Hi ppl...

been using imdisk recently because it's small/portable/useful... thanks again Olof!!! :good:

One thing I do often is mount a disk to a drive letter and then share it,,, :dubbio:
Most of the times I dont even need the drive letter... :dubbio:

My suggestion is to permit mounting a disk directly to a share... :book:

imdisk -a -f "mydisk1.vhd" -m myshare1 -user myuser-or-group

myshare should be expanded to mymachinemyshare
myuser-or-group is a windows user or group with ReadOnly access to the share
maybe some cli switches to gave other permissions besides readonly...

Edited by ZEE, 26 November 2012 - 09:11 PM.


#2 Sha0

Sha0

    WinVBlock Dev

  • Developer
  • 1682 posts
  • Location:reboot.pro Forums
  • Interests:Booting
  •  
    Canada

Posted 26 November 2012 - 10:07 PM

Hi ppl...

been using imdisk recently because it's small/portable/useful... thanks again Olof!!! :good:

One thing I do often is mount a disk to a drive letter and then share it,,, :dubbio:
Most of the times I dont even need the drive letter... :dubbio:

My suggestion is to permit mounting a disk directly to a share... :book:

imdisk -a -f "mydisk1.vhd" -m myshare1 -user myuser-or-group

myshare should be expanded to mymachinemyshare
myuser-or-group is a windows user or group with ReadOnly access to the share
maybe some cli switches to gave other permissions besides readonly...

Please take a look at HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServiceslanmanserverShares and you might find out a bit about how shares work.

Unfortunately, creating a share directly to DeviceImDisk0 does not work; another intermediary would be needed. Such an intermediary could be created with the DefineDosDevice function, but it would have to be called in the context of the LanManServer service (possibly under svchost.exe -k netsvcs). Alternatively, the intermediary could be a global link established under HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerDOS Devices (but that requires a reboot.)

You could try the following .REG patch, then reboot, then attach the virtual disk with ImDisk, then try the share out:

Windows Registry Editor Version 5.00



[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerDOS Devices]

"ImDiskShare"="DeviceImDisk0"



[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServiceslanmanserverShares]

"ImDiskShare"=hex(7):43,00,53,00,43,00,46,00,6c,00,61,00,67,00,73,00,3d,00,30,

00,00,00,4d,00,61,00,78,00,55,00,73,00,65,00,73,00,3d,00,34,00,32,00,39,00,

34,00,39,00,36,00,37,00,32,00,39,00,35,00,00,00,50,00,61,00,74,00,68,00,3d,

00,5c,00,5c,00,3f,00,5c,00,49,00,6d,00,44,00,69,00,73,00,6b,00,53,00,68,00,

61,00,72,00,65,00,00,00,50,00,65,00,72,00,6d,00,69,00,73,00,73,00,69,00,6f,

00,6e,00,73,00,3d,00,30,00,00,00,52,00,65,00,6d,00,61,00,72,00,6b,00,3d,00,

49,00,6d,00,44,00,69,00,73,00,6b,00,30,00,20,00,54,00,65,00,73,00,74,00,20,

00,53,00,68,00,61,00,72,00,65,00,00,00,54,00,79,00,70,00,65,00,3d,00,30,00,

00,00,00,00



[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServiceslanmanserverSharesSecurity]

"ImDiskShare"=hex:01,00,04,80,44,00,00,00,60,00,00,00,00,00,00,00,14,00,00,00,02,00,

30,00,02,00,00,00,00,00,14,00,a9,00,12,00,01,01,00,00,00,00,00,05,07,00,00,

00,00,00,14,00,a9,00,12,00,01,01,00,00,00,00,00,01,00,00,00,00,01,05,00,00,

00,00,00,05,15,00,00,00,79,e3,fc,53,fa,4b,9e,18,43,17,0a,32,f4,01,00,00,01,

05,00,00,00,00,00,05,15,00,00,00,79,e3,fc,53,fa,4b,9e,18,43,17,0a,32,01,02,

00,00



(I haven't tested this.)
It doesn't seem to work.
  • ZEE likes this

#3 ZEE

ZEE

    Member

  • Members
  • 98 posts
  •  
    Portugal

Posted 26 November 2012 - 10:38 PM

Hi "WinVBlock Dev"

I've already automated the works...

in a script
1. first I mount the filedisk with imdisk
2. with net share create the share to that disk and set permissions to users/groups

the problem is if I mount the filedisk to the next available drive letter I must add further code to find the drive letter to share... ;-))
it will be nice if this is done all in the imdisk...

#4 Sha0

Sha0

    WinVBlock Dev

  • Developer
  • 1682 posts
  • Location:reboot.pro Forums
  • Interests:Booting
  •  
    Canada

Posted 26 November 2012 - 10:58 PM

the problem is if I mount the filedisk to the next available drive letter I must add further code to find the drive letter to share... ;-))
it will be nice if this is done all in the imdisk...

Sorry, I thought you were trying to avoid using a drive letter entirely, because I misunderstood the following:

My suggestion is to permit mounting a disk directly to a share... :book:


  • ZEE likes this

#5 ZEE

ZEE

    Member

  • Members
  • 98 posts
  •  
    Portugal

Posted 27 November 2012 - 12:34 PM

Sorry, I thought you were trying to avoid using a drive letter entirely, because I misunderstood the following:


You're right... If possible I want to avoid using a drive letter (thanks for your insight on this)...

#6 ZEE

ZEE

    Member

  • Members
  • 98 posts
  •  
    Portugal

Posted 27 November 2012 - 01:12 PM

You're right... If possible I want to avoid using a drive letter (thanks for your insight on this)...


I thought the WinAPI gurus could have already found some way of pointing a share directly to .DeviceHardDisk0Partition1MyDir :chair:

Anyway... some knowledge can be extracted from here... Thanks again Sha0/WinVBlock Dev... :lightbulb:

#7 Olof Lagerkvist

Olof Lagerkvist

    Gold Member

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

Posted 27 November 2012 - 02:17 PM

Interesting topic!

Sha0, I think you are on the right way with the registry settings. I have seen that there are ways to share a native path. For example, SQL Server does that when it shares a special filesystem it has for filestream database access. When I look at my SQL Server Express 2008 now, I have a share named SQLEXPRESS with these registry settings:

CSCFlags=48

MaxUses=4294967295

Path=\\?\GLOBALROOT\Device\RsFx0151\<localmachine>\SQLEXPRESS

Permissions=0

Remark=SQL Server FILESTREAM share

Type=0


Now, they do not assign a drive letter or similar to their \Device\RsFx0151 virtual device. It looks like they use the "GLOBALROOT" symbolic link to reach this device and a particular path under it. (In this case it is a virtual filesystem driver, so the path, in this case, is probably just some kind of parameter sent to the filesystem driver to connect to a particular SQL Server instance.)

Could the same be done with ImDisk? It looks like that. I tried:

CSCFlags=48

MaxUses=4294967295

Path=\\?\GLOBALROOT\Device\ImDisk0\

Permissions=0

Remark=SQL Server FILESTREAM share

Type=0


This seems to work as far as I can see. Notice the trailing backslash on the device path. To access a root folder on a disk device with native path, you need a trailing backslash. Otherwise you would just open the disk device itself and not the root folder.

Now, it seems impossible to script this with net share calls, since they do not seem to accept the \\.\GLOBALROOT syntax. Maybe it would be possible to call NetShareAdd API directly.

Another approach for O.P. to avoid drive letters, could be to mount the ImDisk drive to a subdirectory on an NTFS volume and then share that subdirectory:

imdisk -a -f "mydisk1.vhd" -m C:\mountpoints\mydisk
net share mydisk=C:\mountpoints\mydisk

This is probably the easiest way to solve this.
  • ZEE likes this

#8 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 27 November 2012 - 02:35 PM

Random thought :w00t:, but maybe through WMI/WMIC it is possible.
Name would be \\.\GLOBALROOT\ instead of \\?\GLOBALROOT\ but it may work in something *like*:

http://serverfault.c...-using-vbscript
http://www.activexpe...etworkShare.htm

Only marginally related:
http://pauldotcom.co...---the-los.html

:cheers:
Wonko

#9 Sha0

Sha0

    WinVBlock Dev

  • Developer
  • 1682 posts
  • Location:reboot.pro Forums
  • Interests:Booting
  •  
    Canada

Posted 27 November 2012 - 05:27 PM

When I look at my SQL Server Express 2008 now, I have a share named SQLEXPRESS with these registry settings:


CSCFlags=48

MaxUses=4294967295

Path=?GLOBALROOTDeviceRsFx0151<localmachine>SQLEXPRESS

Permissions=0

Remark=SQL Server FILESTREAM share

Type=0


Now, they do not assign a drive letter or similar to their DeviceRsFx0151 virtual device. It looks like they use the "GLOBALROOT" symbolic link to reach this device and a particular path under it.

Yay, GLOBALROOT! I totally forgot about it. Very nice find! :)
  • wimb likes this

#10 ZEE

ZEE

    Member

  • Members
  • 98 posts
  •  
    Portugal

Posted 28 November 2012 - 07:09 PM

Do you know any utility that permit us to test interactively with WMI/WMIC... besides powershell... something more assisted perhaps?
:devil: :fish: :innocent:

#11 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 28 November 2012 - 07:21 PM

Do you know any utility that permit us to test interactively with WMI/WMIC... besides powershell... something more assisted perhaps?
:devil: :fish: :innocent:

Yes and no, meaning that there is an "automagic" tool by MS which can produce a "skeleton" in an easier manner, but you need anyway to test/debug manually AFAIK.
See here (everything you wanted to know about WMI/WMIC and dared to ask about):
http://www.robvander...om/wmistart.php
The Scriptomatic tool is here:
http://www.microsoft...s.aspx?id=12028

:cheers:
Wonko
  • ZEE likes this

#12 ZEE

ZEE

    Member

  • Members
  • 98 posts
  •  
    Portugal

Posted 01 December 2012 - 02:29 AM

ahh,,, Rob's site.... long time no visit... has been one of my favorites for script information...

thx...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users