Linux is to mount as Windows is to _______?

39

12

So Linux "mounts" a hard drive to perform some operation such as reading/writing. Does Windows "mount" in the same way?

Is it called something different in the context of Microsoft?

Chad Harrison

Posted 2012-05-14T15:46:24.790

Reputation: 5 759

9

Windows mounts automatically, and therefore no explicit tool is exposed to regular users. Many Linux desktop environments do this as well by default. For the mounting concept, you could see the Wikipedia entry. In short, mounting a device exposes access to the file system that it contains. This has to be done to be able to access files through a file system, no matter what the OS is called.

– Daniel Andersson – 2012-05-14T15:58:02.487

Answers

86

If you know Windows internals, do fix my errors, please.

"Mounting" consists of two primary parts, which are the same in both systems but their separation is somewhat different:

  1. accessing the filesystem on disk;
  2. assigning a path to the filesystem.

On Linux, the same mount() function does both jobs; a filesystem has to be mounted explicitly on a user-chosen path and remains opened as long as it is mounted on at least one path (possibly more). Once all paths to that filesystem are umount()ed, it is closed.

Windows mounts volumes automatically when the volume appears – it immediately opens the filesystem and assigns a drive letter and/or any other configured names to it.

A disk can be temporarily "dismounted" using the FSCTL_LOCK_VOLUME and/or FSCTL_DISMOUNT_VOLUME ioctl functions – for example, while running a chkdsk on it – but is automatically mounted again when the program unlocks it or exits. This behavior could be viewed as kind of opposite to Linux. Since dismounting a filesystem is temporary, it retains the assigned names even while dismounted. (The "Safely Remove" function dismounts the filesystem and disables the underlying device, to prevent Windows from seeing the filesystem and remounting it.)

A filesystem can have several names assigned to it:

  • Drive letters (A:, C:, [:) – automatically assigned to new disks and lost on reboot, although Windows remembers assignments configured by the user. In this way, they are similar to Unix mountpoints.

    (Drive letters can also be assigned to arbitrary devices, including network filesystems supported by Windows. You can see their targets at \GLOBAL??\ and \Sessions\<session>\DosDevices\<loginid>\ in WinObj.)

    Note: Drive letters are normally system-wide, but they can also be assigned session-wide using subst or DefineDosDevice(), and yes, it accepts [:. The session-wide assignments are never stored anywhere and vanish on reboot.

  • Folder mount points (C:\Disks\Music) – a filesystem can be mounted on any arbitrary directory, like in Unix; however, they are actually stored on the target disk, in the form of reparse points (a more powerful form of symlinks) which refer to the mounted disk by its volume name.

    (Different kinds of reparse points also exist; a few standard ones are mount points, symlinks, directory junctions.)

  • Volume GUID paths (\\?\Volume{710308c0-978e-11e1-95bc-806d6172696f}\) (at least that's how it seems to be called) – special paths in the Win32 namespace \\?\, containing an UUID that Windows assigns to that particular volume on this particular Windows system. They cannot be changed. They are listed by mountvol, or under \GLOBAL??\ in WinObj. Unlike drive letters, these are the same for all users.

  • Device interface paths \\?\STORAGE#Volume#<something>Signature<hex>Offset<hex>Length<hex>#<uuid>\ Unlike a volume GUID path, each volume has exactly one device interface path.

    • Volume device name \Device\HarddiskVolume23 - unlike all the previous ones, which are just symbolic links, this directly names the volume. You know this because it's in the \Device namespace, not the \\? namespace. That also means you can't use it with functions such as CreateFile.

diskmgmt.msc, mountvol and diskpart can manage both drive letters and mount points.

Even when a volume doesn't have any drive letters and isn't "mounted" on any folder, it remains open and its contents can still be accessed through its volume name; e.g.

\\?\Volume{710308c0-978e-11e1-95bc-806d6172696f}\Windows\Explorer.exe

user1686

Posted 2012-05-14T15:46:24.790

Reputation: 283 655

4[:..? Really? – Daniel Beck – 2012-05-14T16:23:53.483

11@DanielBeck: Yes, DefineDosDevice() accepts practically anything, although you won't have much luck convincing most applications to accept it. Try subst [: C:\Users, then dir [: – user1686 – 2012-05-14T16:26:48.527

Somebody upvote this answer. I went for my "Vox Populi" badge today and have no upvotes availabe to add to this excelent answer. – Chad Harrison – 2012-05-14T16:45:05.463

@hydroparadise: NEVER! – Der Hochstapler – 2012-05-14T17:09:52.780

@hydroparadise Done:) – Ajasja – 2012-05-14T18:40:50.007

Windows actually mounts the volume the first time a program tries to open a file on it. – psusi – 2012-05-15T00:03:29.620

That last one comes up in boot.ini, IIRC. – SLaks – 2012-05-15T02:45:34.960

1Just curious, how did you find out that [: is a valid drive letter? – Daniel Serodio – 2012-05-15T03:28:44.173

@psusi: True, but that definition of "open" is so broad that even enumerating drive letters triggers it, so it's almost automatic. – user1686 – 2012-05-15T06:59:10.807

4@Daniel: By giving all possible bytes to DefineDosDevice - which really accepts almost all of them. Turns out space is valid, too! – user1686 – 2012-05-15T07:02:50.413

2

@SLaks: No, boot.ini as used by NTLDR uses ARC paths; the Wiki article has interesting background on why it does so.

– user1686 – 2012-05-15T07:05:01.703

8If tween girls were tech savvy enough, they'd be all over setting their drive letters to [: – iglvzx – 2012-05-15T07:06:31.437

2Back in the dos days, we sometimes ended up having netware assign drive [: to the file server because it was the next available drive letter when you set LASTDRIVE=Z in system.ini, which reserved all of the letters. – psusi – 2012-05-15T13:33:25.050

5@psusi, LASTDRIVE went into config.sys. system.ini was Windows. – a CVn – 2012-05-15T13:43:53.163

@MichaelKjörling, oops! yes... – psusi – 2012-05-15T13:52:09.567

@MSalters: Regarding the last part of your edit – can't NT namespace be accessed via \.\GLOBALROOT? (e.g. \\.\GLOBALROOT\Device\HarddiskVolume1) – user1686 – 2012-06-08T13:25:00.357

43

mountvol.exe is the Windows equivalent.

mountvol example output

Der Hochstapler

Posted 2012-05-14T15:46:24.790

Reputation: 77 228

+1 for concise answer in one line and the answer is at the top. AND you provide bonus example screenshot! – Trevor Boyd Smith – 2012-05-16T12:03:59.660

The screenshot is not copy/pasteable and takes a lot of room, more than the equivalent text, for the same amount of information. This is not a good idea I think. – Ludovic Kuty – 2012-09-20T08:27:42.560

@LudovicKuty: Yeah, I was aware of that issue when I posted this. It's just the example output of what mountvol prints on my machine. So it shouldn't be anything too hard to reproduce. If I put the plain text in here, it became harder to read because of the box with scrollbars :( If you want to edit the answer to improve it, go ahead :) – Der Hochstapler – 2012-09-20T08:47:32.437

No, in fact many people are happy with that :) I mostly commented about the "AND you provide bonus example screenshot". It helps people, that's good. – Ludovic Kuty – 2012-09-20T09:11:05.483

6

Yes, but in general, it is handled automatically (say, with a USB drive).

The Disk Management utility (part of Computer Mgmt), allows you to manipulate volumes and mount points. Explorer does the same for network shares. There are command-line versions (diskpart.exe in WIn 7) as well depending on the version of Windows you run.

uSlackr

Posted 2012-05-14T15:46:24.790

Reputation: 8 755

1Also, unmounting hotswappable drives is usually done through the Safely Remove Hardware menu. To re-mount those devices, unplug the connection cable (USB/FireWire/eSATA) and plug it back in, or disable the USB/FireWire/etc. device from Device Manager and re-enable it, and Windows will automatically re-mount it. – Lèse majesté – 2012-05-14T16:17:12.657

So it is with some Linux distributions, e.g., Ubuntu. – krlmlr – 2012-05-14T20:04:22.587

3

The shortest, most obvious answer to fill in your _ _ _ _ _ _ is "mount". Linux mounts (and unmounts) file systems and so does Windows.

They each automate this process to varying degree depending a slew of mixed factors I'm not capable of listing, but I think caching strategies, user style/preference, and patents are significant influences on the automation of this process.

matty

Posted 2012-05-14T15:46:24.790

Reputation: 159