Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What underlying things happen when you mount a drive. Even when a drive isnt mounted, it is visible to the computer (such as sudo fdisk -l / diskutil -list). When a drive is mounted, is all that is happening is that the OS is giving a path to the device or is there some filesystem "magic" occuring?

share|improve this question

3 Answers 3

There is some filesystem "magic" occurring.

It may help to think of your Disk system in layers. The lowest layer being the block device, then the partitions on top, then the filesystem on top of that.

When a drive is mounted, the mount program, in conjunction with the kernel and possibly /etc/fstab works out what kind of filesystem is on the partition, and then implements (through kernel calls), standard filesystem calls to allow manipulation of the filesystem, including reading, writing, listing, permissions etc.

In fact you can easily add additional layers to this, and it all works the same way. (One common one is LVM, which sits between the partition and the filesystems, and allows you to resize, add and remove disks, even on a running filesystem). I mention this because it shows there is more to it then just giving a path to the device.

Similarly, different kernels will have support for different filesystems (for example some might include ReiserFS, btrfs etc). Also it is possible to implement a file system (which can still be mounted and unmounted) using files in "user space" (fuse). This will, for example allow the mounting of virtual filesystems which are not part of the kernel, or even virtual filesystems - I have, for example, mounted FTP directories and even remote paths over ssh as filesystems (and, of-course, NFS and SAMBA shares), as well as encrypted files, and merging multiple directories for a unified filesystem - all of these are "types of magic" done through the kernel, usually with the help of the mount command.

share|improve this answer

When a filesystem is mounted from a block device, several preparations will be made including

  • Reading per-filesystem information like the filesystem type, version, options, amount of free space...
  • Checking if the filesystem was shut down (unmounted) properly last time
  • Checking if the block device is read-only (floppy disk/SD card switch, CDROM/DVD).
  • Replaying the operations recorded in the "journal" of the filesystem, if it has one.
share|improve this answer

when you mount a Linux filesystem like ext2, ext3, ext4, .. a copy of super block of filesystem will reside in memory for further actions

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.