Mount folders in Linux

Operating systems Linux have one remarkable feature. Here all sections are displayed not in some abstract place called “My computer” and mounted in the root file system. You can control where and how will sotirova specific section. In the root file system mounted all the partitions of your hard drives, flash drives, network folders, and the virtual file system.

The result is that you get a single unified file system, with which you can manage all the features of Linux. You can mount not only partitions, but also folders.

Mount folders in Linux

You can mount any folder from the file system to a different folder, without any restrictions. To do this, use the same mount command. But it needs to be used together with option –bind. Above all, however, you have to wonder why you do it. If you need to associate these folders on a regular basis, perhaps the best solution would be to create a symbolic link.

If this is not possible, back to the mount. For example, we have folder /storage that we want to mount in the /mnt directory. All you have to do:

sudo mount --bind /storage /mnt

The way it works. But this mount point will be unstable. After a reboot you have to repeat all over again. To avoid this, you need to add a mount entry in /etc/fstab. For this example it will look like this:

sudo vi /etc/fstab

/storage /mnt none bind 0 0

However, this line need to be added to the end of the file, so that all devices on the target folder was already sotirova. To unmount the folder with the command umount:

sudo umount /mnt

Instead of mount you can use another utility bindfs. It performs almost the same actions, only for her to not need root privileges:

bindfs -n /storage /home/sergiy/mnt

This folder will be mounted only before the reboot. To unmount, use fusermount:

fusermount -u /home/sergiy/mnt

Insights

In this small article we discussed how to use to mount folders in Linux. As you can see, it’s very simple. I hope this information was useful to you.

Source: losst.ru

(Visited 35 times, 1 visits today)