Categories
Linux Tutorial Series

Linux Tutorial Series – 147 – Why is unmounting important?

Here is the video version, if you prefer it:

When you attach a new device to your machine, it is most likely automatically mounted (at least it is on my Debian 10). However, when you want to stop using the device, it is always a good idea to right click on it (in the GUI) and press something along the lines of “Safely remove device”. Why is it so?

You see, in operating systems, there are these things called buffers. Think of buffers like this. Let’s say you were transporting a bunch of wooden planks. The guy who has the truck to transport it comes to your driveway, takes all the planks at your driveway and drives them to the destination. The problem is that it takes a very long time for the driver to go from your house to the destination. So, if you were to carry planks on a plank-by-plank basis and you always waited for the driver with only one plank in your hands, the job would take a very, very long time. But, you can carry planks on the driveway and once the driver arrives, he picks up all the planks on the driveway and drives them to the destination. In this analogy, your driveway is the buffer.

This driving wooden planks analogy can be used to explain writing data to an attached device (such as an USB or an external hard drive). Your operating system has a buffer to which it writes the data and then it writes the data from the buffer to your external device, because data can be written much faster from your operating system to the buffer than from the buffer to your external device. The buffer exists to equalize the speed difference.

So now we come to the reason why unmounting is important – unmounting makes sure that all of the data in the buffer is written to the external device. This happens, again, because writing to the buffer is a lot faster than it is to transfer data from the buffer to an external device.

Hope you learned something interesting today!

Categories
Linux Tutorial Series

Linux Tutorial Series – 146 – Unmounting a device

Here is the video version, if you prefer it:

To unmount a device, type in the following command: (Ward, 2014)⁠

umount mountpoint

where mountpoint is the mount point of the device. Mind the spelling of the command.

Hope you learned something useful!

References

Ward, B. (2014). How Linux Works: What Every Superuser Should Know (2nd ed.). No Starch Press. Page 76

Categories
Linux Tutorial Series

Linux Tutorial Series – 144 – Mounting and unmounting

Here is the video version, if you prefer it:

Today we will talk about something more conceptual yet again. I know that you might be thinking: “Why this conceptual stuff again? It’s been a lot of that lately and I’m tired of that…”. I get it. But be patient – this knowledge will pay off. I am trimming the fat – the things you don’t need to know – but it pays to know these particular concepts. Especially mounting and unmounting because even though you’ll probably never do those manually, there will be some situations where you will have to mount or unmount (an example – “burning” an operating system on an USB) and you have to know what is going on.

Still with me? Good. So what is mounting? Mounting is the process of attaching your device(your device’s storage)in the Linux directory structure. As we know, everything in Linux starts from the root folder (/). Every other directory is accessible from the root folder by navigating from the root folder to the other folders hierarchically below it. When you insert a new device (say, a USB drive) you have to place it in a directory so that it is accessible from the root directory. The directory in which the new device resides is called its mount point. That process (when you assign a directory accessible from the root folder to a new device) is called mounting. Unmounting is the reverse process from mounting – removing the association between a directory in the directory hierarchy and the device (device’s storage).

So basically, when you mount, you make your device’s storage accessible to your Linux computer and when you unmount, you make your device’s storage inaccessible. Not all devices that are mounted need to have storage, but that doesn’t matter for our practical applications. (“What is meant by mounting a device in Linux?,” n.d.)⁠

I modeled my explanation after (“understanding ‘mount’ as a concept in the OS [duplicate],” n.d.)⁠ , which you can read as well for a second perspective.

Thank you for reading!

References

understanding “mount” as a concept in the OS [duplicate]. (n.d.). Retrieved February 12, 2020, from https://unix.stackexchange.com/questions/3247/understanding-mount-as-a-concept-in-the-os

What is meant by mounting a device in Linux? (n.d.). Retrieved February 12, 2020, from https://unix.stackexchange.com/questions/3192/what-is-meant-by-mounting-a-device-in-linux