In Linux, mount means "mounting" and is used to associate the device file system and the Linux file system through the specified directory; the syntax is "mount [-t system type] [-L volume name] [-o special option] [-n] device file name mount point", "mount -a", etc.
#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
In the Linux system, "everything is a file", and all files are placed in a tree directory structure with the root directory as the root. From Linux's perspective, any hardware device is also a file, and each of them has its own file system (file directory structure).
The problem that arises is that when using these hardware devices in a Linux system, the hardware device can only be used by us if the file directory of Linux itself and the file directory of the hardware device are combined into one. The process of combining the two into one is called "mounting".
Mounting refers to connecting the top-level directory in the device file to a directory under the Linux root directory (preferably an empty directory). Accessing this directory is equivalent to accessing the device file.
Mounting refers to associating the file system of the hardware device with the file system in the Linux system by specifying the directory (as the mount point). To mount the file system on a Linux system, you need to use the mount command.
The common formats of the mount command are as follows:
mount [-l]
Simply using the mount command will display the device information that has been mounted in the system. Using the -l option will additionally display the volume. Tag name (readers can run it themselves and view the output results);
mount -a
-a
option means to automatically check whether there are any omitted mounted device files in the /etc/fstab file. If If yes, the automatic mounting operation will be performed. Here is a brief introduction to the /etc/fstab file. This file is an automatically mounted file. When the system is powered on, it will actively read the contents of the /etc/fstab file. According to the configuration of the file, the system will automatically mount the specified device. The specific introduction to automatic mounting (modifying this file) will be explained in a subsequent article.
mount [-t 系統(tǒng)類(lèi)型] [-L 卷標(biāo)名] [-o 特殊選項(xiàng)] [-n] 設(shè)備文件名 掛載點(diǎn)
The meanings of each option are:
-t System type: Specify the file system type to be mounted. Commonly supported types in Linux include EXT2, EXT3, EXT4, iso9660 (disc format), vfat, reiserfs, etc. If you do not specify a specific type, Linux will automatically detect it when mounting.
-L Volume label name: In addition to using the device file name (such as /dev/hdc6), you can also use the volume label name of the file system for mounting.
-n: By default, the system will write the actual mounting situation into the /etc/mtab file in real time, but in some scenarios (such as single-player maintenance mode ), in order to avoid problems, it will be deliberately not written. In this case, you need to use this option;
-o Special options: You can specify additional options for mounting, such as read and write permissions , synchronous/asynchronous, etc., if not specified, the defaults are used. For specific special options, see Table 1;
Options | Function |
---|---|
rw/ro | Whether you have read and write permissions on the mounted file system, rw is the default value, which means you have read and write permissions; ro means read-only permissions. |
async/sync | Whether this file system uses synchronous writing (sync) or asynchronous (async) memory mechanism, the default is asynchronous async. |
dev/nodev | Whether it is allowed to extract data from the block file of this file system. In order to ensure data installation, the default is nodev. |
auto/noauto | Whether to allow this file system to be automatically mounted using mount -a, the default is auto. |
suid/nosuid | Set whether the file system has SetUID and SetGID permissions. The default is yes. |
exec/noexec | Set whether to allow execution of executable files in the file system. The default is allowed. |
user/nouser | Set whether this file system allows ordinary users to use mount to perform mounting. The default is not allowed (nouser), only root can . |
defaults | Define the default value, which is equivalent to the seven options of rw, suid, dev, exec, auto, nouser, and async. |
remount | Remount the mounted file system, generally used to specify and modify special permissions. |
【例 1】
[root@localhost ~]# mount #查看系統(tǒng)中已經(jīng)掛載的文件系統(tǒng),注意有虛擬文件系統(tǒng) /dev/sda3 on / type ext4 (rw) <--含義是,將 /dev/sda3 分區(qū)掛載到了 / 目錄上,文件系統(tǒng)是 ext4,具有讀寫(xiě)權(quán)限 proc on /proc type proc (rw) sysfe on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw, gid=5, mode=620) tmpfs on /dev/shm type tmpfs (rw) /dev/sda1 on /boot type ext4 (rw) none on /proc/sys/fe/binfmt_misc type binfmt_misc (rw) sunrpc on /var/lib/nfe/rpc_pipefs type rpc_pipefs (rw)
【例 2】
修改特殊權(quán)限。通過(guò)例 1 我們查看到,/boot 分區(qū)已經(jīng)被掛載了,而且采用的是 defaults 選項(xiàng)。這里我們重新掛載分區(qū),并采用 noexec 權(quán)限禁止執(zhí)行文件執(zhí)行,看看會(huì)出現(xiàn)什么情況(注意不要用 / 分區(qū)做實(shí)驗(yàn),否則系統(tǒng)命令也就不能執(zhí)行了。
[root@localhost ~]# mount -o remount noexec /boot #重新掛載 /boot 分區(qū),并使用 noexec 權(quán)限 [root@localhost sh]# cd /boot #寫(xiě)一個(gè) shell 腳本,看是否會(huì)運(yùn)行 [root@localhost boot]#vi hello.sh #!/bin/bash echo "hello!!" [root@localhost boot]# chmod 755 hello.sh [root@localhost boot]# ./hello.sh -bash:./hello.sh:權(quán)限不夠 #雖然賦予了hello.sh執(zhí)行權(quán)限,但是仍然無(wú)法執(zhí)行 [root@localhost boot]# mount -o remount exec /boot #記得改回來(lái),否則會(huì)影響系統(tǒng)啟動(dòng)
對(duì)于特殊選項(xiàng)的修改,除非特殊場(chǎng)景下需要,否則不建議大家隨意修改,非常容易造成系統(tǒng)出現(xiàn)問(wèn)題,而且還找不到問(wèn)題的根源。
【例 3】掛載分區(qū)。
[root@localhost ~]# mkdir /mnt/disk1 #建立掛載點(diǎn)目錄 [root@localhost ~]# mount /dev/sdb1 /mnt/disk1 #掛載分區(qū)
/dev/sdb1 分區(qū)還沒(méi)有被劃分。我們?cè)谶@里只看看掛載分區(qū)的方式,非常簡(jiǎn)單,甚至不需要使用 "-ext4" 命令指定文件系統(tǒng),因?yàn)橄到y(tǒng)可以自動(dòng)檢測(cè)。
可能會(huì)想,為什么使用 Linux 系統(tǒng)的硬盤(pán)分區(qū)這么麻煩,而不能像 Windows 系統(tǒng)那樣,硬盤(pán)安裝上就可以使用?
其實(shí),硬盤(pán)分區(qū)(設(shè)備)掛載和卸載(使用 umount 命令)的概念源自 UNIX,UNIX 系統(tǒng)一般是作為服務(wù)器使用的,系統(tǒng)安全非常重要,特別是在網(wǎng)絡(luò)上,最簡(jiǎn)單有效的方法就是“不使用的硬盤(pán)分區(qū)(設(shè)備)不掛載”,因?yàn)闆](méi)有掛載的硬盤(pán)分區(qū)是無(wú)法訪問(wèn)的,這樣系統(tǒng)也就更安全了。
另外,這樣也可以減少掛載的硬盤(pán)分區(qū)數(shù)量,相應(yīng)地,也就可以減少系統(tǒng)維護(hù)文件的規(guī)模,當(dāng)然也就減少了系統(tǒng)的開(kāi)銷(xiāo),即提高了系統(tǒng)的效率。
相關(guān)推薦:《Linux視頻教程》
The above is the detailed content of What does mount in linux mean?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Linux and Windows have their own advantages and disadvantages in CPU and memory usage: 1) Linux uses time slice-based scheduling algorithms to ensure fairness and efficiency; Windows uses priority scheduling, which may cause low-priority processes to wait. 2) Linux manages memory through paging and switching mechanisms to reduce fragmentation; Windows tends to pre-allocate and dynamic adjustment, and efficiency may fluctuate.

Linux's cost of ownership is usually lower than Windows. 1) Linux does not require license fees, saving a lot of costs, while Windows requires purchasing a license. 2) Linux has low hardware requirements and can extend the service life of the device. 3) The Linux community provides free support to reduce maintenance costs. 4) Linux is highly secure and reduces productivity losses. 5) The Linux learning curve is steep, but Windows is easier to use. The choice should be based on specific needs and budget.

LinuxoftenoutperformsWindowsinI/Operformanceduetoitscustomizablekernelandfilesystems,whileWindowsoffersmoreuniformperformanceacrosshardware.1)LinuxexcelswithcustomizableI/OschedulerslikeCFQandDeadline,enhancingperformanceinhigh-throughputapplications

The key to installing dual systems in Linux and Windows is partitioning and boot settings. 1. Preparation includes backing up data and compressing existing partitions to make space; 2. Use Ventoy or Rufus to make Linux boot USB disk, recommend Ubuntu; 3. Select "Coexist with other systems" or manually partition during installation (/at least 20GB, /home remaining space, swap optional); 4. Check the installation of third-party drivers to avoid hardware problems; 5. If you do not enter the Grub boot menu after installation, you can use boot-repair to repair the boot or adjust the BIOS startup sequence. As long as the steps are clear and the operation is done properly, the whole process is not complicated.

The key to enabling EPEL repository is to select the correct installation method according to the system version. First, confirm the system type and version, and use the command cat/etc/os-release to obtain information; second, enable EPEL through dnfinstallepel-release on CentOS/RockyLinux, and the 8 and 9 version commands are the same; third, you need to manually download the corresponding version of the .repo file and install it on RHEL; fourth, you can re-import the GPG key when encountering problems. Note that the old version may not be supported, and you can also consider enabling epel-next to obtain the test package. After completing the above steps, use dnfrepolist to verify that the EPEL repository is successfully added.

Linux usually performs better in web server performance, mainly due to its advantages in kernel optimization, resource management and open source ecosystem. 1) After years of optimization of the Linux kernel, mechanisms such as epoll and kqueue make it more efficient in handling high concurrent requests. 2) Linux provides fine-grained resource management tools such as cgroups. 3) The open source community continuously optimizes Linux performance, and many high-performance web servers such as Nginx are developed on Linux. By contrast, Windows performs well when handling ASP.NET applications and provides better development tools and commercial support.

Newbie users should first clarify their usage requirements when choosing a Linux distribution. 1. Choose Ubuntu or LinuxMint for daily use; programming and development are suitable for Manjaro or Fedora; use Lubuntu and other lightweight systems for old devices; recommend CentOSStream or Debian to learn the underlying principles. 2. Stability is preferred for UbuntuLTS or Debian; you can choose Arch or Manjaro to pursue new features. 3. In terms of community support, Ubuntu and LinuxMint are rich in resources, and Arch documents are technically oriented. 4. In terms of installation difficulty, Ubuntu and LinuxMint are relatively simple, and Arch is suitable for those with basic needs. It is recommended to try it first and then decide.

The steps to add a new hard disk to the Linux system are as follows: 1. Confirm that the hard disk is recognized and use lsblk or fdisk-l to check; 2. Use fdisk or parted partitions, such as fdisk/dev/sdb and create and save; 3. Format the partition to a file system, such as mkfs.ext4/dev/sdb1; 4. Use the mount command for temporary mounts, such as mount/dev/sdb1/mnt/data; 5. Modify /etc/fstab to achieve automatic mount on the computer, and test the mount first to ensure correctness. Be sure to confirm data security before operation to avoid hardware connection problems.
