0

What does mounting really mean in Linux?

And where/when can I use the mount command?

I'm new to Linux so I would appreciate a detailed answer.

Zanna
  • 70,465
NSD
  • 23
  • It isn't a Linux specific concept, other *nixes use mounting too. Windows, otoh, normaly assigns partitions and drives to a volume letter, so the root of that newly "mounted" partition is the volume letter. In Linux, you could mount the partition or drive to any point in the filesystem, you could mount it in / or /home/user/media... or really any other place. – Samuel Feb 21 '17 at 23:05
  • @SamuelSantana But aren't external peripherals automatically mounted when plugged in? And why would I want to mount something manually? What is the purpose or the scenarios that make me mount something? Why would I do it myself? – NSD Feb 21 '17 at 23:08
  • If you are managing a server with no gui, you will need to do this manually, using the mount and umount (that's right, umount and not unmount) commands. Check my answer. Also, some spartan linuxes, even with a gui, may not use a robust file manager like Nautilus which mounts volumes for you. – Samuel Feb 21 '17 at 23:19
  • @SamuelSantana So every time I plug in, say, a flash drive I should mount it manually? – NSD Feb 21 '17 at 23:32
  • @SamuelSantana I see some documentation requiring to mount an iso before the installation of a program. But, how come I mount the iso when I'm already running its OS?! Where's the logic in this? – NSD Feb 21 '17 at 23:35
  • An iso is a disk image, this is it's similar to having a CD but instead you have a file. I don't think iso files are mounted automatically, even on windows, you used to need a program like CdEmu to mount them. – Samuel Feb 21 '17 at 23:38
  • The content of the iso can be anything, you could have a music album or the files to install ubuntu. You don't need to mount it unless you want to explore its contents. To mount it you can go and do it manually with mount or use a graphical program... I suppose Nautilus can mount it. – Samuel Feb 21 '17 at 23:41
  • @SamuelSantana yeah I'm talking about Linux. The documentation tells that I should first mount the iso of the OS to configure the base OS repository. Why?and what is the difference between iso and OS? It is somehow confusing me that's why I'm asking a lot. – NSD Feb 21 '17 at 23:44
  • @SamuelSantana The thing is I'm currently using a Linux. And it tells me to mount the iso of the linux. Why would I do that if I am already running Linux? This is what's confusing me.. – NSD Feb 21 '17 at 23:47
  • Are you installing Linux atm or have you already done this? – Samuel Feb 21 '17 at 23:49
  • @SamuelSantana i'm planning to. – NSD Feb 21 '17 at 23:50
  • Ah, we are making some progress! hehe... you would only need to install files from the disk if you don't have an internet connection when installing the system. If you do have internet, you can pull all the files from the Ubuntu repositories. Is this your case? Will you install Ubuntu on a machine that can't connect to the internet while installing? – Samuel Feb 21 '17 at 23:53
  • Glad I could be of any help! If you have another issue, don't hesitate to ask another question. I'd recommend you watch a video to make yourself more familiar with the whole install process: https://www.youtube.com/watch?v=j5iFE6zBHPE – Samuel Feb 22 '17 at 00:04
  • If you are planning to install a server rather than a desktop, this video gives you a nice overview of the process: https://www.youtube.com/watch?v=P5lMuMhmd4Q – Samuel Feb 22 '17 at 00:10

2 Answers2

1

Mounting means that you associate specific part of your hard drive with a folder on system. If you mount USB drive, it will be associated with some folder , for example /mnt/usbdisk. You then can go into that folder, and browse files (if disk is mounted with appropriate permissions). But until you mount it, you cant go there.

Disk can be physically inserted into machine, but mounting is software concept. So even though a disk might be connected physically, you cannot use it until you mount it.

You can mount any filesysyem, in general. It could be a network drive, for example,too.

Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497
  • But aren't external peripherals automatically mounted when plugged in? And why would I want to mount something manually? What is the purpose or the scenarios that make me mount something? Why would I do it myself? – NSD Feb 21 '17 at 23:08
  • 1
    @NSD: Desktop operating systems will try to mount automatically any filesystem found on removable media when plugged in. Server operating systems do not normally automount anything. – AlexP Feb 21 '17 at 23:10
  • @NSD automatic mounting is still mounting, except it is not done by you, but by some other program. The concept is the same. Purpose can be varied. For example, i have two hard drives in my laptop and mount second hard drive with my Windows stuff only I need to, and don't need to keep it mounted 24/7. – Sergiy Kolodyazhnyy Feb 21 '17 at 23:12
  • Just for user convenience,.it is done automatically.on desktop. In servers, you dont need that.convenience because servers are operated by professional users – Sergiy Kolodyazhnyy Feb 21 '17 at 23:14
  • So how do server users use the mounting concept? Their purposes of mounting? Wouldn't it be inconvenient for them too? How would they benefit from the non-automation of mounting? Scenarios? – NSD Feb 21 '17 at 23:24
  • Well, to automatically mount drives you would need a daemon (service) to detect when drives are inserted and then mount it. Why would you add a daemon that is running all the time when the admin can do it manually just when it is needed? You can also mount volumes during boot (edit /etc/fstab), so that you don't have to mount it manually every time. – Samuel Feb 21 '17 at 23:31
  • @SamuelSantana so when I plug in a flash drive for example and mount it, and then plug it in again does it recognize it or shall I mount it every time I plug it in? – NSD Feb 21 '17 at 23:38
  • 1
    Correction: that's not Nautilus that does the job, that's the UDisks daemon. Also, removing filesystem that wasn't unmounted can lead to that filesystem being corrupted. It's the same as removing it in Windows without "ejecting" the drive first – Sergiy Kolodyazhnyy Feb 22 '17 at 00:21
1

Mounting isn't a Linux specific concept: other *nixes do it too. Windows, otoh, assigns devices to a volume letter, so the root of that device is the volume letter. In GNU/Linux distributions, the device could be mounted on any point of the filesystem (well, in Windows too, but that's another story), it could be mounted right under / or /home/username... or really any other place.

Lets say you insert a USB stick, in some GNU/Linux systems, like Ubuntu Desktop, a daemon may automatically mount it for you, on Ubuntu it will normally mount it under /media/{username}.

You can manually do this. Imagine that for any reason you want to mount the stick under your home directory, we would do it this way:

First, create a dir: mkdir ~/usb_tmp

Then, mount it there: mount /dev/sdb1 ~/usb_tmp.

Note: I use "/dev/sdb1" for this example's purposes, but this really is a representation of your USB stick and it could vary. You would need to figure that with sudo fdisk -l.

Afterwards you could navigate there, as you would with any other directory, and see the contents of the USB stick.

Samuel
  • 1,015