


Is the command to mount a hard disk in Linux the mount command?
The linux command to mount a hard disk is the mount command. Mount is a mounting command that can mount a partition under a folder to connect the partition and the directory. In the future, simply accessing this folder will be equivalent to accessing the partition. The syntax is "mount [-t system type] [- L volume name] [-o special option] [-n] device file name mount point".
#The operating environment of this tutorial: linux7.3 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".
If it is not mounted, the hardware device can be found through the graphical interface system in the Linux system, but it cannot be found through the command line.
Mounting refers to connecting the top-level directory in the device file to a directory (preferably an empty directory) under the Linux root directory. Accessing this directory is equivalent to accessing the device file.
To mount the file system to a Linux system, you need to use the mount
mount command.
Linux mount command: Mount files outside the Linux system
The mount command is to mount the partition to a folder. The partition is associated with the directory. In the future, as long as we access this folder, it will be equivalent to accessing the partition.
The common formats of the mount command are as follows:
1 |
|
Simply using the mount command will display the mounted device information in the system, use the -l
option , the volume name will be additionally displayed (readers can run it by themselves to view the output); the
1 |
|
-a
option means to automatically check whether there are any omissions in the /etc/fstab file. If there is a device file to be loaded, the device file will be automatically mounted. 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.
1 |
|
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 file system’s volume label name to mount load.-n
: By default, the system will write the actual mounting situation to the /etc/mtab file in real time, but in some scenarios (For example, 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, synchronization/asynchronous, etc. If not specified, the defaults will be 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】
1 2 3 4 5 6 7 8 9 10 |
|
【例 2】
修改特殊权限。通过例 1 我们查看到,/boot 分区已经被挂载了,而且采用的是 defaults 选项。这里我们重新挂载分区,并采用 noexec 权限禁止执行文件执行,看看会出现什么情况(注意不要用 / 分区做实验,否则系统命令也就不能执行了。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
对于特殊选项的修改,除非特殊场景下需要,否则不建议大家随意修改,非常容易造成系统出现问题,而且还找不到问题的根源。
【例 3】挂载分区。
1 2 3 4 5 |
|
/dev/sdb1 分区还没有被划分。我们在这里只看看挂载分区的方式,非常简单,甚至不需要使用 "-ext4" 命令指定文件系统,因为系统可以自动检测。
可能读者会想,为什么使用 Linux 系统的硬盘分区这么麻烦,而不能像 Windows 系统那样,硬盘安装上就可以使用?
其实,硬盘分区(设备)挂载和卸载(使用 umount 命令)的概念源自 UNIX,UNIX 系统一般是作为服务器使用的,系统安全非常重要,特别是在网络上,最简单有效的方法就是“不使用的硬盘分区(设备)不挂载”,因为没有挂载的硬盘分区是无法访问的,这样系统也就更安全了。
另外,这样也可以减少挂载的硬盘分区数量,相应地,也就可以减少系统维护文件的规模,当然也就减少了系统的开销,即提高了系统的效率。
推荐学习:Linux视频教程
The above is the detailed content of Is the command to mount a hard disk in Linux the mount command?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

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

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

Undress AI Tool
Undress images for free

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)

Hot Topics



Docker process viewing method: 1. Docker CLI command: docker ps; 2. Systemd CLI command: systemctl status docker; 3. Docker Compose CLI command: docker-compose ps; 4. Process Explorer (Windows); 5. /proc directory (Linux).

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

VS Code is available on Mac. It has powerful extensions, Git integration, terminal and debugger, and also offers a wealth of setup options. However, for particularly large projects or highly professional development, VS Code may have performance or functional limitations.

VS Code is the full name Visual Studio Code, which is a free and open source cross-platform code editor and development environment developed by Microsoft. It supports a wide range of programming languages and provides syntax highlighting, code automatic completion, code snippets and smart prompts to improve development efficiency. Through a rich extension ecosystem, users can add extensions to specific needs and languages, such as debuggers, code formatting tools, and Git integrations. VS Code also includes an intuitive debugger that helps quickly find and resolve bugs in your code.

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

Visual Studio Code (VSCode) is a cross-platform, open source and free code editor developed by Microsoft. It is known for its lightweight, scalability and support for a wide range of programming languages. To install VSCode, please visit the official website to download and run the installer. When using VSCode, you can create new projects, edit code, debug code, navigate projects, expand VSCode, and manage settings. VSCode is available for Windows, macOS, and Linux, supports multiple programming languages and provides various extensions through Marketplace. Its advantages include lightweight, scalability, extensive language support, rich features and version
