In this post I’ll be talking about mounting partitions of a hard disk and other devices like external media (USB sticks, portable hard disks, CDs, DVDs etc) on both Windows systems and on Linux systems.
First of all if you don’t know what the word “mounting” means , don’t worry. Because if you are from the Windows world, chances are that, you have never even heard of the word mounting even though you see it happening every time it’s being done, or rather you never had the need to hear of it.
That’s because Windows does everything needed to mount the partitions and the user doesn’t need to know anything that goes on in the background.
So what exactly is mounting? Simply put, it is the process of making the contents of a device (be it a partition on a hard disk or external media like USB sticks or CDs) accessible to the user by showing its contents in a folder.
More specifically, it is the process of making the file system of the device accessible to the user, since every storage media or device has a file system on which the files are stored. Each device uses a different file system to store the files. For example a Hard disk formatted by Windows uses NTFS (New Technology File System), Linux uses different file systems like ext2, ext3 etc whereas a USB stick would use FAT file system and optical discs like CDs and DVDs use UDF (Universal Disk Format) file system.
Now lets see how Windows and Linux handle this process of mounting by considering a simple scenario.
Scenario:
We have a computer with an internal hard disk with two partitions, a data DVD and a USB stick that we need to access.
Windows:
In Windows, all we need to do to access the files on these devices is, to plug the USB stick in the USB port, put the DVD in the DVD drive and click on the familiar “My Computer” icon and we have a list of drives or devices mounted and ready to be used.
“My Computer” is not a directory. It is only a Window or a user interface using which we can access all our mounted drives. After mounting the devices, Windows names the drives as follows.
In our scenario above, we have an internal hard disk with two partitions. Windows is obviously installed on one of the partitions. So Windows lists its own partition as the “C:\” Drive. This called is the “root directory” of that partition.
Root directory is the beginning of the path of any file, in a file system. Path is how we denote the location of a file, in a file system.
The second partition on the internal hard disk would be named “D:\”. The DVD drive would be named E:\, and the USB stick when connected, would be mounted automatically and named with the next available alphabet i.e F:\ in our scenario. If any other devices are connected , they would be given the next available drive letters i.e “G:\” , “H:\” and so on.
See the picture below to get a clearer idea.
Pathnames in Windows:
Now say we have a directory named “MyFolder” in the “D:\” partition. Then it’s path would be “D:\MyFolder” and if have a file called “MyFile” in the “MyFolder” directory , the path of the file would be “D:\MyFolder\MyFile” and so on.
Note that the root directory of each partition is different and is denoted by the drive letter of the respective device followed by “:\”.
The path of the files or directories on that device therefore starts with the drive letter assigned by windows, followed by the directory and/or filename.
For example a file called “MyUSBFile” within a directory named “MyUSBFolder” on the USB stick would have a path name, “F:\MyUSBFolder\MyUSBFile”
Whereas the path of a file called “MyDVDFile” within a directory called “MyDVDFolder” on a DVD would have a pathname of “E:\MyDVDFolder\MyDVDFile”.
If the above mounted file systems were represented as a hierarchical tree they would look like as shown below
Another thing to note is that in Windows the pathnames are not case-sensitive.i.e windows considers both these pathnames as the same
“E:\MyDVDFolder\MyDVDFile” , “e:\mydvdfolder\mydvdfile” So you need not be particular about the capitalizations.
Linux:
In Linux the mounting process and the way the file system is organized is totally different than what we just saw above, in the Windows section.
Consider the exact same scenario as above but instead of Windows, say Linux has been installed on the first partition of the hard disk.
Linux does not automatically mount all the partitions by default, unless configured to do so. That is not the only difference between Windows and Linux.
Another major difference is that Linux has only one root directory, no matter how many partitions or devices have been mounted .The root directory is denoted by a forward slash “/”. That is because Linux does not assign a drive letter to every storage device that has been mounted. Instead, Linux mounts the partitions to a sub-directory under the main root directory. So the path to any file on any device starts with a “/”, followed by the subfolder name, to which the device’s contents have been mounted.
Now considering our scenario, since the Linux operating system has been installed on the first partition of the internal hard disk, its contents will be shown under the main root directory. I will be talking about the different directories in the Linux root directory and their contents in a different post.
For now, it suffices to understand that Linux mounts the different device file systems and partitions to different sub-directories under the “media” or “mnt” directories, which are in turn sub-directories of the root directory. The paths of these folders therefore are, /mnt and /media. If the devices are to be mounted to a different directory other than the /mnt or the /media directory, the path needs to be specified by the user.
See the picture below to understand how the different devices are mounted under the Linux file system.
Pathnames in Linux
Lets now come back to our current scenario . Assuming that the second partition of the internal hard disk has been mounted to the directory “/mnt/part2”,all the contents of the second partition can now be accessed through that directory. So to access a directory called “MyFolder” in that partition, the path would be “/mnt/part2/MyFolder” and likewise, the path of a file called “MyFile” in the “MyFolder” directory would be “/mnt/part2/MyFolder/MyFile” .
Now consider that the USB stick has been mounted to the directory “/mnt/MyUSB”. To access a file called “MyUSBFile” placed in a directory called “MyUSBFolder” on the USB stick, the path of the file would be “/mnt/MyUSB/MyUSBFolder/MyUSBFile”.
The important thing to note here is that the name of the directory to which the device is mounted is entirely in the User’s hands. So instead of mounting the contents of the USB stick to the directory named “MyUSB” if we mount it to a different directory called “USBmount”, the path of the same file would become “/mnt/USBmount/USBFolder/MyUSBFile”.
If the above file system was represented as a hierarchical tree it would look like as shown below
As you can see all the path names start with “/” as explained in the beginning of the Linux section.
Important Note:
I mentioned above in the Windows section that windows is not case sensitive, but in Linux it is the other way round. The importance of using the proper case for filenames and path names cannot be stressed enough.
For example:
“/media/MyUSBFolder/MyUSBFile” and “/media/MyUSBFolder/myusbfile” would represent two different files.If we type th second path, Linux will give you an error or it would point you to another file named ”myusbfile” if it exists, instead of the file “MyUSBFile” that we want to access. This is because you can have two files with the names “MyUSBFile” and “myusbfile” within the same directory. This is possible even though the names are same, since Linux is case sensitive.In Windows however, this is not possible .
I hope you now have an idea of what mounting means and how it is different in Windows and in Linux.
Do read the post Linux Directory Structure if would like to know about the different directories in Linux.