Linux – Trouble with understanding the concept of mounting

deviceslinuxmount

Having read both What is meant by mounting a device in Linux? and understanding "mount" as a concept in the OS, I have a problem where it is stated that

All accessible storage must have an associated location in this single directory tree. This is unlike Windows where (in the most common syntax for file paths) there is one directory tree per storage component (drive). Mounting is the act of associating a storage device to a particular location in the directory tree.

But there is already an accessible location for say a cdrom drive under /dev/cdrom which obviously comes in the directory hierarchy. So why the need for creating a separate "mount point" under /media/cdrom? Why accessing directly from /dev/cdrom is made impossible? I heard that that the device node files are just like ordinary files. And reading and writing to them is just like ordinary files. So does this mean that the filesystem in the cdrom is not available if we access it from /dev/cdrom. And the filesystem hierarchy(inside the cdrom) "comes alive" when we "mount" it?

Best Answer

You can read or write /dev/cdrom (eg, using dd or cat) but when you do that you are just reading or writing the raw bytes of the device. That can be useful in various circumstances (like cloning a partition), but generally we want to see the directories and files stored on the device.

When you mount a device you're basically telling the kernel to use a layer of software (the filesystem driver) to translate those raw bytes into an actual filesystem. Thus mounting a device associates the filesystem on that device to the directory hierarchy.

Related Question