0

I'm pretty new to Linux and I've been trying to understand how the file system works but I just can't seem to get what mounting is. I've seen several other questions on this site explaining but they have too much lingo I don't understand yet.

From what I understand mounting allows the system to read the files but how does it do that? Then, after you've mounted something you'll get one file in /dev and /media from it. The /media is supposed to be the contents of the device and /dev is just telling the system how to interpret that info?

If someone could use Windows as a comparison to how this works I might understand better, but from what I've read windows doesn't show the user this process at all. I believe people say Linux only does this because they're open source and want to give full control to the user which makes sense.

PS: I am learning how to use Linux on Ubuntu since it seems the most beginner-friendly, I don't know if other distributions do it differently.

2

after you've mounted something you'll get one file in /dev and /media from it

This is not correct. For every block device, you always have a file in /dev, even for devices that are not mounted. Files in /dev represent devices (and not only block devices, you can read more about /dev here), for example /dev/sda is your first (SATA) hard drive and /dev/sda1 first partition on it. You can read and write from/to these devices directly, you don't need to mount anything (but that's generally not a good idea).

By mounting a device you are telling the system something like "this device contains a filesystem and I want its content accessible here". That's where /media comes in. /media is just a "normal" folder, it is used as a destination when mounting (mostly) removable devices (like USB flash drives, SD cards etc.) but you don't need to use /media, you can use any other folder -- if you run mount /dev/sdb1 /media/data this only means content of the sdb1 (first partition on your second disk) will be available in /media/data, you could as well mount it to a directory in your home folder or /data or /whatever/data.

Windows has the same internal logic, but it hides it from you. Similarly GNOME or KDE also hide this logic, in file browsers you see devices like "XY GiB Hard Drive" that are not mounted and by clicking on them, system mounts them and you can browse the filesystem without actually knowing the difference between device and its mountpoint.

2
  • I would rather say that you mount a filesystem (on a partition most of the time) on a device, not simply a device.
    – solsTiCe
    Jun 14 at 9:16
  • 1
    you don't mount on a device, you mount (from) a block device file on a directory. Or as pointed out, it doesn't have to be a device file, it could be a regular file containing a filesystem image, with no device involved.
    – user10489
    Jun 14 at 11:43
0

Over simplifying, for educational purpose, all devices containing file systems, like partitions, images (of partitions, not pictures) in /dev are files. Files you can read like any other files. Mount gives you representation of these files, with files and directories structure in mount point (usually /mnt or /media). This way you can read and write to files and directories mounted under directory in /mnt.

Add been said in earlier answer mount point is point of your choice, you can do it in any directory, even /my/aunties/images:

# mount /dev/sdb1 /my/aunties/images

Now, first partition (1) on usb with your aunties images residing in /dev/sdb is mounted in designated directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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